如何在 C 中修复“体系结构的未定义符号 x86_64”?
How to fix " Undefined symbols for architecture x86_64 " in C?
我在 main 中包含一个头文件,但是当我编译 main 时,出现链接器失败的错误。
我试图找到目标文件,但找不到。
我认为问题可能出在我的机器上。我是初学者,所以我不知道如何解决这个问题
当我尝试编译代码时出现此错误:
Undefined symbols for architecture x86_64:
"_intClassic", referenced from:
_main in main-53b7e4.o
"_intQuadrature", referenced from:
_main in main-53b7e4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@zwol @JonathanLeffer I have 3 files in my project main.c
, integral.h
and integral.c
. integral.c
contains the code of the functions
intClassic
and intQuadrature
that allow me to calculate different
types of integral. In integral.h
I declared the functions and
structures I use. Finally in the main I included integral.h
.
Also $ gcc -o output file1.o file2.o
can this command help me ?
在与您的文件相同的目录中,尝试 运行 命令
gcc main.c integral.c -o integral
这应该将这 2 个文件编译成一个名为 ./integral
的程序
我在 main 中包含一个头文件,但是当我编译 main 时,出现链接器失败的错误。
我试图找到目标文件,但找不到。 我认为问题可能出在我的机器上。我是初学者,所以我不知道如何解决这个问题
当我尝试编译代码时出现此错误:
Undefined symbols for architecture x86_64:
"_intClassic", referenced from:
_main in main-53b7e4.o
"_intQuadrature", referenced from:
_main in main-53b7e4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@zwol @JonathanLeffer I have 3 files in my project
main.c
,integral.h
andintegral.c
.integral.c
contains the code of the functionsintClassic
andintQuadrature
that allow me to calculate different types of integral. Inintegral.h
I declared the functions and structures I use. Finally in the main I includedintegral.h
. Also$ gcc -o output file1.o file2.o
can this command help me ?
在与您的文件相同的目录中,尝试 运行 命令
gcc main.c integral.c -o integral
这应该将这 2 个文件编译成一个名为 ./integral