Hi
I try to link curl statically on Ubuntu/Eclipse/GCC:
Invoking: GCC C++ Linker
g++ -Bstatic -l:libcurl-gnutls.a -l:libcurl.a -L/usr/lib/x86_64-linux-gnu/ -shared -o "lin.xpl" ./BitmapSupport.o ./main.o -lopenal -lSDL -lGL
Finished building target: lin.xpl
and get the runtime error:
undefined symbol: curl_easy_setopt
What am I missing?
Many thanks in advance and regards
undefined symbol: curl_easy_setopt
I've changed the link order on commandline and now get:
undefined symbol: GSS_C_NT_HOSTBASED_SERVICE
Thanks
When linking, object files must come before their dependencies (because the linker resolves symbols from left to right on the command-line). Hence the correct order is your object files followed by libcurl followed by gnutls (probably) because your code needs symbols from libcurl which itself needs symbols from gnutls.
Yes thanks, I found that out just today. So the hostbased error means that static curl was not correctly compiled? I only need libcurl-gnutls.a. With all those dependencies, I don't think I would go through the hassle of recompiling curl and rather tell users to use dynamic libcurl-gnutls which seems to be a problem for Fedora users. Well then I add "Ubuntu compatible" to the description.
It's highly likely you're going to need a whackload of additional libraries linked in statically.
For example, libcurl-gnutls will require libgnutls to also be lined in, which in turn requires libpgp-error, and so on. It's turtles all the way down.
Also, statically linking security libraries used to be considered a severe security hole. You'll need to rebuild most of those libraries yourself from source to statically link them because on Ubuntu, at least, the static versions are not available.