CMake: link to two pre-compiled libraries, depending on different versions of the third library

I am trying to compile a project where I am linking to precompiled versions of two libraries (PCL and Matlab) that are compiled for different versions of Boost (1.58 and 1.56).

This gives me a lot of warnings when I build my project:

Cannot generate a safe runtime search path for target Test because files in some directories may conflict with libraries in implicit directories: runtime library [libpng12.so.0] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /usr/local/MATLAB/R2017b/bin/glnxa64 

etc. for other libraries (libtiff, libfreetype, libexpat, libxml2, libQt5OpenGL ...), but not for boost.

When I compile and run my program, I get this error

 *** Error in `/home/user/Test': free(): invalid pointer: 0x0000000000bf36a8 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f9cf1c507e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f9cf1c5937a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f9cf1c5d53c] /lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0x9a)[0x7f9cf1c1336a] /usr/local/MATLAB/R2017b/bin/glnxa64/libboost_filesystem.so.1.56.0(+0x7646)[0x7f9ce9eda646] 

I suspect this is due to the fact that it adds all the libraries to the same search path and associates PCL with the Boost Matlab version, which gives an error and warnings. I spent a lot of time trying to connect it without fail, but to no avail.

Inspired by: path path confusion after calling target_link_libraries I tried adding Matlab using add_library ,

 add_library(eng STATIC IMPORTED) set_property(TARGET eng PROPERTY IMPORTED_LOCATION ${Matlab_ENG_LIBRARY}) set_property(TARGET eng PROPERTY INTERFACE_INCLUDE_DIRECTORIES /usr/local/MATLAB/R2017b/bin/glnxa64/) target_link_libraries(${PROJECT_NAME} eng) 

(and many variations of this), but I could not find a combination that solved the problem, as I also face the same problems as mine.

It seems that another question relates to a very similar problem, but did not answer it. MATLAB libraries conflict with existing libraries - CMake failed

I think I could solve the problem by compiling PCL and increasing 1.56 from scratch, but I would like to avoid it.


Minimum "working" example:

CMakeLists.txt

 project(Test) cmake_minimum_required(VERSION 2.8) add_executable(${PROJECT_NAME} main.cpp) #PCL find_package(PCL 1.3 REQUIRED COMPONENTS) include_directories(${PCL_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES}) #Matlab find_package(Matlab REQUIRED ENG_LIBRARY) include_directories(${Matlab_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${Matlab_ENG_LIBRARY}) 

main.cpp

 #include <pcl/io/ply_io.h> #include "engine.h" int main() { pcl::PLYReader ply_reader; return 0; } void not_called_function() { Engine *ep; ep = engOpen(""); return; } 

Anything that can help me on my way to a solution will be greatly appreciated.

+8
c ++ boost matlab cmake point-cloud-library
source share

No one has answered this question yet.

See similar questions:

2
Path confusion path after calling target_link_libraries
2
MATLAB libraries conflict with existing libraries - CMake crashes

or similar:

31
version of `CXXABI_1.3.8 'not found (required ...)
28
How to link with boost.system with cmake
14
g ++ -m32 cannot find libstdc ++ on debian amd64
3
PCL (Cloud Point Library) 1.7 on Ubuntu 16.04 LTS Error
2
undefined link to boost :: program_options in xubuntu
2
buffer binding using cmake error
2
Problem with Cmake Core Library
one
invalid mex file error (libstd ++ version)
one
Link to poco static library for targeting in cmake
one
g ++ will not reference the library in / usr / lib /

All Articles