FreeCAD v0.18 and 0.19 source code compilation under VS2017/19

 

This article introduces how to compile FreeCad 0.18 with vs2017 2019 under windows. When I wrote this article, the 0.19 version was released. I used the method introduced in this article to compile and run the 0.19 version. The errors in the compilation were the same, but they were not corrected.

Prerequisite preparation

I am windows 10 (installation requirement is windows 7 or higher), and visual studio 2017 is installed on the computer. In fact, visual studio 2019 may be better. It is said that the 0.18 version was developed on the vs2013 version. In that case, it is more appropriate to use the official document: https://wiki.freecadweb.org/Compile_on_Windows .

I have cmake 3,16 and git on my computer. If you don't have these, it is recommended to download and install below.

visual studio 2019:

https://visualstudio.microsoft.com/downloads/

cmake 

https://cmake.org/download/

It is recommended that the 18.5 version, the official said not to be the latest, it should be: 3.11.x-3.18.x.

git:

https://git-scm.com/downloads

sdk installation

The sdk of vs2017 is installed with visual studio installer. At least one relatively new sdk should be selected, and all the sdk should occupy more than 10G space. If the SDK is not installed, an error will be reported in the first round, indicating that there is no SDK.

Preparation of hard disk space: The following two downloads each require 300M space. After decompression, the code occupies 500M, and the support library is 3.5G. After compiling one such as release, it is close to 10G. 

Download source code

The download contains 2 parts, one is the source code download,

The source code download link is:

Official Github repositoryhttps://github.com/FreeCAD/FreeCAD.git

fastgit mirror repositoryhttps://hub.fastgit.org/FreeCAD/FreeCAD.git

gitclone mirror repositoryhttps://gitclone.com/github.com/FreeCAD/FreeCAD.git

cnpmjs mirror warehousehttps://github.com.cnpmjs.org/FreeCAD/FreeCAD.git

Clone the code  git clone https://github.com/FreeCAD/FreeCAD.git (change the mirror if it doesn’t move)

I used the official one, which is the first one. The specific version should be this: https://github.com/FreeCAD/FreeCAD/releases/tag/0.18.5

And now version 0.19 is: https://github.com/FreeCAD/FreeCAD/tree/releases/FreeCAD-0-19

Libpack supports library package download

Freecad compilation requires some support libraries, such as OpenCASCADe, Coin and Qt.

The support library installation package packaged under windows, the download address is:

The official Libpack can be downloaded from Github Release https://github.com/FreeCAD/FreeCAD/releases

Libpack created by community members  https://github.com/apeltauer/FreeCAD/releases(including OpenCascade 7.5)

What I download is: https://github.com/apeltauer/FreeCAD/releases/tag/LibPack_12.1.4

Its content is:

Visual Studio 2017
OpenSSL 3.0.0
Curl
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)

The title says it's a bit outdated, but it's vs2017 on my computer, and I didn't find an update. vs2019 is up to date.

cmake configuration project

This is the most important part of the compilation, and its content is the project to be compiled.

First unzip the download above, mine

The source code is placed under: C:\study17\FreeCAD18,

The support library is placed in: C:\study17\FreeCADLibs_12.1.4_x64_VC15

Run cmake, in the source code place, enter the directory where our source code is decompressed and released, where the compiled result is, I add a /bin or /build to the source code directory to ensure that it is separated from the source code, or other directories are also can.

Click onfigure (configuration), then the project compiler selection dialog box appears. Of course, the specified is: visual studio 15 2017, we must pay attention to choosing x64 here, because our support library is x64, so we must choose x64 here. 

Once you have selected it, click Finish to start the configuration. The error appears, it doesn't matter, we need to set the path of the support library package: this is in the FREECAD project, the following FREECAD_LIBPACK_DIR, copy or enter the libpack directory here.

There are 3 items that contain copy. Check them so that the supporting files will be in the program directory after editing. However, this option will not appear for the first time, after config, it will be available again.

My first configuration prompts that I need to install the SDK. This is what I mean by installing the SDK in the above premise.

Another important point is: Under the BUILD project, you need to check BUILD_QT5:

If you want to make an installation package, you need to set CMAKE_INSTALL_PREFIX, which is not set or may be a program file directory.

 

There is also need to cancel BUILD_JTREADER

https://blog.csdn.net/libaineu2004/article/details/95623091  This blog says to choose to check BUILD_SANDBOX, BUILD_TEMPLATE, it is estimated that you need this function, just check it. Not selecting it just lacks this feature.

Configure again, if you report an error, look at the error, and configure again, I was just fine the first time, and it shows Config Done

Created install commands for INSTALL target.

