简体   繁体   中英

CMake error: common is required but boost was not found

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?

First of all, you can put

set(Boost_DEBUG ON)

before the command

FIND_PACKAGE(Boost)

This gives you some more output and helped me to find the source of other errors.

Next, I would try to set the variables BOOST_LIBRARYDIR and BOOST_INCLUDEDIR , eg

set(BOOST_LIBRARYDIR "C:/Program Files/PCL 1.6.0/3rdParty/Boost/lib")
set(BOOST_INCLUDEDIR "C:/Program Files/PCL 1.6.0/3rdParty/Boost/include")

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM