[英]How to include curl header or library in C compiler(mingw)(on WINDOWS)?
I want to include curl.h
to use the functions included there for my C program and I downloaded them.我想包含
curl.h
以将其中包含的函数用于我的 C 程序,我下载了它们。 By them I mean to say .h
, .c
, .a
files ie a whole library(curl library).我指的是
.h
、 .c
、 .a
文件,即整个库(curl 库)。 Following is the location to curl.h
:以下是
curl.h
的位置:
C:\CURL\include\curl
Following is the location to libcurl.a
:以下是
libcurl.a
的位置:
C:\CURL\lib
The problem is that I am not able to compile the program correctly as I am thrown error each time.问题是我无法正确编译程序,因为每次都会抛出错误。
I tried including path where curl/curl.h
resides:我尝试包括
curl/curl.h
所在的路径:
gcc -IC:/CURL/include test.c -o run -lcurl
Error I get:我得到的错误:
C:/Program Files (x86)/Embarcadero/Dev-Cpp/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl
collect2.exe: error: ld returned 1 exit status
Thinking opps, I should have given the path to libcurl.a
, I tried including path where curl/curl.h
resides and path where libcurl.a
resides(i don't know if it is corrent to use -I
twice):想想 opps,我应该给出
libcurl.a
的路径,我尝试包括curl/curl.h
所在的路径和libcurl.a
所在的路径(我不知道使用-I
两次是否正确):
gcc -IC:/CURL/include -IC:/CURL/lib -lcurl test.c -o run gcc -IC:/CURL/include -IC:/CURL/lib -lcurl test.c -o 运行
I was still wrong and Error I get:我仍然错了,我得到错误:
C:/Program Files (x86)/Embarcadero/Dev-Cpp/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl
collect2.exe: error: ld returned 1 exit status
I also tried replacing -lcurl
with -llibcurl
, -llibcurl.a
, curl.a
while keeping other syntax unchanged for the sake of satisfaction or something like touch and go of if this could be right or that could be right way.我还尝试将
-lcurl
替换为-llibcurl
、 -llibcurl.a
、 curl.a
,同时为了满意而保持其他语法不变,或者如果这可能是正确的或那可能是正确的方式,则保持其他语法不变。
Had I ever entered correct syntax for compiling?我曾经输入过正确的编译语法吗?
Where am I mistaken in compilation?我在哪里编译错误? Please help me in this.
请帮助我。 Suggest the correct and best way to compile and if possible with
makefile
.建议正确和最好的编译方法,如果可能的话使用
makefile
。
gcc -IC:/CURL/include test.c -o run -lcurl
gcc -IC:/CURL/include test.c -o 运行 -lcurl
If you want to add the path directory to the curl.h
, use -I
option, but if you want to also link your program, and do it with -lcurl
, then you need also to add the path to the library binaries with -Lc:/CURL/lib
option.如果您想将路径目录添加到
curl.h
,请使用-I
选项,但如果您还想链接您的程序,并使用-lcurl
执行此操作,那么您还需要使用-Lc:/CURL/lib
将路径添加到库二进制文件-Lc:/CURL/lib
选项。
gcc -IC:/CURL/include test.c -o run -LC:/CURL/lib -lcurl
This will, probably, work as expected.这可能会按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.