how to fix cmake parts?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

how to fix cmake parts?

Post by django013 »

Hello,

I try to get the combination of netgen and fc up and running.

Both packages build, but currently I get runtime errors when I switch to fem-wb in fc about unresolved externals.
@midgetfc found out, that the netgen author experimented with cmake instructions and that the experiment was not finished.
nglib definitions might be the source of trouble.
As sf.net is stil out of order, I try to get into the problem.

This is the CMakeList.txt of nglib - that I changed without really knowing what to do

Code: Select all

# dist_pkgdata_DATA = cube.surf

add_definitions(-DNGLIB_EXPORTS)
set(nglib_sources nglib.cpp)

# ADD_LIBRARY(nglib SHARED nglib.cpp)
# TARGET_LINK_LIBRARIES( nglib interface geom2d csg stl occ mesh ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} )

#//FC needs csg gen geom2d gprim la mesh occ stlgeom

#if(WIN32)
#    set(nglib_objects 
#        $<TARGET_OBJECTS:interface>
#        $<TARGET_OBJECTS:geom2d>
#        $<TARGET_OBJECTS:csg>
#        $<TARGET_OBJECTS:stl>
#        $<TARGET_OBJECTS:occ>
#        $<TARGET_OBJECTS:mesh>
#        $<TARGET_OBJECTS:general>
#        $<TARGET_OBJECTS:linalg>
#        $<TARGET_OBJECTS:gprim>
#
#        $<TARGET_OBJECTS:visual>
#        $<TARGET_OBJECTS:csgvis>
#        $<TARGET_OBJECTS:stlvis>
##         $<TARGET_OBJECTS:geom2dvis>
##         $<TARGET_OBJECTS:occvis>
#       )
#else
    set(nglib_objects
            interface geom2d csg stl occ mesh visual stlvis occvis geom2dvis csgvis
#            gen la gprim
            )
#endif(WIN32)

#add_library(nglib SHARED ${nglib_sources} ${nglib_objects})
add_library(nglib SHARED ${nglib_sources})
target_link_libraries( nglib ${nglib_objects} ${LIBPTHREAD} ${OCC_LIBRARIES} ${LIBTOGL} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} )

if(USE_PYTHON)
    target_link_libraries(nglib ${PYTHON_LIBS})
endif(USE_PYTHON)

# if(NOT WIN32)
#     add_executable(ng_vol ng_vol.cpp ${nglib_objects})
#     target_link_libraries( ng_vol nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} )
#     target_link_libraries( ng_vol nglib interface geom2d csg stl occ mesh )
# 
#     add_executable(ng_stl ng_stl.cpp ${nglib_objects})
#     target_link_libraries( ng_stl nglib ${OCC_LIBRARIES} ${OCC_OCAF_LIBRARIES} ${MPI_CXX_LIBRARIES} )
#     target_link_libraries( ng_stl nglib interface geom2d csg stl occ mesh )
# 
#     install(TARGETS nglib ng_vol ng_stl ${ng_install_dir})
# endif(NOT WIN32)

install(TARGETS nglib ${ng_install_dir})
using the TARGET_OBJECTS the author created does not work on debian.
Using nglib_objects at add_library fails with error

Code: Select all

no source for interface. Tried ...
Using the variant without TARGET_OBJECTS works to build.
but FC still fails to switch to fem wb - now error message is

Code: Select all

/opt/netgen/lib/liboccvis.so: undefined symbol: _ZN6netgen25SelectFaceInOCCDialogTreeEi
The function SelectFaceInOCCDialogTree() is defined in ng/ngpkg.cpp
... and apparently liboccvis does not know, how to load netgen lib for that symbol.

So I guess, this is a cmake issue.

I don't know, how to proceed :(
OS: Linux Debian Jessie amd64 - FC: Git Master
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: how to fix cmake parts?

Post by wmayer »

When configuring netgen with cmake add this

Code: Select all

"-Wl,--no-undefined"
to CMAKE_SHARED_LINKER_FLAGS. If netgen still builds after a "make clean" then everything there is fine.
The symbol seems to be part of libvisual.so - which exists
This lib looks new to me. Then you probably have to make FreeCAD dependent on this, too.
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: how to fix cmake parts?

