Tag: 器错误

未定义的引用’_ *’链接器错误

我在编译/链接以下C代码时遇到问题。 链接器抛出的错误如下所示: pso.o:pso.c:(.text+0x41): undefined reference to ‘_ps’ … pso.o:pso.c:(.text+0x93): more undefined references to ‘_ps’ follow 这是我第一次为gcc编写C代码,所以我不确定如何解决这个问题。 我假设因为结构PS定义了我的头文件,它不知何故没有链接到pso.c. 但是,我确实在该源文件的顶部使用了#include“ps.h”语句。 我已经在下面包含了相关的源文件和头文件,以及我正在使用的make文件。 编写可链接的C代码是否缺少一个基本概念? 谢谢! 哦,这是一个粒子群优化器,如果你想知道:) main.c文件: #define MAIN #include #include #include #include “ps.h” int main(int argc, char *argv[]) { int c; double test; int test_int; srand(time(NULL)); printf(“starting pso\n”); pso(); printf(“finished pso\n”); return(0); } 有问题的文件,pso.c: #include #include “ps.h” double […]

无法链接到fftw3库

我正在编译测试程序以测试fftw3(ver3.3.4)。 由于它没有安装root previlidge,我使用的命令是: gcc -lm -L/home/my_name/opt/fftw-3.3.4/lib/ -I/home/my_name/opt/fftw-3.3.4/include/ fftwtest.c 安装库的位置 /home/my_name/opt/fftw-3.3.4/ 我的代码是fftw3网站上的第一个教程: #include #include int main(){ int n = 10; fftw_complex *in, *out; fftw_plan p; in = (fftw_complex*) fftw_malloc(n*sizeof(fftw_complex)); out = (fftw_complex*) fftw_malloc(n*sizeof(fftw_complex)); p = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE); fftw_execute(p); /* repeat as needed */ fftw_destroy_plan(p); fftw_free(in); fftw_free(out); return 0; } 当我编译程序时它会返回以下错误: /tmp/ccFsDL1n.o: In function […]