News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Using static libs of libcurl

Started by Roog, October 24, 2009, 03:32:53 PM

Previous topic - Next topic

Roog

Hi,

I'm using C::B for my project in combination with MinGW. I've installed MinGW in C:\MinGW and everything is working well, untill I wanted to use libcurl for my project. I've compiled the code well, and everything is working from the command line.

In the commandline the following code works well:

gcc -o simple simple.c -DCURL_STATICLIB -I ..\..\include -L ..\..\lib\ -lcurl -lws2_32 -lwinmm


My libcurl map is in: C:\MinGW\libcurl

But in C::B, when I add the libcurl\includes to Search Directories compiler and libcurl\lib too the Search D. Linker, and libcurl.a, libcurldll.a, libws2_32.a and libwinmm.a to the linker itself I still have compiling errors:

zlib1.dll not found when I add libcurldll.a to the compiler and the following when I remove libcurlddl.a from the linker settings:



Compiling: C:\MinGW\src\tb\simple.c
Linking console executable: C:\MinGW\src\tb\simple.exe
C:\MinGW\src\tb\simple.o:simple.c:(.text+0x2b): undefined reference to `_imp__curl_easy_init'
C:\MinGW\src\tb\simple.o:simple.c:(.text+0x51): undefined reference to `_imp__curl_easy_setopt'
C:\MinGW\src\tb\simple.o:simple.c:(.text+0x5e): undefined reference to `_imp__curl_easy_perform'
C:\MinGW\src\tb\simple.o:simple.c:(.text+0x6e): undefined reference to `_imp__curl_easy_cleanup'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings






How am I supposed to fix this?

MortenMacFly

Quote from: Roog on October 24, 2009, 03:32:53 PM
How am I supposed to fix this?
Enable full compiler logging (see my sig) and post again.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Roog

With libcurldll.a linked:


mingw32-gcc.exe   -IC:\MinGW\include -IC:\MinGW\libcurl\include  -c C:\MinGW\src\tb\simple.c -o C:\MinGW\src\tb\simple.o
mingw32-g++.exe -LC:\MinGW\lib -LC:\MinGW\libcurl\lib  -o C:\MinGW\src\tb\simple.exe C:\MinGW\src\tb\simple.o   C:\MinGW\libcurl\lib\libcurl.a C:\MinGW\lib\libws2_32.a C:\MinGW\lib\libwinmm.a C:\MinGW\lib\libcurldll.a
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings

Checking for existence: C:\MinGW\src\tb\simple.exe
Executing: C:\Program Files\CodeBlocks/cb_console_runner.exe "C:\MinGW\src\tb\simple.exe" (in C:\MinGW\src\tb)
Process terminated with status -1073741510 (0 minutes, 8 seconds)


Without libcurldll.a linked remains the same.

Roog


stahta01

#4
Wild guess try adding the same defines

-DCURL_STATICLIB


Tim S.

PS: This is a topic for a beginner programing site.

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

MortenMacFly

Quote from: stahta01 on October 26, 2009, 10:44:20 PM
PS: This is a topic for a beginner programing site.
I'm afraid this is indeed not the right forum. We do not discuss CURL compiling issues here, but C::B issues. Try in a CURL related forum. Another hint I can give: Try to find a simple project that uses CURL and see what compiler/linker parameters they use and adopt yur project accordingly. It's probably also an issue with the CURL libs you have - they may not be compatible or built in a wrong way... who knows? We don't. "CURL guys" might...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Roog

Well actually it's a C::B problem, since I do get it to work from the command line:

Quote
In the commandline the following code works well:

gcc -o simple simple.c -DCURL_STATICLIB -I ..\..\include -L ..\..\lib\ -lcurl -lws2_32 -lwinmm


But how am I supposed to add -DCURL_STATICLIB to C::B?

Jenna

#7
Quote from: Roog on October 27, 2009, 10:47:16 AM
Well actually it's a C::B problem, since I do get it to work from the command line:
[...]
But how am I supposed to add -DCURL_STATICLIB to C::B?

You see it's not a C::B, but a configuration problem.
And configuration problems are in fact user problems.

Jus add CURL_STATICLIB to the defines in your projects build options.

maninthewind

I also encounter this problem .
Did you solve it?

maninthewind

 :)
hi,sorry for my poor english.
I found the right version   "libcurl-7.16.4-win32-ssl"  from http://curl.cs.pu.edu.tw/download
This lib also needs libs : libeay32.dll,libssh2.dll,libssl32.dll
Remember that add -CURL_STATICLIB to "other options" .
Now my test runs well.

smallpawn

I know this is an old thread, but seeing that there are at list 2 people who didn't get a solution, I give my 2 cents:

- Go to "Project" -> "Build options..."
- Under "Compiler settings" select the "Other options" tab
- Add your options there as you would do in the command line, in your case it would be like this:

-DCURL_STATICLIB
-I ..\..\include
-L ..\..\lib\
-lcurl
-lws2_32
-lwinmm


Good luck!

oBFusCATed

Quote from: smallpawn on May 17, 2010, 04:42:45 PM

-DCURL_STATICLIB
-I ..\..\include
-L ..\..\lib\
-lcurl
-lws2_32
-lwinmm

This suggestion is wrong/incorrect, because:
1. You set both compiler and linker options only in the compiler part of the build options
2. There is GUI for setting

Below I've where/how you should set the compiler/linker options in C::B's GUI (first open the dialog Project -> Build options):
Compiler options:
"-DCURL_STATICLIB" -> add "CURL_STATICLIB" to Compiler settings -> Defines
"-I ..\..\include  " -> add "..\..\include " in Search Directories -> Compiler
Linker options:
"-L ..\..\lib\" -> add "..\..\lib" in Search Directories -> Linker
"-lcurl", "-lws2_32", "-lwinmm" -> add "curl", "ws2_32", "winmm" in Linker settings -> Link libraries


(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]