LibreCAD是Linux平台上常见的2D绘图软件,本人因工作需经常开发机床的简易CAD软件,对其一直特别关注。这个软件有一个较大的升级版本LibreCAD_3,想体验一下,打开Ubuntu18,上GitHub,克隆源代码,编译,官方Wiki已经给出编译方法,
Building · LibreCAD/LibreCAD_3 Wiki · GitHub
但事情发展没那么顺利,执行到步骤
make -j 4
遭遇了三个错误,第一错误信如下:
[ 22%] Linking CXX shared library liblckernel.so
/usr/bin/ld: tinyspline/lib/libtinysplinecxx.a(tinyspline.c.o): relocation R_X86_64_PC32 against symbol `ts_bspline_set_knots' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: 错误的值
网上查了很久也没找到方法白嫖,最后只好自己硬着头皮修改了
LibreCAD_3/lckernel/tinyspline/src/CMakeLists.txt文件的603行和614行
# TINYSPLINE_LIBRARY_C_FLAGS
list(APPEND TINYSPLINE_LIBRARY_C_FLAGS
"-std=c89"
"-pedantic"
"-fPIC -Wall" // 修改过
"-Wextra"
"-Wfloat-equal")
。。。。。。
# TINYSPLINE_LIBRARY_CXX_FLAGS
list(APPEND TINYSPLINE_LIBRARY_CXX_FLAGS
"-fPIC -Wall" // 修改过
"-Wextra"
"-Wfloat-equal")
改了再make就好。
第二个问题
[ 90%] Building CXX object luacmdinterface/CMakeFiles/luacmdinterface.dir/main.cpp.o
/home/quan/GitRoot/LibreCAD_3/luacmdinterface/main.cpp: In function ‘int main(int, char**)’:
/home/quan/GitRoot/LibreCAD_3/luacmdinterface/main.cpp:152:9: error: ‘glfwGetError’ was not declared in this scope
glfwGetError(&description);
^~~~~~~~~~~~
/home/quan/GitRoot/LibreCAD_3/luacmdinterface/main.cpp:152:9: note: suggested alternative: ‘’
glfwGetError(&description);
^~~~~~~~~~~~
glGetError
按照提示信息,改“glfwGetError(&description);”为“glGetError()”
第三个问题
[ 99%] Building CXX object unittest/CMakeFiles/lcunittest.dir/rendering/renderingtest.cpp.o
[100%] Linking CXX executable ../bin/lcunittest
/usr/bin/ld: 找不到 -lgtest
collect2: error: ld returned 1 exit status
unittest/CMakeFiles/lcunittest.dir/build.make:761: recipe for target 'bin/lcunittest' failed
make[2]: *** [bin/lcunittest] Error 1
CMakeFiles/Makefile2:1771: recipe for target 'unittest/CMakeFiles/lcunittest.dir/all' failed
make[1]: *** [unittest/CMakeFiles/lcunittest.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2
查wiki可知是 Google Test没安装,“You need to compile Google Test in /usr/src/gtest/ and move the libraries in /usr/lib/”具体安装步骤如下:
cd /usr/src/gtest
sudo mkdir build
sudo cd build
sudo cmake ..
sudo make
sudo make install
重新make全部通过。