为什么在编译过程中尽管有 -I(破折号大写 i)标志,但仍会出现未定义的引用错误?

Why undefined reference error despite -I (dash capital i) flag during compilation?

本文关键字:标志 错误 引用 未定义 过程中 编译 破折号 为什么      更新时间:2023-10-16

我正在编译使用外部库https://www.cs.cmu.edu/afs/cs/project/quake/public/www/triangle.html的代码。 所有三角形源文件和目标文件都在 ~/triangle/文件夹中。所以我像这样编译:

g++ -g sobel_aot_run.cpp sobel_x_out.a sobel_y_out.a support.a -ljpeg -lpng -std=c++11 -I ../include -I ../tools -I ~/triangle -lpthread -ldl -o sobel

即使我指定了-I ~/triangle,运行此命令也会给出以下错误:

/tmp/cc9AUEre.o: In function `main':
/home/zendevil/Halide/tutorial/sobel_aot_run.cpp:74: undefined reference to `triangulate(char*, triangulateio*, triangulateio*, triangulateio*)'
collect2: error: ld returned 1 exit status

如何编译?

-I仅向编译器指定您在目录中搜索文件以满足#include语句。

现在需要编译并链接到正在使用的triangulate代码。