My argument list for the linker is getting too long and I am receiving the following error at this point:
Error running link command: Argument list too long
I am using different 3rd party libraries in my application (including Qt, OpenCV, PointCloudLibrary, VTK, ...), some of which I compiled manually, others I installed through homebrew on Mac OS X 10.7.
For the actual build setup of my application I am using CMake (2.8-9). Recently, I started linking against PCL (PointCloudLibrary 1.6), which is giving me a headache and the reported error right now.
My CMake file looks something like this:
cmake_minimum_required(VERSION 2.6)
project(cmake_test)
add_definitions( -DBOOST_ALL_NO_LIB )
add_definitions( -DBOOST_ALL_DYN_LINK )
find_package(Boost COMPONENTS iostreams system filesystem regex thread date_time timer atomic locale graph exception REQUIRED)
if(Boost_FOUND)
add_definitions("-DHAS_BOOST")
endif()
find_package(PCL REQUIRED)
include_directories(
${Boost_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
link_directories(
${Boost_LIBRARY_DIRS}
${PCL_LIBRARY_DIRS}
)
add_definitions(
${PCL_DEFINITIONS}
)
add_executable(cmake_test cmake_test.cpp)
target_link_libraries(cmake_test
${Boost_LIBRARIES}
${PCL_COMMON_LIBRARIES}
${PCL_IO_LIBRARIES}
${PCL_FILTERS_LIBRARIES}
${PCL_FEATURES_LIBRARIES}
${PCL_GEOMETRY_LIBRARIES}
${PCL_SEGMENTATION_LIBRARIES}
${PCL_SURFACE_LIBRARIES}
${PCL_VISUALIZATION_LIBRARIES}
)
The main issue appears to be that the target link library list now contains multiple references to all boost libs. In fact, for every ${PCL_***_LIBRARIES}
the complete ${Boost_LIBRARIES}
list is added over and over again.
My question is, how could I remove such duplicates that come in as dependencies from third party libraries or if anyone has an idea how to handle this appropriately.
Please keep in mind that I am actually using additional libraries not listed in this CMake (e.g. Qt, VTK), which add further items to the target link list, eventually making it too big for the linker to handle.
Thank you!
list(REMOVE_ITEM <list> <value>)
fordebug
/release
as<value>
, if those unwanted entries in the list cause issues. – Suffolk