工控编程吧

标题: QCAD开源版LIBRECAD成功编译运行方法与心得 [打印本页]

作者: qq263946146    时间: 2017-7-6 12:06
标题: QCAD开源版LIBRECAD成功编译运行方法与心得
前面写一篇QT4.8.4的安装方法,主要就是为编译QCAD。在这篇里用它编译QCAD没能成功,真是纠结万千。

后面改换成编译QCAD的开源版LIBRECAD,更是奇葩无数。
这里就记录下从失败到成功编译的经历,给以后的自己,也给正在经历同样痛苦的你们;

想一步成功?直接看最后边!!


折腾部分:
刚才开始编译是不成功的,习惯性的搜索网络。这玩意,在中国也没有群或论坛可浏览学习,也只能在网络搜索星星点点;
借鉴了一网页: 为方便阅读,这里复制过来

  1. How to built LibreCAD (master branch) on Windows.From LibreCAD wiki

  2. Jump to: navigation, search
  3. Get and install Cygwin.See: http://www.cygwin.com/
  4. Get and install Qt SDK.See: http://qt.nokia.com/products/qt-sdk
  5. Get and install Boost library by doing the following operations:
  6. Get Boost library (boost_1_48_0.zip) using the following link:https://sourceforge.net/projects/boost/files/boost/1.48.0/
  7. In C:\, create a directory named "boost".
  8. In C:\boost\, unzip the boost library.Notes: When finished you will have the following directory:C:\boost\boost_1_48_0
  9. Get, built and install muParser library by doing the following operations:
  10. Get muParser library (muparser_v2_2_2.zip) using the following link:http://sourceforge.net/projects/muparser/files/muparser
  11. In C:\, create a directory named "muparser".
  12. In C:\muparser\, unzip muparser_v2_2_2.zipNotes: At this point you will have the following directory:C:\muparser\muparser_v2_2_2
  13. Start Qt Desktop using "Qt 4.8.0 for Desktop (MinGW)" shortcut.
  14. 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
  15. Get LibreCAD from GIT, doing the following step:
  16. Start a "Cygwin Terminal" using the supplied short cut.Notes: At this point, you are in C:\cygwin\home\<user>\ directory.
  17. In Cygwin Terminal, get LibreCAD master branch by typing the following command:git clone git://github.com/LibreCAD/LibreCAD.git
  18. Built and run LibreCAD, by doing the following operations:
  19. Start Qt Creator using the supplied short cut.
  20. Built LibreCAD using Qt Creator, by doing the following operations:
  21. In the menu, select "File"->"Open File or Project...".
  22. In "Open File", navigate to C:\cygwin\home\<user>\LibreCAD
  23. In "Open File", select librecad.pro, and then click on the "Open" button.
  24. In "Project Setup", check "Desktop" item, if not already checked.
  25. In "Project Setup", uncheck "Use Shadow Building", if not already unchecked.
  26. In "Project Setup", click on the "Finish" button.
  27. 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.
  28. Run LibreCAD from Qt Creator, by doing the following operations:
  29. Switch to "Projects" mode by clicking on associated icon that is located at left of Qt Creator window.
  30. Then, in "Desktop", select "Run".
  31. Then, in "Run configuration:", make sure "src" is selected.
  32. 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,看看有没个有用的信息。
(, 下载次数: 8)