I am trying to use some functions defined in a header file provided to me but keep getting undefined reference error.
First time asking, tried really hard to comply with the format and google every topic i found.
I've been given LsApi.so and LsApi.h
LsApi.h:
...
// Linux porting
typedef int HWND, BOOL;
extern int LSDisconnect(short hConnect, HWND hWnd);
...
main.cpp:
#include "LsApi.h"
int main(int argc, char** argv) {
int retVal = 0;
HWND b = 0;
short devID;
retVal= LSDisconnect (devID,b);
return 0;
}
Tried with clang++ to see ld command
clang++ -O3 -v -m32 -g -Wall -I. -L/usr/lib -L/usr/local/lib/ -lLsApi main.cpp
(sorry i have ubuntu in spanish will try to translate errors)
...
...
/tmp/main-bfde60.o: in function `main':
/home/jere/LSAPI/main.cpp:11: undefined reference to `LSDisconnect(short, int)'
Lib is there
locate libLsApi.so
/usr/local/lib/libLsApi.so
ld --verbose shows me that ld can find library:
(didnt paste full ld command because its generated by clang so really large)
...
attempt to open /usr/local/lib//libLsApi.so succeeded
-lLsApi (/usr/local/lib//libLsApi.so)
...
nm shows me that the symbol is there:
nm /usr/local/lib//libLsApi.so | grep LSDisconnect
0004b751 T LSDisconnect
There seems to be no problem with the .so format:
file /usr/local/lib/libLsApi.so
/usr/local/lib/libLsApi.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, with debug_info, not stripped
libLsApi.so dependencies looks good
(i dont think thats important, given that the symbol is in the library according to nm)
ldd /usr/local/lib/libLsApi.so
linux-gate.so.1 (0xf7f0b000)
libpthread.so.0 => /lib32/libpthread.so.0 (0xf492b000)
libdl.so.2 => /lib32/libdl.so.2 (0xf4926000)
libz.so.1 => /usr/lib32/libz.so.1 (0xf4907000)
librt.so.1 => /lib32/librt.so.1 (0xf48fd000)
libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf4777000)
libm.so.6 => /lib32/libm.so.6 (0xf46ac000)
libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf468e000)
libc.so.6 => /lib32/libc.so.6 (0xf44b5000)
/lib/ld-linux.so.2 (0xf7f0d000)
Observations:
There is one thing that seems weird to me, I've been given: LsApi.h and LsApi.so, installed using provided shell script, but i had to change LsApi.so name to libLsApi.so for the linker to find it.
Tried using gcc because its and old library, and tried all the same things in Ubuntu Jaunty with same results.