Even the Static cURL Library Isn't Static


 
Thread Tools Search this Thread
Top Forums Programming Even the Static cURL Library Isn't Static
# 1  
Old 07-06-2011
Even the Static cURL Library Isn't Static

I'm writing a program which uses curl to be run on Linux PCs which will be used by a number of different users. I cannot make the users all install curl on their individual machines, so I have tried to link curl in statically, rather than using libcurl.so. I downloaded the source and created a libcurl.a static library. However, when I tried to link it in with my program, it showed a lot of disparate undefined references, in other words it had dependencies on other libraries. It would be hard to figure out all the things it's calling for and link in static versions of those libraries too. How do people use curl for programs that are to be distributed to users, most of whom don't have curl libraries on their PCs? How can I use curl in my program completely statically.

Thanks in advance for any enlightenment you can shed.

Brandon
.AOLWebSuite .AOLPicturesFullSizeLink { height: 1px; width: 1px; overflow: hidden; } .AOLWebSuite a {color:blue; text-decoration: underline; cursor: pointer} .AOLWebSuite a.hsSig {cursor: default}
# 2  
Old 07-06-2011
It's not all static because you said you didn't want that. As a result you have to link in libraries libcurl uses.

I remember your thread. Didn't you try -ldl like suggested? All the symbols you mentioned came from it.
# 3  
Old 07-07-2011
I did use -ldl. I presume that it links in libdl.a. But after that it still complained about numerous undefined references. A small fraction is:

Code:
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(strerror.o): In function `Curl_idn_strerror':
strerror.c: (.text+0x6e): undefined reference to `idna_strerror'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(timeval.o): In function `curlx_tvnow':
timeval.c: (.text+0x89): undefined reference to `clock_gettime'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(url.o): In function `fix_hostname':
url.c: (.text+0x10ee): undefined reference to `stringprep_check_version'
url.c: (.text+0x1113): undefined reference to `idna_to_ascii_lz'
url.c: (.text+0x111b): undefined reference to `stringprep_locale_charset'
url.c: (.text+0x1157): undefined reference to `idna_to_unicode_lzlz'
url.c: (.text+0x11b6): undefined reference to `tld_check_lz'
url.c: (.text+0x11cb): undefined reference to `idn_free'
url.c: (.text+0x11d5): undefined reference to `tld_strerror'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(url.o): In function `Curl_disconnect':
url.c: (.text+0x1bd4): undefined reference to `idn_free'
url.c: (.text+0x1be6): undefined reference to `idn_free'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(ssluse.o): In function `Curl_ossl_version':
ssluse.c: (.text+0xc): undefined reference to `SSLeay'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(ssluse.o): In function `Curl_ossl_data_pending':
ssluse.c: (.text+0x262): undefined reference to `SSL_pending'
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../libcurl.a(ssluse.o): In function `x509_name_oneline':
ssluse.c: (.text+0x3d6): undefined reference to `X509_NAME_print_ex'


Last edited by pludi; 07-07-2011 at 12:25 PM..
# 4  
Old 07-07-2011
Are you sure that you are following the steps for generating an archive...otherwise it wont complain about external references. Post the commands you are following to generate libcurl.a and make sure that all dependencies of curl have their static lib versions installed otherwise there will be errors.
# 5  
Old 07-07-2011
I have downloaded and untarred the curl source. I simply go to the lib sub-directory and enter "make." Everything works well, a libcurl.a is produced, and when I try to use it with g++ -static, I get these "undefined reference" errors.
# 6  
Old 07-07-2011
Quote:
Originally Posted by BrandonShw
I have downloaded and untarred the curl source. I simply go to the lib sub-directory and enter "make." Everything works well, a libcurl.a is produced, and when I try to use it with g++ -static, I get these "undefined reference" errors.
It has been a while but when I last compiled it there was some "curl-config --static-lib" thing i had to specify on the comand line...is there a readme or install file with the curl distro.
# 7  
Old 07-07-2011
Thanks. By the way, I was incorrect when I said that I went into the lib sub-directory. I used the make command at the top level.

---------- Post updated at 03:07 PM ---------- Previous update was at 03:07 PM ----------

Does anybody know of a switch to put on the libcurl make to build a truly self-sufficient (static) libcurl.a which has no dependencies?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use curl to send a static xml file using url encoding to a web page using pos

Hi I am try to use curl to send a static xml file using url encoding to a web page using post. This has to go through a particular port on our firewall as well. This is my first exposure to curl and am not having much success, so any help you can supply, or point me in the right direction would be... (1 Reply)
Discussion started by: Paul Walker
1 Replies

2. HP-UX

How to use chatr to change static library path in binary?

I have solved this but now cannot recall the syntax. I want to strip or change the hard wired library paths on binaries I download from a repository. I do not have root and just want a personal install, but would rather not build every tool. I even posted the solution here once for others, but... (2 Replies)
Discussion started by: DGPickett
2 Replies

3. UNIX for Dummies Questions & Answers

Shared static library

Hello Please what does mean shared static library and LD-Preload? Thank you (3 Replies)
Discussion started by: chercheur857
3 Replies

4. Programming

g++ fails to link to static library when compilation and link in single command

Hello All, I've encountered a strange behaviour from g++ that doesn't make sense to me. Maybe you can shed some light on it: I have a bunch of source files and want to compile them and link them with a static library liba.a located in /usr/local/lib64 into an executable Approach 1 works... (0 Replies)
Discussion started by: magelord
0 Replies

5. Programming

Static and Shared Library in Makefile

I am having a devil of a time with a very simple make file. The program needs two shared and one static library. If I link the shared libraries only like below the mysql test app works ... (1 Reply)
Discussion started by: jadsys
1 Replies

6. Linux

Could static library include static library?

I have some static library(libxxx.a libyyy.a). And I want to generate my library(libzzz.a), libzzz.a will use libxxx.a and libyyy.a I wan't my application only use libzzz.a, (means libzzz.a had include libxxx.a, libyyy.a), how can I do that? Thank you. example: I have zzz.c. I do ... (4 Replies)
Discussion started by: freemagic
4 Replies

7. Programming

Adding a Static Library (libtimer.a) to the Makefile

Hi, The following is my Makefile, I wanted to add a staic library named libtimer.a. I'm using the following Makefile. Please let me know how to add this static library: Makefile:- It produces "usbserial" executable. Thanks, S (1 Reply)
Discussion started by: suryaemlinux
1 Replies

8. IP Networking

I need HELP to Set up Coyote Linux router with 1 static IP & 64 internal static IP

hello, i need help on setting my coyote linux, i've working on this for last 5 days, can't get it to work. I've been posting this message to coyote forum, and other linux forum, but haven't get any answer yet. Hope someone here can help me...... please see my attached picture first. ... (0 Replies)
Discussion started by: dlwoaud
0 Replies

9. Shell Programming and Scripting

How to change a Makefile from building static library to shared library?

Hi: I have a library that it only offers Makefile for building static library. It built libxxx.a file. How do I in any way build a shared library? (either changin the Makefile or direct script or command to build shared library) Thanks. (1 Reply)
Discussion started by: cpthk
1 Replies

10. IP Networking

Static IP

Is it possible, and if so, how can I assign a static IP address to my RedHat 8.0 machine. I am using a Linksys router/switch with DHCP enabled. I have a small linux/windows2000 LAN at home. I want to assign a static IP so that I can setup port forwarding to my linux machine so that I can ssh into... (7 Replies)
Discussion started by: google
7 Replies
Login or Register to Ask a Question