Post by django013 »

Thank you for your support!

build now fails. Error message is too long, have to append a file.
link_errors.txt
(61.25 KiB) Downloaded 68 times
I guess, that bunch of errors is beyond my skills.
Looks like my netgen-snapshot is not in a usable state.
This lib looks new to me.
Can I verify, that the symbol is part of that library?
OS: Linux Debian Jessie amd64 - FC: Git Master
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: how to fix cmake parts?

Post by wmayer »

From the txt file it's impossible to say what's wrong. Either all the source files of the missing functions weren't built at all or the libvisual target doesn't have listed the corresponding libraries as dependency.

You should make a description of what you did. E.g where you got the source code from, how you run cmake, ...
Can I verify, that the symbol is part of that library?
With the tool nm you get all symbols of a shared library (in case you didn't run strip on it). So, with nm + grep you check if a certain symbol is there.
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: how to fix cmake parts?

Post by django013 »

Either all the source files of the missing functions weren't built at all
No, they have been built, I have *.o files
You should make a description of what you did. E.g where you got the source code from, how you run cmake, ...
Ok, the sources are from sf.net and when I start netgen I get this:

Code: Select all

NETGEN-6.1-dev
Developed by Joachim Schoeberl at
2010-xxxx Vienna University of Technology
2006-2010 RWTH Aachen University
1996-2006 Johannes Kepler University Linz
Including OpenCascade geometry kernel
Run parallel Netgen with 'mpirun -np xy netgen'
optfile ./ng.opt does not exist - using default values
OCC module loaded
The sources are located at /usr/local/src and I created a centralized build directory /usr/local/build where I create subdirectories for each project that is built from /usr/local/src
I used cmake-gui to check all requirements and setup the parameters.
prefix for netgen is /opt and netgen uses the same oce as fc (also self built).

To ease the usage of netgen for fc I linked each lib from /opt/netgen/lib to /usr/local/lib

The CMakeList.txt for libvisual.so looks like this:

Code: Select all

add_definitions(-DNGINTERFACE_EXPORTS)
install(FILES soldata.hpp DESTINATION include COMPONENT netgen_devel )

# AM_CPPFLAGS =  $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include  -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES)

if(USE_GUI)
    set( LIB_VISUAL_SOURCES meshdoc.cpp mvdraw.cpp vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp visualpkg.cpp )
else(USE_GUI)
    set( LIB_VISUAL_SOURCES visual_dummy.cpp )
endif(USE_GUI)

add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})

if(NOT WIN32)
    target_link_libraries( visual ${PYTHON_LIBS} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TCL_LIBRARY} )
    install( TARGETS visual DESTINATION lib COMPONENT netgen )
endif(NOT WIN32)
Thanks for the hint to nm - this is what I got:

Code: Select all

nm libnetgenlib.so | grep SelectFaceInOCCDialogTree
000000000002a720 T _ZN6netgen25SelectFaceInOCCDialogTreeEi

nm liboccvis.so | grep SelectFaceInOCCDialogTree
                 U _ZN6netgen25SelectFaceInOCCDialogTreeEi
so I guess libnetgenlib.so contains the function code and liboccvis.so exports a symbol without code?
Doesn't need liboccvis a dependency to libnetgenlib?

CMakeLists.txt of liboccvis is this:

Code: Select all

add_library(occ ${NG_LIB_TYPE}
        Partition_Inter2d.cxx Partition_Inter3d.cxx 
        Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx 
        occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp
        )

add_library(occvis ${NG_LIB_TYPE} occpkg.cpp vsocc.cpp)

if(NOT WIN32)
    target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBS})
    target_link_libraries( occvis occ )
    install( TARGETS occ occvis DESTINATION lib COMPONENT netgen )
endif(NOT WIN32)
OS: Linux Debian Jessie amd64 - FC: Git Master
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: how to fix cmake parts?

Post by django013 »

When configuring netgen with cmake add this ...
Can I add those options to the linking stage of fcs netgen-plugin?
Setting CMAKE_SHARED_LINKER_FLAGS changes build-process of the whole project.

Could I add those options to just the netgen-plugin?
OS: Linux Debian Jessie amd64 - FC: Git Master
Post Reply