每当我在程序中 #include 时,我都会收到链接器错误。我已经从 haxx.se 下载了 libcurl,编译了 libcurl.dll,并在编译时将 -Icurl 添加到了我的 GCC 选项中(以及尝试使用 -L 添加直接路径到 dll)。但是,我仍然收到以下错误:
undefined reference to `_imp__curl_easy_init'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_perform'
undefined reference to `_imp__curl_easy_strerror'
undefined reference to `_imp__curl_easy_cleanup'
Run Code Online (Sandbox Code Playgroud)
我的编译命令包括:
-Icurl -L"F:/GCCnew/lib/libcurl.dll"
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我怀疑这很简单,但我无法解决,并且搜索没有给我一个不使用 Code::blocks 之类的解决方案。
小智 1
我的编译命令包括:
-Icurl -L"F:/GCCnew/lib/libcurl.dll"
如果你使用 mingw gcc,那么:
-L
必须有文件夹名称,而不是库名称。因此构建命令可能如下所示:
gcc your-file.c -o executable_name -L"F:/GCCnew/lib" -lcurl
Run Code Online (Sandbox Code Playgroud)
有用的链接: