使用 make
编译 xpdf 时出现以下错误。我尝试过使用以下命令:
LIBS=-lm make
但是,它不起作用。我知道问题是 c 编译器无法识别源代码中的数学符号,因为数学库不可用,但我不知道如何修复它。
[ 71%] Linking CXX executable pdftohtml
/usr/bin/ld: CMakeFiles/xpdf_objs.dir/Gfx.cc.o: undefined reference to symbol 'acos@@GLIBC_2.2.5'
//usr/lib64/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [xpdf/CMakeFiles/pdftohtml.dir/build.make:219: xpdf/pdftohtml] Error 1
make[1]: *** [CMakeFiles/Makefile2:428: xpdf/CMakeFiles/pdftohtml.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
我已经把我的Makefile和 makeLists.txt在pastebin上了解更多信息
最佳答案
在阅读 gcc 的手册页后,我意识到我必须使用 g++ 编译器而不是 gcc,其中指出:
The usual way to run GCC is to run the executable called gcc, or machine-gcc when cross-compiling, or machine-gcc-version to run a specific version of GCC. When you compile C++ programs, you should invoke GCC as g++ instead.
关于c - make 编译时不链接数学库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50825735/