编译时 make 没有 link 数学库

make doesn't link math lib when compiling

使用 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 and 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.