]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/README.md
Pending status can be returns from FMU to Native C to Java
[simantics/fmil.git] / org.simantics.fmil.core / README.md
1 # How to build FMUSimulator and FMILibrary
2
3 ## Base FMILibrary
4
5 To build the Visual Studio Solution files you need CMake.
6 CMake is also used to build the base native FMILibrary.
7
8 Note:
9 This is not usually needed, you can use the existing build.
10
11 Remember to manually delete CMakeCache and CMakeFiles from FMILibrary/build/expatex/-folder 
12
13 Follow the instructions provided by the Linux Dockerfile and linuxbuild.sh.
14
15 On Windows the library must be manually downloaded and unzipped to the *native* directory.
16 The build can then be performed by executing the batch file *./windowsbuild.bat* in the same directory.
17
18 The build steps are:
19 1. Download the desired FMILibrary source .zip from https://jmodelica.org/fmil/FMILibrary-2.0.3-src.zip
20 2. Unzip the package to the *native* directory.
21 3. Open terminal with development tools configured
22     * Visual Studio: Use the *"Developer Command Prompt for VS 2017"* start menu entry
23 4. Execute build script
24     * Linux: `docker build -f Dockerfile -t fmilibrary:build .`, then `docker run -v /path/to/org.simantics.fmil.linux64/libraries:/output fmilibrary:build`
25     * Windows: `cd native`, then `windowsbuild.bat`
26
27 Automated steps:
28 1. Replace *fmi_util.c* file under *"<path to FMILibrary>/src/Util/src/FMI/fmi_util.c"* with contents of *fmi_util.c.txt*, located
29 under */native/FMUSimulator/fmi_util.c.txt*.
30 2. Change directory to where you want to build the output
31 3. Run cmake from command-line and provide as the first argument the path to where you unzipped sources in step 2
32 Optional) To make a debug version, add -DFMILIB_ENABLE_LOG_LEVEL_DEBUG=ON before the path to source
33      * Windows: Specify build tools and target architecture with
34        * `cmake -G "Visual Studio 15"` (32-bit) or
35        * `cmake -G "Visual Studio 15 Win64"` (64-bit)
36 4. Use the generated makefiles/project files to perform the build
37     * Linux: In both debug and normal case, run "make" and "make install test" to verify the installation
38     * Windows: Execute the command `msbuild FMILibrary.sln /p:Configuration=<Debug/Release> /p:Platform=<Win32/x64>` 
39
40 If the build succeeded, you should have .dll files which you can now copy to your win32 or win64 org.simantics.fmil.* projects.
41 Specifically:
42 fmu1_dll_cs.dll, fmu1_dll_me.dll, fmu2_dll_cs.dll, fmu2_dll_me.sll and fmilib_shared.dll
43 Copy the corresponding "Debug" build files to the sub-directoryn "Debug" in the projects.
44
45 ### Windows-build with Visual Studio
46
47 On Windows, cmake needs to be run separately for 32-bit and 64-bit builds. See the Windows batch file *update_fmilibrary.bat*, which performs both automatically.
48
49 ### Building on linux
50         
51 When building the libfmilib_shared.so, we need to replace fmi_util.c file under "<path to FMILibrary>/src/Util/src/FMI/fmi_util.c" with contents of fmi_util.c.txt, located
52 under /native/FMUSimulator/fmi_util.c.txt. The Dockerfile already does this so if you build the libfmilib_shared.so with that, then you needn't worry about this.
53  
54 ## FMUSimulator
55
56 When you have the Visual Studio files:
57 Build from command-line our FMUSimulator.dll
58
59 1) Open a VS development terminal
60 2) Navigate to org.simantics.fmil.core/native
61 3) Run "windowsbuildsim.bat"