简体   繁体   中英

libcurl curl/curl.h No such file or Directory Win xp 32 MinGW

I have been searching for a couple of hours and found several threads with the same problem and tried all their suggestions.

My curl.h is in C:\\MinGW\\msys\\1.0\\curl-7.29.0\\include\\curl and I've included it at compile time but for some reason gcc claims it can't find it:

gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local/ -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/curl -IC:/MinGW/msys/1.0/OpenSSL-Win32/ -lcurl -lws2_32

and the result:

curl.c:4:32: fatal error: curl/curl.h: No such file or directory

UPDATE: (With the suggestion from H2CO3)

$ gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/ -IC:/MinGW/msys/1.0/OpenSSL-Win32/include/ -lws2_32

C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xa8): undefined reference to `_imp__curl_global_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xe6): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x124): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x162): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x169): undefined reference to `_imp__curl_easy_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x183): undefined reference to `_imp__curl_slist_append'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x1b8): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x211): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x237): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x245): undefined reference to `_imp__curl_easy_perform'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x25e): undefined reference to `_imp__curl_easy_strerror'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x288): undefined reference to `_imp__curl_easy_cleanup'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x296): undefined reference to `_imp__curl_formfree'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x2a4): undefined reference to `_imp__curl_slist_free_all'

collect2: ld returned 1 exit status

If I try to compile with -lcurl it says ..... ld.exe: cannot find -lcurl is this because it can't find the dll?

You're including <curl/curl.h> , and not <curl.h> . So you have to tell the compiler to look for header files in the include directory, and not in include/curl :

gcc -IC:\MinGW\msys\1.0\curl-7.29.0\include etc. etc.

This might be beyond the scope of what you're doing, but, I found it best to install a version of cURL(libcurl) into the MinGW/MSYS environment. After installed, any program can be compiled to use it with the typical <curl/curl.h> and -lcurl conventions since it's installed where GCC would expect it. I documented my process here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM