c - 尝试使用 g++ 编译 .c 文件时链接器命令失败
问题描述
刚刚发布了一个简单的 c 代码并收到此错误消息。谁能解释问题出在哪里?
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mac@MACs-MacBook-Pro-2 C % cd "/Users/mac/C/" && g++ tes.c++ -o tes && "/Users/mac/C/"tes
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
解决方案
你必须用 gcc 而不是 g++ 编译,g++ 是编译 .cpp 或 .cc 文件
gcc tes.c++ -o tes
推荐阅读
- c# - 如何将 html 表情符号转换为文本?
- c# - C# httpwebrequest 调用将 SendFailure 返回到 URL,但 Postman 应用程序中的相同 URL 调用工作正常,并且在另一台服务器上工作正常
- objective-c - 内存泄漏 NSInvocationOperation
- postgresql - PostgreSQL 服务器用户管理员角色,用于批准从较低角色管理员对 db 的更改
- java - Spring-Boot WebMvcTest:如何使用 Authentication 对象参数测试控制器方法?
- scala - Scala:根据预定义数组 Spark 1.6 中存在的列值过滤 DF 行
- perl - PERL 中使用的 exit(0) 和 exit(1) 有什么区别?
- python - 使用 matplotlib 在多线图中显示误差线
- c++ - 未找到响应 libmicrohttpd 的图像
- html - 某个css属性的引入导致其他不相关的属性被忽略