Compiling on Linux

About the development of the FEM module/workbench.

Moderator: bernd

psi13art
Posts: 50
Joined: Sat Oct 02, 2010 4:01 pm

Re: Compiling on Linux

Post by psi13art »

Ок, it's work!!

What about FREECAD_BUILD_FEM_NETGEN
Current Value: ON

Compilation .....

Code: Select all

[  7%] Building CXX object src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/src/NETGENPlugin/NETGENPlugin_Mesher.cpp.o
/home/valber/source/free-cad-code/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp:61:23: Fatal error: occgeom.hpp: No file or catalog
compilation abort
make[2]: *** [src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/src/NETGENPlugin/NETGENPlugin_Mesher.cpp.o] Ошибка 1
make[1]: *** [src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/all] Ошибка 2
make: *** [all] Ошибка 2
ickby
Veteran
Posts: 3117
Joined: Wed Oct 05, 2011 7:36 am

Re: Compiling on Linux

Post by ickby »

The linux distrubutions do not supply all needed netgen headers to compile the plugin successfully. Currently your only chance is to compil netgen on your own, point freecad towards you own netgens header files and put your nglib somewhere it is found by freecad on runtime.
psi13art
Posts: 50
Joined: Sat Oct 02, 2010 4:01 pm

Re: Compiling on Linux

Post by psi13art »

What files/path register in cmake for the netgen test? (without "make install")

https://help.ubuntu.com/community/netge ... 6%20ngflow
mauriz
Posts: 8
Joined: Sun Mar 02, 2014 4:42 pm

Re: Compiling on Linux

Post by mauriz »

With the changes to src/3rdParty/salomesmesh/CMakeLists.txt I will describe below, I successfully compiled FreeCAD master on Kubuntu 12.04 with the FREECAD_BUILD_NETGEN option switched on. I use OCE-0.14 and netgen 5.1.

CHANGE 1
I moved all the variables in include_directories() to the end. Otherwise my build system uses the wrong “utilities.h” header, leading to lots of compilation errors.

Code: Select all

include_directories(
    src/SMDS
    src/Driver
    src/DriverUNV
    src/DriverDAT
    src/DriverSTL
    src/StdMeshers
    inc
    ${CMAKE_BINARY_DIR}/src
    ${CMAKE_SOURCE_DIR}/src
    ${CMAKE_CURRENT_BINARY_DIR}
    ${Boost_INCLUDE_DIRS}
    ${OCC_INCLUDE_DIR}
    ${NGLIB_INCLUDE_DIR}
    ${NETGEN_INCLUDE_DIRS}
)
CHANGE 2
In the section NETGENPlugin I inserted a COMPILE_FLAGS definition. I omitted the -DOCCGEOMETRY definition to prevent compiler warning about the variable being redifiend.

Code: Select all

################
# NETGENPlugin #
################
…
else(MSVC)
    set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DNETGEN_V5")
…
With the COMPILE_FLAGS definition above, users with an old netgen version will run into problems. Is this a problem?
For myself, I prefer to use a current version of netgen, linked to a current version of OCE. Building OCE is straight forward. Building netgen is a bit tricky but not too complicated (see notes below).

CHANGE 3
FreeCAD compiles without the next change. However, without that change, I get the warning "sh: 1: SMDS_MemoryLimit: not found" on the console when meshing a geometry. Therefore, I added the following section to CMakeLists.txt.
Note: The conditionals for MSVC and MINGW are an untested guess. Especially, I am unsure about the DEBUG_OUTPUT_NAME.

Code: Select all

############################
# SMDS_MemoryLimit Utility #
############################
SET(SMDS_MemoryLimit_SRCS
        src/SMDS/SMDS_MemoryLimit.cpp
    )
add_executable(SMDS_MemoryLimit ${SMDS_MemoryLimit_SRCS})

