前面写一篇QT4.8.4的安装方法,主要就是为编译QCAD。在这篇里用它编译QCAD没能成功,真是纠结万千。
后面改换成编译QCAD的开源版LIBRECAD,更是奇葩无数。
这里就记录下从失败到成功编译的经历,给以后的自己,也给正在经历同样痛苦的你们;
想一步成功?直接看最后边!!
折腾部分:
刚才开始编译是不成功的,习惯性的搜索网络。这玩意,在中国也没有群或论坛可浏览学习,也只能在网络搜索星星点点;
借鉴了一网页: 为方便阅读,这里复制过来
- How to built LibreCAD (master branch) on Windows.From LibreCAD wiki
- Jump to: navigation, search
- Get and install Cygwin.See: http://www.cygwin.com/
- Get and install Qt SDK.See: http://qt.nokia.com/products/qt-sdk
- Get and install Boost library by doing the following operations:
- Get Boost library (boost_1_48_0.zip) using the following link:https://sourceforge.net/projects/boost/files/boost/1.48.0/
- In C:\, create a directory named "boost".
- In C:\boost\, unzip the boost library.Notes: When finished you will have the following directory:C:\boost\boost_1_48_0
- Get, built and install muParser library by doing the following operations:
- Get muParser library (muparser_v2_2_2.zip) using the following link:http://sourceforge.net/projects/muparser/files/muparser
- In C:\, create a directory named "muparser".
- In C:\muparser\, unzip muparser_v2_2_2.zipNotes: At this point you will have the following directory:C:\muparser\muparser_v2_2_2
- Start Qt Desktop using "Qt 4.8.0 for Desktop (MinGW)" shortcut.
- In Qt Desktop console, navigate to muParser build directory (C:\muparser\muparser_v2_2_2\build\), then type the following command to built muParser library:mingw32-make -fmakefile.mingw
- Get LibreCAD from GIT, doing the following step:
- Start a "Cygwin Terminal" using the supplied short cut.Notes: At this point, you are in C:\cygwin\home\<user>\ directory.
- In Cygwin Terminal, get LibreCAD master branch by typing the following command:git clone git://github.com/LibreCAD/LibreCAD.git
- Built and run LibreCAD, by doing the following operations:
- Start Qt Creator using the supplied short cut.
- Built LibreCAD using Qt Creator, by doing the following operations:
- In the menu, select "File"->"Open File or Project...".
- In "Open File", navigate to C:\cygwin\home\<user>\LibreCAD
- In "Open File", select librecad.pro, and then click on the "Open" button.
- In "Project Setup", check "Desktop" item, if not already checked.
- In "Project Setup", uncheck "Use Shadow Building", if not already unchecked.
- In "Project Setup", click on the "Finish" button.
- In menu, select "Build"->"Rebuild All".Notes: At this point, you will have to wait a lot of time to get LibreCAD built, and this is normal.
- Run LibreCAD from Qt Creator, by doing the following operations:
- Switch to "Projects" mode by clicking on associated icon that is located at left of Qt Creator window.
- Then, in "Desktop", select "Run".
- Then, in "Run configuration:", make sure "src" is selected.
- Run LibreCAD by selecting "Build"->"Run" in the menu.
复制代码
一步步按照上面步骤,又是Cygwin(获取源码用),又是Boost 库,又是muParser 库的,还得用指令编译。可气的是编译仍旧不成功,期间还换过QT版本!
下面是编译中遇到 的问题与解决方法:
一 问题1:cc1plus.exe: error: unrecognized command line option "-std=c++11"
原因:g++ gcc 版本不够高;删除旧版本C:\mingw,解压mingw.7z 做为新版本使用;
二 问题2: 编译生成的程序无法运行
新建一测试程序也无法运行了,查看说是APPCRASH,QTcor4.dll问题。看样子又是版本不够高问题。果断卸了QT4.8.4, 装个qt-win-opensource-4.8.5-vs2010.
再次新建新程序 用QT运行,OK!!; 双击运行会提示少QT动态库,先不理会;
三 问题3:100好几错误,原因 LibreCAD-2.0\libraries\jwwlib\src下文件编码问题;
用文本编辑软件notepad.ext,也就是系统自带的txt文件编辑软件手工一个个将目录下全部
文件打开另存。编码改为UTF_8;
四 问题4
1.default: 未声明的标识符 ;
错误:'DBL_EPSILON' was not declared in this scope。
在当前文件包含头文件 #include<float.h>便可;
2. no matching function for call to 'mu:arser::SetExpr(std::string)
宽字符问题:进行更改为p.DefineConst(_T("pi"),M_PI)形式;
3.p.SetExpr(expr.toStdString());改为p.SetExpr(expr.toStdWString());
std::cout << e.GetMsg() << std::endl;
改为
QString s;
s.fromStdWString(e.GetMsg());
std::cout << s.toStdString() << std::endl;
4.错误:'to_string' is not a member of 'std'
进行如下更改,替换不用它便是,
// xmlWriter->addAttribute(_T("id"), std::to_string(block->getId()));
char c[100];sprintf(c,"%ld",block->getId());
xmlWriter->addAttribute("id", c);
还有另一处
// xmlWriter->addAttribute("href", "#" + std::to_string(block->getId()), NAMESPACE_URI_XLINK);
char c[100];sprintf(c,"#%ld",block->getId());
xmlWriter->addAttribute("href", c , NAMESPACE_URI_XLINK);
问题一堆堆,最终仍旧没法编译通过,说是少了这个文件,那个文件。
在放弃余,不禁感慨开源的东西真他妈折腾人!
电脑上安装有LIBRECAD,再操作操作,打算卸载放弃。功能真好,真想学习下代码!
成功部分:
本着不抛弃不放弃的精神,又到LIBRECAD的下载网页github.com/LibreCAD,看看有没个有用的信息。
QCAD开源版LIBRECAD成功编译运行方法与心得
经过上面的折腾,换了QT版本,mingw版本,这次哥再换个LIBRECAD版本,直接换个V1.0.0.BETA5,最低版本试下,
下载解压后其根目录文件有QT版本的介绍,又把QT版本换成4.6.2,再次用此版本QT编译LIBRECAD V1.0.0.BETA5版本,
编译好久又是error: collect2: ld returned 1 exit status。崩溃!说是链接问题,也不折腾,直接删除,更换下个新的LIBRECAD 版本!
下载个LibreCAD-1.0.0再试,我要求也不高,就从最低版本开始,解压后根目录文件介绍的QT版本,差不多也是QT4.6.2,能用!!
直接用 QT4.6.2 编译LibreCAD-1.0.0,嗨整个过程没错误,编译时间是长了点,十几分钟!
在根目录生成 了debug文件夹,内部就生成了LibreCAD.exe,运行缺少些QT动态库,从QT安装目录复制过来便是!
这样从早上折腾到凌晨2点,总算功夫不负有心人,搞定,效果如下图
QCAD开源版LIBRECAD成功编译运行方法与心得
QCAD开源版LIBRECAD成功编译运行方法与心得
总结:
版本一定要一一对应!
这里分享 LibreCAD-1.0.0与qt-sdk-win-opensource-2010.02.1 下载地址:
百度云附件:LibreCAD-1.0.0与qt-sdk-win-opensource-2010.02.1.rar
仅要安装qt-sdk-win-opensource-2010.02.1,安装后用QT creater编译LibreCAD-1.0.0就好;
直接编译,顺利通过!不要安装其他库,不要修改编码,不要配置编译器,方便的不要不要的!
|