Linking openNURBS with CMake - Unix

Hello,

I am implementing a NURBS “handler” with C++ on an Unix platform.
The aim is to read 3dm file and use the Splines as an input for a meshing program that works on Ubuntu.
Also, the C++ project in which I want to use openNURBS is based on a CMake compilation, with CMakeLists.txt files to configure it.

So the first step I did was to reorganize a little the folder of openNURBS in order to compile it with CMake into a dynamic library (openNURBSCore.so) :
opennurbs/
_CMakeLists.txt
_build/
_src/
___CMakeLists.txt
__opennurbs.cpp
__opennurbs
.h
___zlib/

Once openNURBS complied, I linked the dynamic library to my main project (always with CMakeListst.txt), and everything compiled as well.

However, I cannot create a new object of openNURBS, because of a onmalloc issue :
For example, writing

ON::Begin();
ON_Brep* brep = new ON_Brep();

cause an error on the execution phase :

symbol lookup error: PATH/include/opennurbs_custom/build/lib/libopenNURBSCore.so: undefined symbol: onmalloc

But

ON::Begin();
ON_Brep* brep;

works well (but does nothing)

Have you any idea why this happens ? If necessary I can post my CMakeLists, but they are a little long to read because I included other libraries in my project.

Thanks in advance for your help !
Elisa

The second part only defines a pointer to an ON_Brep, and does not actually construct an object. It only defines a pointer which is not initialised.

I think onmalloc is a #define to malloc (and onfree to free). It is likely that, when using CMake, these #define statements are missing, probably because other environment variables that relate to the platform are not defined. That’s as far as my knowledge goes, you may want to look for the term #define onmalloc in the headers and see if it is surrounded by certain other #define statements.

Sorry I can’t be more helpful.

Thank your for your answer, I think you are right and I’m looking after the #define that my CMake is missing.
I let you know in few days if it worked !

Elisa

I modified the function for including the sources files, instead of FILE(GLOB_RECURSE openNURBSCore_SRCS *.cpp *.C *.h), I listed all the .h and .cpp as in the Makefile.
This worked much better.

Thanks again for your help !
Elisa