Banging my head against a wall with making a quick proof of concept app which links to a third party .so file.
I've produces a simple C file which calls a simple function in the .so file, it includes the header file also supplied by the vendor. Linking produces the following errors:
/usr/local/lib/xxx.so: undefined reference to `sprintf_s'
/usr/local/lib/xxx.so: undefined reference to `sendWCmdThread'
/usr/local/lib/xxx.so: undefined reference to `pthread_create'
/usr/local/lib/xxx.so: undefined reference to `pthread_cancel'
I can handle the pthread issues (-pthread option) but I'm at a loss for the other two errors. Expecially as Google provides zero results for 'sendWCmdThread'
Anyone help?
Related
I have some core libraries compiled in icc and I am using those libraries to build my code with the help of gcc.
I have included the -lm in linking command but I am still getting he following undefined references:
undefined reference to __libm_sse2_sin
undefined reference to __libm_sse2_sincos
undefined reference to __libm_sse2_pow
Does anyone know how to resolve this? According to my investigation this is happening due to use of different compilers but using icc instead of gcc is not an option for me.
Is there any extra library I need to add which have definition for these undefined references?
I'm compiling a CPython Extension for an in-house library, and I'm pretty sure one of the functions that I'm using from the library is cursed.
When I run ld on the CPython Extension .so, it prints
./pyextension.so: undefined reference to `le_sig_cursed'
I don't believe it's an issue with the ordering of -l flags or it not finding the shared lib somehow, as the shared library contains hundreds of functions and they all work fine except this one.
Running nm --extern-only | grep le_sig_cursed on the shared lib shows that it does indeed exist.
0002ff70 T le_sig_cursed
Running that on the extension shows undefined (as expected).
U le_sig_cursed
Its prototype in the shared library's header looks like this
void le_sig_cursed(void);
There are other functions in the same header file with the exact same signature yet they link fine.
I'm using --no-undefined, and it doesn't complain at link time. Only when I run it or pass the extension into ld does it fail to resolve this one function.
I could understand if the library failed to load and none of the functions worked, but this one doesn't seem to have anything special about it yet it's the only one that fails. How do I diagnose this?
I want to use libpfm4 library for Perf_Event
but compiling program which have library function
throws following error.
/tmp/ccYD603t.o: In function `main':
encod.c:(.text+0x44): undefined reference to `pfm_initialize'
encod.c:(.text+0x57): undefined reference to `pfm_strerror'
encod.c:(.text+0x97): undefined reference to `pfm_get_perf_event_encoding'
encod.c:(.text+0xaa): undefined reference to `pfm_strerror'
collect2: ld returned 1 exit status
please can any one tell me how configure library in system to resolve this error.
As noted in the comments, you're looking at a linker error. Because this is a common error we have a reference question for this:
What is an undefined reference/unresolved external symbol error and how do I fix it?
To tell you more about exactly what you're doing wrong we'll need to see how you're compiling. Briefly, you're likely #includeing library headers but not linking the library. The compiler is telling the linker that the compiled code will need entities declared in the library headers but then the linker chokes because it doesn't know the definitions of those entities.
I've been transitioning to SDL 2 from 1.2 and I seem to have finally fixed all incompatibilities within my code. However, I am still getting some compile errors that appear to be about linking, but I have tried everything I know of to fix the linker directories and don't know what to do now.
Since warnings, the compile directory, the program name, and repeats of the same compiler output line don't matter in this situation, I've omitted warnings, changed the compile directory to "C:\", changed the program name to "program", and removed duplicated compiler output lines.
C:\program.program.cpp|| undefined reference to `SDL_DestroyWindow'|
C:\program.o:program.cpp|| undefined reference to `SDL_DestroyRenderer'|
C:\program.o:program.cpp|| undefined reference to `SDL_DestroyTexture'|
C:\program.o:program.cpp|| undefined reference to `SDL_CreateWindow'|
C:\program.o:program.cpp|| undefined reference to `SDL_CreateRenderer'|
C:\program.o:program.cpp|| undefined reference to `SDL_CreateTexture'|
C:\program.o:program.cpp|| undefined reference to `SDL_LockTexture'|
C:\program.o:program.cpp|| undefined reference to `SDL_UnlockTexture'|
C:\program.o:program.cpp|| undefined reference to `SDL_GetMouseFocus'|
I'd think that if it were a problem with including the library then many of the other SDL functions would freak out, but the audio functions, LoadBMP, and LoadWAV seem to be fine.
Is it possible that I am still linking the old SDL 1.2 libraries?
It turns out that I was actually linking the x64 libraries when I was supposed to be linking the i686 libraries. I'm not sure why I can't use the 64-bit ones, but apparently MinGW likes for them to be 32-bit.
I'm writing a program dealing with threads that I've almost got working completely. Unfortunately, I'm hitting an error (repeated 4 times) who's syntax I'm not familiar with. Here's a quick snip-it of my compile commands, and the errors that follow:
gcc -o threads threads.cpp -pthread<br>
/tmp/ccy8maS0.o: In function `tenPercentA()':
threads.cpp:(.text+0xde): undefined reference to `ceil'
/tmp/ccy8maS0.o: In function `tenPercentB()':
threads.cpp:(.text+0x1c6): undefined reference to `ceil'
/tmp/ccy8maS0.o: In function `fiftPercentC()':
threads.cpp:(.text+0x2ae): undefined reference to `ceil'
/tmp/ccy8maS0.o: In function `fiftPercentD()':
threads.cpp:(.text+0x396): undefined reference to `ceil'
/tmp/ccy8maS0.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I've already included the math.h library in my program, and I'm using the correct syntax for the call:
ceil(tempA);
Where tempA is a double holding the value I need to be rounded up.
Any suggestions? I've tried Google'ing these errors but, like most errors, it's hard to find specific examples with the same pattern as yours.
EDIT: I've solved all of the ceil related errors (using -lm on the command line) however the last error still remains, and I have no idea what it means, or how to fix it.
Referring the undefined reference to ceil():
You seem to be missing to link against libm.
Adding the option -lm to your call to gcc should solve this problem.
#includeing math.h is for the compiler to get to know ceil()'s defintion. The linker then later needs to know where ceil()'s implementation actually resides, namely in libm.