I have posted this question in stack overflow (https://stackoverflow.com/ questions/59851535/undefined-reference-cgalprecondition-fail), but I reproduce
it here as I think its the right place for CGAL questions:
I am trying to build a project with CMake in Debug mode. The project contains
several static libraries, a dynamic library and an executable. The executable
links against the dynamic library and the dynamic library links against
several external dynamic libraries and to the project static libraries. One of
the static libraries depends on CGAL.
Static A -> CGAL
Dynamic C -> Static A, Static B, Qt...
Executable -> Dynamic C
When compiling in Release mode, everything works fine, but when compiling in
Debug mode, I get
[100%] Linking CXX executable ../../bin/Executable
/usr/bin/ld: ../../lib/DynamicC.so: undefined reference to
`CGAL::precondition_fail(char const*, char const*, int, char const*)'
collect2: error: ld returned 1 exit status
I have checked the exported symbols for DynamicC with `nm -D DynamicC | grep
CGAL::precondition_fail` and it says its undefined
Re: Undefined reference to CGAL::precondition_fail
On 22.01.20 02:59, Juan José Casafranca wrote:
> Static A -> CGAL
> Static B
> Dynamic C -> Static A, Static B, Qt...
> Executable -> Dynamic C
> nm -C DynamicC.so | grep CGAL::precondition
> U CGAL::precondition_fail(char const*, char const*, int, char
Can you do this also for all libraries and the executable? Once you've found
the source, you can further drill down on the corresponding object files.
Did you maybe disable the header-only mode for some translation units? Or use
a second include path that points to an older CGAL version where header-only
was not the default? Do your external libraries depends on CGAL?
The problem does not show up in release builds because the assertions are
disabled in release builds (which probably means that your external libraries
do not depend on CGAL and are unrelated).