I'm starting to learn c ++, so the problem can be completely stupid, I even feel it. It consists of the following. I put DevCpp, download libcurl.a, here's the source file, call it "main.c" mode "plain C".

#include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); } return 0; } 

When compiling from both DevCpp and compile.bat

 @echo off mingw32-gcc -I"D:\\_CPP_\\devpaks\\include" -c main.c -o "main.o" -DCURL_STATICLIB mingw32-g++ main.o -o "pr2.exe" -L"D:\\_CPP_\\Dev-Cpp\\lib" -lcurl -lws2_32 -lwinmm pause 

(there were both gcc, both g ++ and generally in all variants, c ++ code is also test) gives the following:

D:\\_CPP_\\Dev-Cpp\\lib/libcurl.a(content_encoding.o)(.text+0x5d): undefined reference to 'inflateEnd'
[ ... Π΅Ρ‰Π΅ 5 с Π΄Ρ€ΡƒΠ³ΠΈΠΌΠΈ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌΠΈ ... ]
collect2: ld returned 1 exit status
Для продолТСния Π½Π°ΠΆΠΌΠΈΡ‚Π΅ Π»ΡŽΠ±ΡƒΡŽ ΠΊΠ»Π°Π²ΠΈΡˆΡƒ . . .

Two nights of googling gave this result: linking is there, the PATH environment variable is in order (checked), the library and the headers from the site. Reloaded) There are no gaps in the paths. Hello world compiles fine, but any connected library (poco, boost, clSockets) crashes the program.

Has anyone come across this?

UPD: sorry, winXP SP2

    2 answers 2

    Judging by the fact that there is not enough inflateEnd , this means that you need to link more zlib

    PS: that is, it means that you still need to add -lz to the options

    • Thank you so much!) The only thing that worries me now, have I really ignored the list of dependencies in ALL libraries? = (Ok, next time I'll be more careful. You, by the way, opened the door for me) - Sh4dow
    • I am glad for you;) It is necessary to carefully read the error message: the linker clearly stated the reason why he cannot do his job. It only remained to find what this inflateEnd is and where it happens. - cy6erGn0m
    • And before that I was looking everywhere, but there were variables either from the library or system like htons. Also, the conflicts between minGW and MSVC ("undefined reference to 'getaddrbyname @ 5'", the dog mingw does not understand). Apparently, the path was correct, but I gave up early) - Sh4dow

    Try adding your libcurl.a to the project in Project Options -> Parameters.

    • One of the attempts was code :: blocks, and in it and in devcpp I added the library to both the list of library libraries on the full / relative path, and on the commands of the linker (-lcurl). Moreover, the error is not issued on main.c, but on the library itself. - Sh4dow