# Note this is IDE specific, not necessarily platform specific
if(MSVC)
    set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
    set_target_properties(SMDS_MemoryLimit PROPERTIES DEBUG_OUTPUT_NAME "SMDS_MemoryLimit")
    # dirty hack to avoid Debug/Release subdirectory
    set_target_properties(FreeCADMainCmd PROPERTIES PREFIX "../")
    set_target_properties(FreeCADMainCmd PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
elseif(MINGW)
    set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
    set_target_properties(SMDS_MemoryLimit PROPERTIES DEBUG_OUTPUT_NAME "SMDS_MemoryLimit")
    set_target_properties(FreeCADMainCmd PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
else(MSVC)
    set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
    set_target_properties(SMDS_MemoryLimit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
    set_target_properties(SMDS_MemoryLimit PROPERTIES INSTALL_RPATH ${INSTALL_RPATH})
endif(MSVC)
NOTES ABOUT NETGEN
I use netgen from the sourceforge repository (svn checkout svn://svn.code.sf.net/p/netgen-mesher/code netgen-mesher-code). For the following description, the base directory is branches/netgen-5.1.

First, some modifications of the source are required:
In libsrc/occ/Partition_Inter3d.cxx and libsrc/occ/Partition_Splitter.cxx the lines with the comment “# V6.3” must be commented out and the lines with the comment “# V6.5” must be uncommented.

In libsrc/occ/Partition_Loop2d.cxx I have inserted the following lines just after the file header:

Code: Select all

#ifndef PI
  #define PI M_PI
#endif
Next, a symbolic link must be defined:

Code: Select all

# cd /MY_PREFIX/include/oce
# ln -s . inc
Then we can compile netgen:

Code: Select all

# autoreconf --install
# mkdir build
# cd build
# ../configure --disable-gui  --prefix=MY_PREFIX –includedir=/MY_PREFIX/include/netgen --with-occ=/MY_PREFIX/include/oce LDFLAGS=-L/MY_PREFIX/lib
# make -j8 all install
Note: The FreeCAD CMake Variable NETGEN_INCLUDE_DIR must correspond to the --includedir option defined above.

REMARKS ABOUT CMake VARIABLES
To compile FreeCAD, the following variables must point to subdirectories within the netgen source tree (these headers are not part of the netgen dev package, these header are not installed to “include” when compiling and installing netgen using “make all install”)

NETGEN_DIR_csg = NETGEN_SOURCE/libsrc/csg
NETGEN_DIR_gen = NETGEN_SOURCE/libsrc/general
NETGEN_DIR_geom2d = NETGEN_SOURCE/libsrc/geom2d
NETGEN_DIR_gprim = NETGEN_SOURCE/libsrc/gprim
NETGEN_DIR_la = NETGEN_SOURCE/libsrc/linalg
NETGEN_DIR_mesh = NETGEN_SOURCE/libsrc/meshing
NETGEN_DIR_occ = NETGEN_SOURCE/libsrc/occ
NETGEN_DIR_stlgeom = NETGEN_SOURCE/libsrc/stlgeom
User avatar
dubstar-04
Posts: 698
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Compiling on Linux

Post by dubstar-04 »

I have installed calculix on Ubuntu however, when i try to switch to the FEM workbench i get the following message:
No module named Calculixlib
Am i missing something?

OS: Ubuntu 13.10
Platform: 64-bit
Version: 0.14.3207 (Git)
Branch: master
Hash: e2bb30bd47690f5528998e4d18efed96d4324c38
Python version: 2.7.5+
Qt version: 4.8.4
Coin version: 4.0.0a
SoQt version: 1.5.0
OCC version: 6.7.0
User avatar
quick61
Veteran
Posts: 3804
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Compiling on Linux

Post by quick61 »

dubstar-04 wrote:I have installed calculix on Ubuntu however, when i try to switch to the FEM workbench i get the following message:
No module named Calculixlib
Am i missing something?

OS: Ubuntu 13.10
Platform: 64-bit
Version: 0.14.3207 (Git)
Branch: master
Hash: e2bb30bd47690f5528998e4d18efed96d4324c38
Python version: 2.7.5+
Qt version: 4.8.4
Coin version: 4.0.0a
SoQt version: 1.5.0
OCC version: 6.7.0
That was fixed a few days ago - issue #1449
This post made with 0.0% Micro$oft products - GOT LINUX?
wmayer
Founder
Posts: 20074
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Compiling on Linux

Post by wmayer »

mauriz wrote:With the changes to src/3rdParty/salomesmesh/CMakeLists.txt I will describe below, I successfully compiled FreeCAD master on Kubuntu 12.04 with the FREECAD_BUILD_NETGEN option switched on. I use OCE-0.14 and netgen 5.1.
Thanks for your contribution! I have opened a Mantis ticket to not loose your patch: http://www.freecadweb.org/tracker/view.php?id=1462
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Compiling on Linux

Post by jriegel »

Does it actually work? I mean compile it is only one thing, but it should also work...

IMO omit -DOCCGEOMETRY will switch of the CasCade support in NETGEN, which is the whole point of using NETGEN? Does the mesher work?
Stop whining - start coding!
mauriz
Posts: 8
Joined: Sun Mar 02, 2014 4:42 pm

Re: Compiling on Linux

Post by mauriz »

Hi,

Werner, thanks for opening a ticket. Next time I will do it myself...
jriegel wrote:Does it actually work? I mean compile it is only one thing, but it should also work...
Yes, it works. I can mesh bodies using Create mesh from shape. It works for Netgen as well as for Mefisto. I guess the reason is in cMake/FindNETGEN.cmake on line 16:

Code: Select all

SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY)
As I read the code, cmake appends the options defined here when netgen is compiled. Plesase correct me if I'm wrong; I'm not very experienced... However, I don't know if all cmake versions out there beheave the same way.

On the bottom line, it does not hurt to introduce the -DOCCGEOMETRY in the CMakeLists.txt file again. In the worst case, the compiler issues a warning about a variable being redefined. (Strange is, that I get a warning for -DOCCGEOMETRY but not for -DNO_PARALLEL_THREADS).

Mauriz
mauriz
Posts: 8
Joined: Sun Mar 02, 2014 4:42 pm

Re: Compiling on Linux

Post by mauriz »

Hi,

I did some more research about the compiler warning on my system when the -DOCCGEOMETRY switch is used. In the source of salomesmesh I find some occurrences of #define OCCGEOMETRY. This is likely the reason for the compiler warnings. It appears to me, that the -DOCCGEOMETRY switch is not needed at all: I removed it from FindNETGEN.cmake, deleted the build directory, recompiled FreeCAD and meshing with netgen is still working.

However, prior removing the -DOCCGEOMETRY switch, my conclusion should be confirmed by an expert.
Post Reply