一、环境准备
VS2017,x64
cmake-3.14.5-win64-x64.msi
FreeCADLibs_12.1.2_x64_VC15.1.7z,源码依赖库,x64位,里面已集成boost/Qt5/Python等依赖环境,点击详细说明
依赖库下载:https://github.com/FreeCAD/FreeCAD/releases/tag/0.19_pre
FreeCAD LibPack Version 12.1.2 debug/release with Visual Studio 2017 Qt 5.12.1 PySide2 build against Qt 5.12.1 Coin3D 4.0 Pivy Python 3.6.8 OpenCascade 7.3
Boost 1.67 (including the debug files build against python_d.exe)
源码:https://github.com/FreeCAD/FreeCAD/tree/0.19_pre
二、CMake生成VS工程
1、建工程
注意,一定要选择x64,因为依赖库FreeCADLibs_12.1.2_x64_VC15.1.7z是64位的。这个很重要,如果误选了32位,则会报错:
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/FindBoost.cmake:2165 (message): Unable to find the requested Boost libraries. Boost version: 1.67.0 Boost include path: F:/CADCAM/FreeCADLibs_12.1.2_x64_VC15.1/include Could not find the following Boost libraries: boost_filesystem boost_program_options boost_regex boost_system boost_thread Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost. Call Stack (most recent call first): CMakeLists.txt:654 (find_package) CMake Error at CMakeLists.txt:670 (message): ============================================= Required components: filesystem;program_options;regex;system;thread Not found, install the components: filesystem;program_options;regex;system;thread =============================================
2、指定依赖库的路径
3、勾选需要的功能模块
4、先后点击按钮Configure和Generate。OK!
三、异常处理
如果CMake点击按钮Configure过程有boost库相关的错误信息,请打开项目的CMakeLists.txt文件
F:\CADCAM\FreeCAD-master\CMakeLists.txt ,手动添加以下三句话,会有更详细的提示信息。
set(Boost_DEBUG ON) #是否开启Boost Debug模式,ON位开启,OFF关闭。开启之后会输出很多调试信息,方便寻找错误
set(Boost_ARCHITECTURE "-x32") # CPU架构,对应库文件文件名里的x32或者x64
set(Boost_THREADAPI "win32") # 线程类型,对应thread模块文件名里面的pthread或者win32
四、编译源码及依赖文件拷贝
VS2017打开F:\CADCAM\FreeCAD-master\build\FreeCAD.sln,使用x64编译器编译。
编译比较耗时,需要耐心等待。编译完成之后,程序还无法正常运行,需要把相关依赖文件附上:
1.把
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\bin
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\data
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\resources
拷贝到源文件工程目录F:\CADCAM\FreeCAD-master\build\
resources文件夹的文件很重要,QWebEngine所需的一些关键文件
qtwebengine_resources.pak
qtwebengine_resources_100p
qtwebengine_resources_200p.pak.pak
QtWebEngineProcess.exe
icudtl.dat
缺失了它们,F:\CADCAM\FreeCAD-master\src\Mod\Web\Gui\BrowserView.cpp源码运行会报错,抛出异常。
QWebEngineProfile *profile = view->page()->profile();
2.把
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\plugins\iconengines
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\plugins\imageformats
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\plugins\platforms
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\plugins\printsupport
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\plugins\sqldrivers
拷贝到源文件工程目录F:\CADCAM\FreeCAD-master\build\bin
3.把
F:\CADCAM\FreeCADLibs_12.1.2_x64_VC15.1\translations\qtwebengine_locales
拷贝到源文件工程目录F:\CADCAM\FreeCAD-master\build\bin
五、其他版本同样适用
上述的方法,同样适用于以下环境:
VS2019+Qt5.12.9 x64+FreeCAD v0.18.5+FreeCADLibs_12.1.6_x64_VC15
https://github.com/FreeCAD/FreeCAD/tree/0.18.5
main函数的入口:F:\Software\CADCAM\FreeCAD\FreeCAD-0.18.5\src\Main\MainGui.cpp
---
FreeCAD是一个基于OpenCASCADE的开源CAD/CAE工具。 OpenCASCADE是一套开源的CAD/CAM/CAE几何模型核心,来自法国Matra Datavision公司,是著名的CAD软件EUCLID的开发平台。
https://github.com/FreeCAD/FreeCAD
https://www.freecadweb.org/wiki/Getting_started/zh-cn 入门教程
https://forum.freecadweb.org/index.php 社区
https://www.freecadweb.org/wiki/CompileOnWindows 源码编译说明
https://github.com/FreeCAD/FreeCAD-ports-cache/releases 依赖库官方发布
https://github.com/apeltauer/FreeCAD/releases 依赖库非官方纯私人发布,版本比较新
https://github.com/FreeCAD/FreeCAD_Conda 依赖库新方式
https://www.opencascade.com/ 官网
https://www.opencascade.com/content/download-center
https://www.opencascade.com/content/latest-release