cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: R: Re: cannot link libcurl statically

From: Oscar Koeroo <okoeroo_at_nikhef.nl>
Date: Tue, 11 Sep 2012 14:31:11 +0200

On 08-09-12 23:04, crillion_at_tiscali.it wrote:
> I have tried that,
>
> so now my test programs have this source code:
>
>
>
> extern "C" {
>
> #include <curl/curl.h>
> #include <curl/easy.h>
>
> }
>
> int main
> (int argc, char* argv[])
> {
> curl_global_init(CURL_GLOBAL_ALL);
> }
>
>
> but
> even so, I get the same error messages:
> - the one linked to the default-
> compiled libcurl compiles but gives the error when launched for missing
> dll;
> - the one linked to the static-compiled libcurl doesn't compile
> and gives the compile-time error for the missing implementations of
> some ldap routines:
>
> Z:
> \data\users\marco_pappalepore\data\projects\repository1\tests\libcurl\test_libcurl_client_static>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'
>
>
> So the problem persists.
>
>
> what else can be done ?
>
> Many thanks,
>
> Marco

Do you need the LDAP routines? You could also try to minimize the amount of
features available in libcurl to make it more easily build statically.

I've recently statically build libcurl with success and stripped the feature
with the configure flags down to HTTP(S), SSL and proxy support. All the
rest was overhead to me with complicated the static building a lot.

        Oscar

>
>
> ----
> Messaggio originale----
> Da: driansharp_at_gmail.com
> Data: 08/09/2012 2.07
>
> A: "crillion_at_tiscali.it"<crillion_at_tiscali.it>, "libcurl development"
> <curl-library_at_cool.haxx.se>
> Ogg: Re: cannot link libcurl statically
>
> Hi
>
>
> You need to use
> Extern "C" {.....}
>
> Around all header includes that
> reference any library that was written in c to properly link against a
> c++ program
>
> Best wishes
> Ian Sharp PhD
>
> On Sep 7, 2012, at 7:33 AM,
> "crillion_at_tiscali.it" <crillion_at_tiscali.it> wrote:
>
>> 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
>
>
>
>
>
> 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
>

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