建筑x86_64的未定义符号 ->建筑x86_64找不到的符号
Undefined symbols for architecture x86_64 -> symbol(s) not found for architecture x86_64
我正在学习c ,我已经掌握了这一点:
helloworld.cpp
#include <iostream>
using namespace std;
int main() {
cout << "Hi" << endl;
return 0;
}
我正在使用Macos Mojave,用于编译,我使用命令
>> g++ helloworld.cpp
>> ./a.out
如果工作正常。现在我想使用标题文件。因此,我已经创建了以下文件:
test.cpp
#include <iostream>
#include "add.h"
using namespace std;
int main() {
add(4,7);
return 0;
}
add.h
#pragma once
int add(int a, int b);
add.cpp
#include "add.h"
int add(int a, int b) {
return a + b;
}
当我尝试编译时,我会得到:
>> g++ test.cpp
Undefined symbols for architecture x86_64:
"add(int, int)", referenced from:
_main in test-ebc106.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
有人知道如何解决这个问题吗?
g++ test.cpp add.cpp
需要编译每个CPP文件以分开.OBJ文件
相关文章:
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自:
- Qt Creator项目打破:"找不到建筑x86_64符号"
- C++ 建筑x86_64的未定义符号(类似)
- 建筑x86_64的未定义符号 (curlpp)
- 建筑x86_64的未定义符号 ->建筑x86_64找不到的符号
- 建筑x86_64的未定义符号 - 如何查找丢失的文件
- 凉亭ROS插件出错:建筑x86_64的未定义符号
- 未定义的建筑符号,尝试了i386和其他符号
- 加速C++:建筑x86_64的未定义符号
- 建筑x86_64的未定义符号:链接错误
- 建筑x86_64的未定义符号:"_SSLv2_ ..."
- 叮当 Mac 链接错误与 gtest 建筑x86_64的未定义符号
- 另一个:建筑x86_64:的未定义符号
- C++ 制作链接步骤:建筑x86_64的未定义符号
- 石英:为x86_64建筑构建时未定义的符号
- 建筑x86_64的未定义符号:C++编译
- LD:找不到建筑符号
- 建筑x86_64的未定义符号:"Shape::get_area()",引用自:Shape.o 中的形状可投票。
- 未定义的建筑符号x86_64 -小牛(约塞米蒂,埃尔卡皮坦…)
- 'ld:找不到建筑???符号",即使它在那里