0

I downloaded libboost1.50-all in Raspberry Pi and has successfully compiled and execute a program using threads. Libraries were also found in CMake. I then copied the libraries of the boost and its include from /usr/lib and /usr/include/boost respectively to C:\Boost such that the hierarchy becomes:

C:
  -> Boost
      -> lib
         ... files
      -> include
         -> boost
            ... files

I then used the same CMakeLists.txt and the source code but the library was not found.

NOTE: The cross compiler that I used is fully working and I was able to produce an executable with CMake in Cygwin using the std library. I even specified the location of the library and the user and the root.

Is there anything that I missed out?

cmake_minimum_required(VERSION 2.8)

set(BOOST_ROOT C:/Boost/)
set(BOOST_INCLUDEDIR C:/Boost/include/)
set(BOOST_LIBRARYDIR C:/Boost/lib/)

SET(Boost_DEBUG ON)
find_package(Boost 1.50.0 COMPONENTS thread system)

if (Boost_FOUND)
    include_directories (${Boost_INCLUDE_DIRS})
    add_executable (thread thread.cpp)
    target_link_libraries(thread ${Boost_LIBRARIES})
endif()

enter image description here

Xegara
  • 563
  • 2
  • 10
  • 23
  • Not sure if this is relevant: Could it be that Boost's auto-linking gets in the way? See http://stackoverflow.com/a/9256902/417197 or http://stackoverflow.com/a/6469314/417197. – André Oct 30 '13 at 08:55

2 Answers2

1

Use CMAKE -GUI and then check whether your boost libraries are detected . If not then manually set in the CMAKE-GUI and configure again.

0

TEMPORARY SOLUTION that I was able to come up to!

I placed the boost lib and include to where the cross compiler is installed since the cross compile was able to link the source code to libstdc++.

The library is placed here:

C:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\sysroot\lib

The include files are placed here:

C:\cygwin\opt\cross\x-tools\arm-unknown-linux-gnueabi\arm-unknown-linux-gnueabi\include\c++\4.6.3

The CMakeLists content is as follows now:

cmake_minimum_required(VERSION 2.8)
add_executable (thread main.cpp)
target_link_libraries(thread boost_thread boost_system)

Open Cygwin terminal and invoke cmake there, then make. Viola! It now compiles successfully! :>

The magic lies in here:

target_link_libraries(thread boost_thread boost_system)

I found this in one of the questions here in Stackoverflow where someone said to manually link the libraries..

Even though that it worked, why is it that CMake cannot detect the boost library both in Windows (Cygwin terminal) and Linux (VMware) -- These I tried -- but the library was found in Raspberry Pi (Raspbian) using the same CMakeLists.txt and main.cpp. Isn't it the purpose of CMake is to find the libraries itself? If I were just to link them manually, better do it like this then:

arm-unknown-linux-gnueabi-g++.exe -lboost_thread -lboost_system
Xegara
  • 563
  • 2
  • 10
  • 23