LibreCAD_3编译遇到的问题

博主在Ubuntu18上编译LibreCAD_3时遇到了三个问题: tinyspline库编译选项缺失-fPIC、glfwGetError未声明和gtest库未安装。通过修改CMakeLists.txt文件添加-fPIC选项,替换glfwGetError为glGetError,以及手动编译安装GoogleTest,最终成功解决所有问题并完成编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

         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全部通过。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值