=================================================
Now run 'cmake --build C:/study17/FreeCAD-0.19/build' to build FreeCAD
=================================================

Configuring done

Then click Generate to generate the project. After the project is generated, you can Open Projet. I don't know how to open the project is empty.

But it doesn't matter, I open visual studio 2017 by myself, and then open the sln file.

Compile the project

I can't open the project directly in cmake, so open vs2017, and then open freecad.sln:

Compiling is actually very simple. I chose the first project: FreecadBase to compile this one separately, because I started downloading and compiling 0.19_pre. This compilation fails, and many later will not work. If all build lasts a long time, it will not work in the end. The option I compile is Release. I don't want to debug, so I will compile it first.

After the compilation is complete, all build. But compiling takes a lot of time, my computer used 3 hours.

There was an error in the first compilation, and 3 projects failed. Check the reason:

110>Generating Code...
110>LINK : fatal error LNK1181: cannot open input file '..\App\Release\_PartDesign.lib'
110>Done building project "PartDesignGui.vcxproj" -- FAILED.
111>------ Build started: Project: ALL_BUILD, Configuration: Release x64 ------
111>Building Custom Rule C:/study17/FreeCAD-0.19/CMakeLists.txt
112>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
112>Project not selected to build for this solution configuration 
========== Build: 106 succeeded, 2 failed, 1 up-to-date, 4 skipped ==========

The error message is like this:

5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1237): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1889): error C2001: newline in constant
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1891): error C3688: invalid literal suffix '鈥unsupported'; literal operator or literal operator template 'operator ""鈥unsupported' not found
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1891): error C2143: syntax error: missing ')' before 'std::string'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1891): error C2143: syntax error: missing ';' before 'std::string'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1902): error C2001: newline in constant
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1904): error C3688: invalid literal suffix '鈥unsupported'; literal operator or literal operator template 'operator ""鈥unsupported' not found
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1904): error C2146: syntax error: missing ')' before identifier 't'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1904): error C2146: syntax error: missing ';' before identifier 't'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1931): error C3688: invalid literal suffix '鈥with'; literal operator or literal operator template 'operator ""鈥with' not found
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1931): error C2143: syntax error: missing ';' before ':'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1931): error C2059: syntax error: ':'
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1931): error C2017: illegal escape sequence
5>C:\study17\FreeCAD-0.19\src\Mod\PartDesign\App\FeatureHole.cpp(1931): error C2001: newline in constant
5>Generating Code...
5>Done building project "PartDesign.vcxproj" -- FAILED.

 

FearureHole.cpp has garbled characters in this file. According to the error message and line number, it is easy to find the wrong place.

1889:throw Base::IndexError(std::string("Thread type ‘") + thread_type_string + "’ unsupported");

1902: throw Base::IndexError(std::string("Cut type ‘") + cut_type_string + "’ unsupported");

1931:std::cerr << "Failed reading ‘" << f.filePath() << "’ with: "<< e.what() << "\n";


Excluding these few errors, all the compilation is successful.

========== Build: 3 succeeded, 0 failed, 106 up-to-date, 4 skipped ==========

If you want to make the installation package, right-click the INSTALL project after all the compilation is successful, and then Projecct Only->build only INSTALL. It will take some time to copy all the required files to the directory specified by cmake_install_prefix. 

Run verification

Go to bin under bin and click freecad.exe directly to start the freecad interface.

For the first time, the 3 copy options were not checked, indicating that the file information is missing.

Later, after checking, the project is generated and compiled, which is a bit time-consuming.

When compiling version 0.19 later, I forgot to check it again, but it was compiled again. I think the file will be copied in the configuration after checking it. If the replication is completed without forming the project, then I won't form the project, it's really okay.

So, in case you forget to check the 3 copies, it doesn't matter, just check the configuration and let the configuration complete the copy, no need to form a new project. copy has nothing to do with the project, it just helps you to complete the necessary copy when configuring.

Troubleshooting

This mainly refers to the case of cmake configuration failure

I successfully configured it very smoothly for the first time, but then there were always various problems that caused the configuration to fail, mainly because the various path settings were incorrect. For example, the following situation:

This is a python path problem. Many problems are caused by poor python settings:

The following is the boost problem: 

It was very depressing to encounter this situation. Later, I compared the original configuration and set it directly to correct it. This was really effective.

You may not succeed the first time, then you can check the input information below. Usually it is the file name or directory under your libpack directory. My libpack directory is C:/study17/FreeCADLibs_12.1.4_x64_VC15.

That's all about compiling.

Guess you like

Origin blog.csdn.net/leon_zeng0/article/details/114157473