Author Topic: Using static libs of libcurl  (Read 30820 times)

Offline Roog

  • Single posting newcomer
  • *
  • Posts: 4
Using static libs of libcurl
« on: October 24, 2009, 03:32:53 pm »
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:
Code
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:


Code
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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using static libs of libcurl
« Reply #1 on: October 24, 2009, 04:35:40 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Roog

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using static libs of libcurl
« Reply #2 on: October 24, 2009, 06:45:36 pm »
With libcurldll.a linked:

Code
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.

Offline Roog

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using static libs of libcurl
« Reply #3 on: October 26, 2009, 10:41:02 pm »
Anyone?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Using static libs of libcurl
« Reply #4 on: October 26, 2009, 10:44:20 pm »
Wild guess try adding the same defines
Code
-DCURL_STATICLIB 

Tim S.

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

« Last Edit: October 26, 2009, 10:46:01 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Using static libs of libcurl
« Reply #5 on: October 27, 2009, 06:46:44 am »
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Roog

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using static libs of libcurl
« Reply #6 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:

Quote
In the commandline the following code works well:
Code
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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Using static libs of libcurl
« Reply #7 on: October 27, 2009, 10:57:03 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.
« Last Edit: October 27, 2009, 12:35:43 pm by jens »

Offline maninthewind

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using static libs of libcurl
« Reply #8 on: December 09, 2009, 03:00:39 pm »
I also encounter this problem .
Did you solve it?

Offline maninthewind

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using static libs of libcurl
« Reply #9 on: December 10, 2009, 06:09:00 am »
 :)
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

  • Guest
Re: Using static libs of libcurl
« Reply #10 on: May 17, 2010, 04:42:45 pm »
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:
Code
-DCURL_STATICLIB 
-I ..\..\include
-L ..\..\lib\
-lcurl
-lws2_32
-lwinmm

Good luck!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Using static libs of libcurl
« Reply #11 on: May 22, 2010, 08:39:09 pm »
Code
-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!]