When compiling a program, I am shown the following error messages:
Undefined symbols for architecture x86_64:
"_jrand_", referenced from:
___trfind_module_MOD_trfind in ccqRBw2L.o
(maybe you meant: ___jrand_module_MOD_jrand)
"_left_", referenced from:
___trmesh_module_MOD_trmesh in ccq56SyA.o
(maybe you meant: ___left_module_MOD_left)
"_lstptr_", referenced from:
___intadd_module_MOD_intadd in ccr7Tz7x.o
___swap_module_MOD_swap in cclq1Td3.o
___trfind_module_MOD_trfind in ccqRBw2L.o
___addnod_module_MOD_addnod in ccwGNCEK.o
(maybe you meant: ___lstptr_module_MOD_lstptr)
"_store_", referenced from:
___trfind_module_MOD_trfind in ccqRBw2L.o
(maybe you meant: ___store_module_MOD_store)
"_swptst_", referenced from:
___addnod_module_MOD_addnod in ccwGNCEK.o
(maybe you meant: ___swptst_module_MOD_swptst)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I understand that this comes about because of incorrect linking between modules. My question is how exactly to interpret the information the compiler is giving. What does "in ccqRBw2L.o" mean, for example?
For you the most important are the suggestions maybe you meant.
It as very probable you forgot to use the relevant modules. In particular
"_jrand_", referenced from:
___trfind_module_MOD_trfind in ccqRBw2L.o
(maybe you meant: ___jrand_module_MOD_jrand)
when linking the object file ccqRBw2L.o (the name is controlled by your build mechanism, some Makefile or similar) the linker did not find any symbol _jrand_ which would be an external subroutine or function called jrand.
However the linker sees that there is something called jrand.
maybe you meant: ___jrand_module_MOD_jrand
but it is not external, it seems to be located in the module called jrand.
You should make sure you use the module (use jrand) when calling the subroutine or function which is in this module.
Related
Sundown a (formerly) popular Markdown editor includes an examples directory, and I want to play around with it on the command line, but I'm having difficulties.
I navigate to examples, I run gcc sundown.c -o sundown and it complains that I don't have markdown.h. So I dump the contents of the src directory and the html directory into the examples category, and run it.
I then get:
Undefined symbols for architecture x86_64:
"_bufgrow", referenced from:
_main in sundown-3bac08.o
"_bufnew", referenced from:
_main in sundown-3bac08.o
"_bufrelease", referenced from:
_main in sundown-3bac08.o
"_sd_markdown_free", referenced from:
_main in sundown-3bac08.o
"_sd_markdown_new", referenced from:
_main in sundown-3bac08.o
"_sd_markdown_render", referenced from:
_main in sundown-3bac08.o
"_sdhtml_renderer", referenced from:
_main in sundown-3bac08.o
What exactly am I doing wrong here? I feel like this should be relatively simple, I'm just at wits end trying to figure out what I'm doing wrong.
you tell gcc where to obtain #include files by adding the parameter:
'-Ipathtoincludes'
you tell gcc where to obtain the needed libraries by adding the parameters:
'-Lpathtoolibrary' and '-lshortlibraryname
note: the -l is lower case 'L'
The library path and library name parameters must be last in the gcc command line, as the linker looks at the linker parameters in the order listed on the command line
I need to retrieve vorbis and vorbisenc libraries to compile a C program. I tried to download vorbis lib sources in http://xiph.org/downloads/ but each time, there are problems for compiling this lib. Do you know where I can download these lib (.h and .so ) ?
I work on MacOSX.
Thanks
EDIT :
Finally, I succeed to install the library by downloading an older version. But now, I encounter another problem in compiling my program with this library :
ld: warning: ignoring file /usr/local/lib/libFLAC.dylib, missing required architecture x86_64 in file /usr/local/lib/libFLAC.dylib (2 slices)
Undefined symbols for architecture x86_64:
"_sf_close", referenced from:
_main in ccucQ4qH.o
"_sf_open", referenced from:
_main in ccucQ4qH.o
"_sf_readf_double", referenced from:
_read_n_samples in ccucQ4qH.o
"_sf_strerror", referenced from:
_main in ccucQ4qH.o
ld: symbol(s) not found for architecture x86_64
I'm having problems with apples examples for vDSP. I tried all of them but i need the convolution sample in the end.
I can't even get it through the linker:
Undefined symbols for architecture i386:
"_conv", referenced from:
_ConvTiming in main.o
ld: symbol(s) not found for architecture i386
Is the error message (no matter what architecture i build for or).
You need to include the Accelerate framework in the build.
I am trying to learn how to program in C, and I want to be able to import data into my C program from a .hdf file.
I am using a mid 2009 MacBook Pro with Mac OS X lion.
I think I am having problems, because I didn't know where on my system to put all the header files associated with hdd (remember, I'm a bit of a noob). So I just downloaded the hdf5-1.8.9-freebsd-shared folder from the hdd website, and manually dragged all the .h files from the /include subdirectory into the /usr/include directory onto my computer.
When I try to compile my .c program using the normal gcc terminal command, I get an error which is along the lines of (sorry about the formatting but I think the exact error doesn't matter too much anyway):
Undefined symbols for architecture x86_64:
"_H5check_version", referenced from:
_main in cc9FVO6S.o
"_H5Fcreate", referenced from:
_main in cc9FVO6S.o
"_H5Screate_simple", referenced from:
_main in cc9FVO6S.o
"_H5open", referenced from:
_main in cc9FVO6S.o
"_H5T_STD_I32LE_g", referenced from:
_main in cc9FVO6S.o
"_H5Dcreate2", referenced from:
_main in cc9FVO6S.o
"_H5T_NATIVE_INT_g", referenced from:
_main in cc9FVO6S.o
"_H5Dwrite", referenced from:
_main in cc9FVO6S.o
"_H5Dclose", referenced from:
_main in cc9FVO6S.o
"_H5Sclose", referenced from:
_main in cc9FVO6S.o
"_H5Fclose", referenced from:
_main in cc9FVO6S.o
"_H5Fopen", referenced from:
_main in cc9FVO6S.o
"_H5Dopen2", referenced from:
_main in cc9FVO6S.o
"_H5Dread", referenced from:
_main in cc9FVO6S.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Though the exact error varies depending on exactly what code I am trying to compile. This was generated when I tried to compile a sample program.
Does anybody have any experience with getting hdf5 to work in C in Mac OS X? I have found it all very confusing.
By the way, I normally use python, and frequently use h5py without trouble.
You have to tell your linker when you are using a library using -l<library-name> and -L<library-dir> for non-standard locations.
If you installed hdf5 in /usr/local/hdf5, you need something like:
gcc -o h5ex_d_rdwr h5ex_d_rdwr.c -I/usr/local/hdf5/include -L/usr/local/hdf5/lib -lhdf5
If you are using the High-Level API, also add -lhdf5_hl.
If you have pkg-config installed and it is aware of your hdf5 installation, you can let it do it for you:
gcc -o h5ex_d_rdwr h5ex_d_rdwr.c `pkg-config hdf5 --cflags --libs`
Update: After some more reading I see that this problem is totally general, you can't mix architectures in the same process, so 64 bit Java cannot dlopen() a 32 bit library like FMOD. Is there any possible workaround for this, keeping in mind I'm writing my own C interface to the FMOD library?
I need to make a 64-bit dylib on Max OS X because Java Native Access only likes 64-bit libraries on 64-bit machines. The problem is, my C source code dynamically includes FMOD which on Mac only provides 32-bit dylibs. When I try to compile without the -m32 option (since I must output a 64-bit dylib) I get the following error:
gcc -dynamiclib -std=c99 -pedantic -Wall -O3 -fPIC -pthread -o ../bin/libpenntotalrecall_fmod.dylib ../../src/libpenntotalrecall_fmod.c -lfmodex -L../../lib/osx/
ld: warning: in /usr/lib/libfmodex.dylib, missing required architecture x86_64 in file
Undefined symbols:
"_FMOD_System_CreateSound", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_Channel_GetPosition", referenced from:
_streamPosition in ccJnlwrd.o
"_FMOD_System_Create", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_System_PlaySound", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_Sound_Release", referenced from:
_stopPlayback in ccJnlwrd.o
"_FMOD_Channel_IsPlaying", referenced from:
_playbackInProgress in ccJnlwrd.o
"_FMOD_System_Update", referenced from:
_streamPosition in ccJnlwrd.o
_startPlayback in ccJnlwrd.o
"_FMOD_Channel_SetPaused", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_System_Release", referenced from:
_stopPlayback in ccJnlwrd.o
"_FMOD_System_Init", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_Channel_SetVolume", referenced from:
_startPlayback in ccJnlwrd.o
"_FMOD_System_Close", referenced from:
_stopPlayback in ccJnlwrd.o
"_FMOD_Channel_SetCallback", referenced from:
_startPlayback in ccJnlwrd.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [all] Error 1
Shouldn't it be possible to get a 64 bit dylib from my source code that dynamically includes 32 bit libraries?!
As you've noted, you can't mix architectures in the same process.
The workaround is then to have two processes. One of them is a 32 bit "helper" process that links to the 32-bit library and exposes its functions through some IPC mechanism, and the other is the 64-bit Java process linked to your own 64-bit library.
Your 64-bit library starts up the helper process, and provides a set of functions that it implements by passing requests to the helper process over the IPC mechanism and returning the results. The IPC can be as simple as a pair of anonymous pipes created with the pipe() system call.
64-bit binaries cannot link to 32-bit ones or vice-versa. If you can't get the library you want in 32-bit, your best solution is to create a 32-bit proxy program that your main program controls. This is how Safari does Flash in 10.6 — the Flash plugin runs in its own address space.
Just an FYI to anyone who stumbles across this, FMOD's development release contains a 64 bit dylib for Mac OS X. I'm using that now, and I'm sure it will be moved into the main line of the API soon.