Jump to content
  • Advertisement
Sign in to follow this  
FGFS

statically link curl on Linux

This topic is 1339 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

is it possible to statically link curl on Ubuntu? It seems to have lots of dependencies. Simply adding:

-DCURL_STATICLIB

didn't change anything. It compiles but ldd still points to libcurl.

Thanks

 

Share this post


Link to post
Share on other sites
Advertisement

You probably either need to use -Wl,static or explicitly link the .a file on the linker command line.  Oh, and find and statically link all its dependencies.  And check all the licenses to see if it's allowed.

 

Ubuntu generally doesn't ship static libraries so you'll need to build everything yourself from source.

Edited by Bregma

Share this post


Link to post
Share on other sites

Thanks it compiled using -DCURL_STATICLIB and giving the .a file in the miscellaneous Eclipse options. Ldd doesn't show curl anymore but now I get the runtime error:

undefined symbol: GSS_C_NT_HOSTBASED_SERVICE

This comes from Kerberos? Actually I only need http, could I avoid the above without recompiling libs?

Thanks again for help.

Edited by FGFS

Share this post


Link to post
Share on other sites

Thanks it compiled using -DCURL_STATICLIB and giving the .a file in the miscellaneous Eclipse options. Ldd doesn't show curl anymore but now I get the runtime error:

undefined symbol: GSS_C_NT_HOSTBASED_SERVICE

This comes from Kerberos? Actually I only need http, could I avoid the above without recompiling libs?

Thanks again for help.

 

As Bregma said, you also need to link (statically or otherwise) to all of curl's dependencies. As a shared library it implicitly did that for you, but as a static library you have to do it manually. Try to ldd libcurl.so itself to find out what it depends on.

Share this post


Link to post
Share on other sites

Yes thanks I've added those from: curl-config --static-libs
and now get:

 

Finished building: ../main.cpp
 
Building target: lin.xpl
Invoking: GCC C++ Linker
g++ -Wl,-rpath=.,-Bdynamic,-lopenal,-lidn,-static,-fPIC -L/usr/lib/x86_64-linux-gnu/ -shared -o "lin.xpl"  ./BitmapSupport.o ./main.o  /usr/lib/x86_64-linux-gnu/libcurl.a -lrtmp -lgcrypt -lgnutls -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -llber -lldap -lz -lcurl -lSDL -lGL
/usr/bin/ld: /usr/lib/x86_64-linux-gnu//libgcrypt.a(libgcrypt_la-visibility.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/lib/x86_64-linux-gnu//libgcrypt.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [lin.xpl] Error 1

 

I use Eclipse so maybe I could use the main.o and manually link with gcc? Well anyway what to change above? It works if I only link static libcurl but I guess users are not

happy to install manually the other krypto etc. libs. libcurl is different on Fedora hence I try to link all that stuff statically.

Many thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!