c - g++ Mac Curl 架构 x86_64 的未定义符号
问题描述
我正在学习与 curl 相关的在线课程。但是,我遇到了一些问题。
我的建筑声明是:
gcc -Wall web-server.c -o web-server1 -lcurl
这是 web-server.c 中的代码
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main(void){
CURL *curl = NULL;
CURLcode res;
curl = curl_easy_init();
curl_easy_setops(curl, CURLOPT_URL, "http://www.google.com");
res = curl_easy_perform(curl);
if (res != CURLE_OK){
print("curl easy perform error res = %d",res);
return 1;
}
curl_easy_cleanup(curl);
return 0;
}
错误信息是:
Undefined symbols for architecture x86_64:
"_curl_easy_setops", referenced from:
_main in web-server-afa9ad.o
"_print", referenced from:
_main in web-server-afa9ad.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
非常感谢你们 我的操作系统是 MacOs 10.14.6 我的 gcc 版本
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Found CUDA installation: /usr/local/cuda, version unknown
详细的错误信息
"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library
/Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -
dynamic -arch x86_64 -macosx_version_min 10.14.0 -o web-server
/var/folders/j2/jrqt57vj73s0jc8mjc2mddf40000gn/T/web-server-14b13c.o -lcurl
-lSystem
/Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/lib/darwin/libclan
g_rt.osx.a
解决方案
推荐阅读
- intellij-idea - 在打开 PhpStorm 的情况下从命令行运行代码格式化程序
- c# - 传递给视图的错误模型项属于“x”类型,但此字典需要“y”类型的模型项
- pandas - 如何将 pandas DataFrames 的字典连接成一个单一的 DataFrame?
- android - 无法从 Bloc Flutter 中听到新的价值
- .net-core - PublishSingleFile 选项如何处理旧版本的应用程序?
- modelica - Modelica 变量未在此范围内声明
- react-native - 如何使用 ref 更改内置组件的 props 值
- svelte - 使用 Svelte,我如何填充