cURL / Mailing Lists / curl-library / Single Mail

curl-library

cannot link libcurl statically

From: <crillion_at_tiscali.it>
Date: Fri, 7 Sep 2012 15:33:09 +0100 (GMT+01:00)

Hi,

    I'm trying to use libcurl on windows vista (32) with mingw,
linking it statically to C++ programs. The problem I get is that I
cannot link my client program, or when I'm able to link it, it doesn't
work anyway(it requires the dll). I've already read many similar
requests for static linkage problems with curl, and I think have
applied the related suggestions, but the problem persists.

I have
synthesized my problem in 2 cases, one with curl-7.27.0 compiled in the
default way, and the other with curl-7.27.0 compiled with static
options. In each of the cases I have a .bat script compiling the
program and a simple C++ program using curl.

What I really need is to
be able to link curl statically, so I ask if you can explain me where
I'm doing wrong and how can actually get my program compiling.

Here
are my 2 cases:

========================================

------------------------------
case 1: default curl compile

------------------------------

- get curl-7.27.0.
- extract it into a
folder, such as
(...)\data\projects\external\libcurl\curl-7.27.0-
default
- open mingw shell
- go the folder
(...)
\data\projects\external\libcurl\curl-7.27.0-default
- give the command
.
/configure
(wait till the command ends)
- give the command
make
(wait
till the command ends)
- create then a c++ program, such this file:

(...)
\data\projects\repository1\tests\libcurl\test_libcurl_client_default\test_libcurl_client_default.
cpp

here's the c++ program source code:

#include <curl/curl.h>

#include <curl/easy.h>

int main(int argc, char* argv[])
{
        
curl_global_init(CURL_GLOBAL_ALL);
}

- create the .bat file to compile
the program:
(...)
\data\projects\repository1\tests\libcurl\test_libcurl_client_default\compile_test_libcurl_client_default_gpp.
bat

here's the .bat source code:

g++ test_libcurl_client_default.cpp -
o test_libcurl_client_default_gpp.exe -I../../../..
/external/libcurl/curl-7.27.0-default/include -L../../../..
/external/libcurl/curl-7.27.0-default/lib/.libs -lcurl -L../../../..
/external/libcurl/curl-7.27.0-default/lib/.deps -lwsock32

- now
close mingw shell and start using normal windows command prompt
- from
the windows command prompt, run the .bat to build the program. the
build process works and I get the output:

Z:
\data\users\marco_pappalepore\data\projects\repository1\tests\libcurl\test_libcurl_client_default>g++
test_libcurl_client_default.cpp
 -o test_libcurl_client_default_gpp.exe
-I../../../../external/libcurl/curl-7.27.0-default/include -L../../../..
/external/libcurl/curl-
7.27.0-default/lib/.libs -lcurl -L../../../..
/external/libcurl/curl-7.27.0-default/lib/.deps -lwsock32

- now the
generated program, test_libcurl_client_default_gpp.exe exists and can
be launched via the command
test_libcurl_client_default_gpp

- this
gives the error:

"test_libcurl_client_default_gpp.exe - unable to
locate component"
"This application has failed to start because libcurl-
4.dll was not found. Re-installing the application may fix this
problem."

- I don't want to use dlls, I need to produce a single file
executable, so anyway this option cannot be done.

========================================
------------------------------

case 2: static curl compile
------------------------------

- get curl-
7.27.0.
- extract it into a folder, such as
(...)
\data\projects\external\libcurl\curl-7.27.0-static
- open mingw shell
-
go the folder
(...)\data\projects\external\libcurl\curl-7.27.0-static
-
give the command
./configure --enable-static --disable-shared --with-
ssl
(wait till the command ends)
- give the command
make LDFLAGS=-all-
static
(wait till the command ends)
- create then a c++ program, such
this file:
(...)
\data\projects\repository1\tests\libcurl\test_libcurl_client_static\test_libcurl_client_static.
cpp

here's the c++ program source code:

#include <curl/curl.h>

#include <curl/easy.h>

