本文记录Windows11下编译FreeCAD 0.21.2的流程。
零、环境
操作系统 | Windows 11 |
Visual Studio | Visual Studio Community 2022 |
CMake | CMake 3.24.2 |
Doxygen | Doxygen-1.9.8 |
一、下载代码与依赖
1.1 下载源代码
git clone https://github.com/FreeCAD/FreeCAD.git
cd ./FreeCAD/
git checkout -b FreeCAD-0.21.2 0.21.2
1.2 下载依赖
从GitHub下载FreeCAD LibPack-0.21 Version 2.11
二、编译
按照下表配置CMake,并完成构建与生成,
Where is the source code | D:/YouQuan/CaeFrameworks/FreeCAD/FreeCAD |
Where to build the binaries | D:/YouQuan/CaeFrameworks/FreeCAD/BUILD/FreeCAD-0.21.2 |
CMAKE_INSTALL_PREFIX | D:/YouQuan/CaeFrameworks/FreeCAD/INSTALL/FreeCAD-0.21.2 |
FREECAD_LIBPACK_DIR | D:/YouQuan/CaeFrameworks/FreeCAD/LibPack-0.21-V2.11 |
BUILD_TEST | FALSE |
打开FreeCAD.sln,构建"ALL_BUILD"完成FreeCAD编译;构建"INSTALL"完成FreeCAD安装。
三、FAQs
问题: 编译TechDrawGui时,报如下错误,
解决方案1: VS源字符集设置问题,右键TechDrawGui项目,打开属性设置,按下图修改即可,
解决方案2:修改src/Mod/TechDraw/Gui/CMakeLists.txt,增加"/utf-8"编译选项,
if(MSVC)
add_definitions(-DHAVE_ATANH -DHAVE_ASINH -DHAVE_ACOSH)
# Set source and execution character sets to UTF-8
# see https://learn.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
add_compile_options(/utf-8)
else(MSVC)
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
endif(MSVC)
参考资料
FreeCADhttps://wiki.freecad.org/Compile_on_Windows
FreeCAD LibPackhttps://github.com/FreeCAD/FreeCAD-LibPack/releases