I know there are many topics about this but none of them helped me to solve my problem. All I want is to make a simple C++ program that uses cURL with static libcurl (without DLL files) on Code::Blocks - Windows 8. I've spent around 20 hours trying to do this but all I found is unuseful stuff and stuff I don't understand.
After downloading curl-7.39.0.zip from http://curl.haxx.se/download.html and extracting it to my Code::Block directory, I ran Developer Command Prompt for VS2013 as Administrator and entered the following:
cd C:\Program Files (x86)\CodeBlocks\curl-7.39.0\winbuild
nmake /f Makefile.vc mode=static vc=12 debug=no
The output of the second command was: http://pastebin.com/bwPqxp9V
Then I made a new empty Code::Blocks project with Main.cpp:
#include <curl/curl.h>
int main() { curl_global_cleanup(); }
In Code::Blocks, I navigated to Project > Build Options
In Compiler Settings > Defines, I added CURL_STATICLIB
In Linker Settings > Link Libraries, I added the path of the .lib file generated (which exists):
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib
In Linker Settings > Other Link Options, I added -static
In Search Directories > Compiler, I added:
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\include
I may have edited some other stuff, but nothing important.
When I build using GNU GCC Compiler with the following command:
mingw32-g++.exe -o Debug\MyTestProgram.exe Debug\Main.o -static "..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib"
I get 80 warnings similar to:
.drectve `/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
And more than 50 errors. What I did wrong and how can I fix it?
Feel free to ask me for more details if needed.
Error log:
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\easy.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\easy.obj):(.text$mn+0x44)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\easy.obj):(.text$mn+0x64)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x13b)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x151)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x10d)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x295)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x2ac)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x17b)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\multi.obj):(.text$mn+0x2ea)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x80)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x41d)||undefined reference to `_imp__strtoll'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x58f)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x754)||undefined reference to `_imp__strtoll'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x45)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\cookie.obj):(.text$mn+0x57)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\curl_sspi.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\curl_sspi.obj):(.text$mn+0xca)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\curl_sspi.obj):(.text$mn+0xfc)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x5a)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x91)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x12e)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x198)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x1ae)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\asyn-thread.obj):(.text$mn+0xaa)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x88)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x178)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x42)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x7b)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\hostip.obj):(.text$mn+0x8e)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x12c)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x7)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0xd5)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x115)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x4)||undefined reference to `__security_cookie'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0xa4)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x1c6)||undefined reference to `@__security_check_cookie@4'|
..\..\..\..\Program Files (x86)\CodeBlocks\curl-7.39.0\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib\libcurl_a.lib(..\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl-obj-lib\url.obj):(.text$mn+0x216)||undefined reference to `@__security_check_cookie@4'|
||More errors follow but not being shown.|
Intro:
To build libcurl with gcc on windows, you need a command line tool. You may use Git-Bash or MSYS. Your choice.
Getting Started:
Start the MSYS installation. Choose whatever folder you like for the installation. When the command-line window pops up, answer as follows:
PRE-SETUP:
Now you have a command-line tool "make" installed and is compatible with your gcc/g++/mingw.
BEFORE we run the commands, there's a few things you need to know:
If using 32-bit gcc/g++ then change to:
--build=i686-pc-mingw32
.If using 64-bit gcc/g++ then change to:
--build=x86_64-w64-mingw32
.If using SSL, change
--without-ssl
to--with-ssl
and add-DOPENSSL_PATH=Path_To_Open_SSL_Here
.If you need to specify a special path to your ZLIB then add
-DZLIB_PATH=Path_To_ZLib_Here
.If you want to build STATIC then use
--disable-shared
otherwise don't use it OR use--enable-shared
.Configuration:
Open MSYS.bat and run the following commands (modify as needed and described above):
It should start doing a bunch of "checks". It will take a while so go get a coffee or something. If all is well and the configuration is complete, and you have everything setup correctly, then you should see the following:
Building & Installing:
Finally, run the following commands:
It should now start building and it will install to (Wherever your MSYS installation is -- Mine is
C:/Msys
):Those locations should have all the files necessary for you to use libcurl with gcc/g++/mingw.
If all went well, it will look like:
OPTIONAL: