Compiling FMU example for linux
Created by: mpcagro
I seems maven is using the following commands to compile the tank example:
gcc -DLIBXML_STATIC -DFMI_COSIMULATION -O0 -g -c -fmessage-length=0 -DMODEL_IDENTIFIER='tank' -DMODEL_GUID='"{8c4e810f-3df3-4a00-8276-176fa3c9f001}"' -fPIC -g -Isrc -Isrc -Iinclude -Isrc/include -Isrc/include/templates -c -o ../../../target/native/linux64/fmu2watertank.o src/fmu2watertank.c gcc -shared -g -o ../../../target/fmu/binaries/linux64/tank.so ../../../target/native/linux64/fmu2watertank.o
For the build line -g -c and -Isrc is set multiple times. This is not a problem when you have a single *.c og *.cc file. Problems can occur when you have multiple files in the system with interdependencies. I am also a bit unsure why you are using the -g flag at all on linux. If you look in the man pages
man gcc | grep -e '-g'
You can find this output in the list
-g Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information. On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but probably makes other debuggers crash or refuse to read the program.
Are the plan to use GDB by default? else this flag provides an intensive calculation overhead. I am no expert in maven, so I cannot provide a solution in this format. If I would have to do it in cmake, it would look something like this:
cmake_minimum_required (VERSION 2.8.11)
project (FMI)
set(INCLUDE_DIR src/include src/include/templates)
include_directories (${INCLUDE_DIR})
add_definitions(-DLIBXML_STATIC -DFMI_COSIMULATION -DMODEL_IDENTIFIER='tank' -DMODEL_GUID='"{8c4e810f-3df3-4a00-8276-176fa3c9f001}"')
SET(GCC_COVERAGE_COMPILE_FLAGS "-fmessage-length=0")
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
add_library(tank SHARED src/fmu2watertank.c)
I know the output path is not rigth in your case, but the example should help you along. If you the see my output run:
cmake .
followed by
make Verbose=1