int main(int argc, char* argv[])
{
        
curl_global_init(CURL_GLOBAL_ALL);
}

- create the .bat file to compile
the program:
(...)
\data\projects\repository1\tests\libcurl\test_libcurl_client_static\compile_test_libcurl_client_static_gpp.
bat

here's the .bat source code:

g++ test_libcurl_client_static.cpp -
DCURL_STATICLIB -o test_libcurl_client_static_gpp.exe -I../../../..
/external/libcurl/curl-7.27.0-static/include -L../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs -lcurl -L../../../..
/external/libcurl/curl-7.27.0-static/lib/.deps -lwsock32

- now close
mingw shell and start using normal windows command prompt
- from the
windows command prompt, run the .bat to build the program. Now I get
the following output with error messages:

g++
test_libcurl_client_static.cpp -DCURL_STATICLIB -o
test_libcurl_client_static_gpp.exe -I../../../../external/libcurl/curl-
7.27.0-static/include -L../../../../external/libcurl/curl-7.27.0-
static/lib/.libs -lcurl -L../../../../external/libcurl/curl-7.27.0-
static/lib/.deps -lwsock32

../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x221):
undefined reference to `_i
mp__ldap_err2stringA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x262): undefined reference to `_i

mp__ldap_msgfree'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x28e): undefined
reference to `_i
mp__ldap_unbind_s'
../../../../external/libcurl/curl-
7.27.0-static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.
text+0x636): undefined reference to `_i
mp__ldap_set_optionA'
../../..
/../external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x659): undefined reference to `_i

mp__ldap_sslinitA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x6b9): undefined
reference to `_i
mp__ldap_simple_bind_sA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x70a): undefined reference to `_i

mp__ldap_search_sA'
../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x727):
undefined reference to `_i
mp__ldap_err2stringA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x7ae): undefined reference to `_i

mp__ldap_err2stringA'
../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x80d):
undefined reference to `_i
mp__ldap_set_optionA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x828): undefined reference to `_i

mp__ldap_initA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x85c): undefined
reference to `_i
mp__ldap_first_entry'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x896): undefined reference to `_i

mp__ldap_get_dnA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0x92b): undefined
reference to `_i
mp__ldap_first_attributeA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0x952): undefined reference to `_i

mp__ldap_get_values_lenA'
../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xb20):
undefined reference to `_i
mp__ldap_value_free_len'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0xb6d): undefined reference to `_i

mp__ldap_memfreeA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xb87): undefined
reference to `_i
mp__ldap_next_attributeA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0xb9e): undefined reference to `_i

mp__ldap_memfreeA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xbb6): undefined
reference to `_i
mp__ber_free'
../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xbc9):
undefined reference to `_i
mp__ldap_next_entry'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0xbee): undefined reference to `_i

mp__ldap_value_free_len'
../../../../external/libcurl/curl-7.27.0-
static/lib/.libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xbfa):
undefined reference to `_i
mp__ldap_memfreeA'
../../../..
/external/libcurl/curl-7.27.0-static/lib/.libs/libcurl.a(libcurl_la-
ldap.o):ldap.c:(.text+0xc06): undefined reference to `_i

mp__ldap_memfreeA'
../../../../external/libcurl/curl-7.27.0-static/lib/.
libs/libcurl.a(libcurl_la-ldap.o):ldap.c:(.text+0xc22): undefined
reference to `_i
mp__ber_free'
collect2: ld returned 1 exit status

-
It seems that the compiler is searching some "ldap" library that I
don't think I have on windows vista/mingw. I had already been able to
reduce some of these errors by linking also wsock32 with the option -
lwsock32;
anyway it seems that this ldap library is not present on my
system.

So:

what other steps am I supposed to do in order to make
the build process work, and the program run without the need of any dll
?

Many thanks,

            Marco

Invita i tuoi amici e Tiscali ti premia! Il consiglio di un amico vale più di uno spot in TV. Per ogni nuovo abbonato 30 € di premio per te e per lui! Un amico al mese e parli e navighi sempre gratis: http://freelosophy.tiscali.it/

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-07