I'm making a program that needs to be linked to a third party SDK which comes in the form of header files and precompiled shared libraries.
The program itself is simple, it just calls one function from the library:
#include <dhnetsdk.h>
int main() {
CLIENT_Init(nullptr, 0);
}
Then I compile it with
g++ -std=c++17 -O3 -ldhnetsdk -lavnetsdk -ldhconfigsdk -lInfra -lNetFramework -lStream -lStreamSvr trigger/src/main.cpp -Lsdk/bin -Isdk/include
sdk/bin contains the .so files and sdk/include contains the dhnetsdk.h
file where CLIENT_Init
is declared as extern "C" int CLIENT_Init(void(*)(long long, char*, long), long);
I have checked with nm
and sdk/bin/libdhnetsdk.so indeed exports the CLIENT_Init
symbol, but for some reason the linker is not able to find it and fails with:
/usr/bin/ld: /tmp/ccovgfxa.o: in function `main':
main.cpp:(.text.startup+0x9): undefined reference to `CLIENT_Init'
collect2: error: ld returned 1 exit status
What am I doing wrong here?