Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake error: common is required but boost was not found

Tags:

c++

boost

cmake

qt

I'm trying to compile opencv_2.4.9 with cmake_3.5.0 to run a project in Qt_5.3.2 MinGW and it keeps showing this error:

Common needed but can't find boost

I choose "MinGW Makefiles" as generator and "specify native compilers" in configure window. I defined BOOST_ROOT environmental variable and this is my CmakeLists.txt:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

SET(sampleName MyApp)

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
set(Boost_COMPILER -gcc49)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Program Files/PCL 1.6.0/3rdParty/Boost/include")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/Program Files/PCL 1.6.0/3rdParty/Boost/lib")

find_package(PCL 1.6.0 REQUIRED)
FIND_PACKAGE(Boost)
IF (Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
    ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()

FIND_PACKAGE(MRPT REQUIRED base;bayes;obs;gui)

include_directories(${PCL_INCLUDE_DIRS})
include_directories("C:/Program Files/PCL 1.6.0/3rdParty/Boost/include")

link_directories(${PCL_LIBRARY_DIRS})
link_directories("C:/Program Files/PCL 1.6.0/3rdParty/Boost/lib")

add_definitions(${PCL_DEFINITIONS})

add_executable (MyApp Local.cpp part.h grab.h interface.h test.cpp test.h)

target_link_libraries (MyApp ${PCL_LIBRARIES} libeng.lib libmx.lib libmex.lib libmat.lib Aria.lib winmm.lib wsock32.lib)

TARGET_LINK_LIBRARIES(${sampleName}
${MRPT_LIBS} # This is filled by FIND_PACKAGE(MRPT ...)
"" # Optional extra libs...
)

Does anyone know what solves this error?

like image 382
Hadi GhahremanNezhad Avatar asked Nov 09 '22 17:11

Hadi GhahremanNezhad


1 Answers

So what I did to solve this was first run Cmake as

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcd_write)
set(Boost_DEBUG ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcd_write pcd_write.cpp)
target_link_libraries (pcd_write ${PCL_LIBRARIES})

And towards the bottom I saw

Boost include path: C:/Program Files/PCL 1.6.0/3rdParty/Boost/include
Could not find the following static Boost libraries:
    boost_system
    boost_filesystem
    boost_thread
    boost_date_time
    boost_iostreams

I looked in that folder and sure enough I was missing the boost folders for them all.

There might be a better solution, but I just downloaded the latest version of Boost to my computer and replaced the entire C:/Program Files/PCL 1.6.0/3rdParty/Boost folder with the new one and everything worked for me

like image 189
FrickeFresh Avatar answered Nov 14 '22 22:11

FrickeFresh