[CMake] Linking Boost on Linux on 64bit host and 32bit target
Michael Jackson
mike.jackson at bluequartz.net
Thu Nov 4 12:31:12 EDT 2010
Clean out your build folder first.
export BOOST_ROOT=/home/kknox/sdk/boost_1_44_0
==> that needs to be an actual "installation", a staged area will
probably NOT work to find boost as FindBoost is looking for a very
specific path within BOOST_ROOT and if that path is NOT found then it
will probably fall back on the system paths.
Also.
put the following in your CMakeLists.txt file after you try to find
boost:
message(STATUS "Boost_PROGRAM_OPTIONS_LIBRARY: $
{Boost_PROGRAM_OPTIONS_LIBRARY}")
You should get the absolute path to the boost program_options library.
For example is a project I have I get the following:
Boost_THREAD_LIBRARY /Users/Shared/Toolkits/MXABoost-1.44/
lib/libboost_thread-mt.a
Boost_THREAD_LIBRARY_DEBUG /Users/Shared/Toolkits/MXABoost-1.44/
lib/libboost_thread-mt-d.a
Boost_THREAD_LIBRARY_RELEASE /Users/Shared/Toolkits/MXABoost-1.44/
lib/libboost_thread-mt.a
where my BOOST_ROOT=/Users/Shared/Toolkits/MXABoost-1.44
HTH
___________________________________________________________
Mike Jackson www.bluequartz.net
Principal Software Engineer mike.jackson at bluequartz.net
BlueQuartz Software Dayton, Ohio
On Nov 4, 2010, at 11:47 AM, Knox, Kent wrote:
> Hi Adam~
>
> [Adam]
> Are you sure this logic is right? It looks very odd. Does CMake set
> WIN32 for a 64-bit Windows toolchain? Didn't you say you were
> building on Linux?
>
> [Kent]
> My software compiles cross platform, and we support windows too.
> WIN32 is set for 64bit platforms. I do have the windows build
> compiling properly with boost. I'm specifically having problems
> with linux.
>
> [Adam]
> You don't set ADDITIONAL_VERSIONS. That's probably not the problem.
> IIRC, it's:
> set(Boost_ADDITIONAL_VERSIONS "1.44 1.44.0")
>
> [Kent]
> I did not originally set Boost_ADDITIONAL_VERSIONS. I did set it
> now, and ran a clean recompile, but no change. My Boost_LIBRARIES
> still came out as:
> -- Boost_LIBRARIES: /usr/lib/libboost_program_options-mt.a
>
> Even though I've specified BOOST_LIBRARYDIR as:
> BOOST_LIBRARYDIR = /home/kknox/sdk/boost_1_44_0/stage/lib
>
> Kent
>
> -----Original Message-----
> From: Adam J Richardson [mailto:fatman at crackmonkey.us]
> Sent: Thursday, November 04, 2010 4:56 AM
> To: Knox, Kent
> Cc: cmake at cmake.org
> Subject: Linking Boost on Linux on 64bit host and 32bit target
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thu, 04 Nov 2010 04:35:57 -0400
> cmake-request at cmake.org wrote:
>> Hi all~
>
> Hi Kent.
>
>> I have a project using Boost that should compile for both 64bit and
>> 32bit on a 64bit host. This works fine for a 64bit target, but I
>> can't get this to work for a 32bit target.
>
> I'm having problems linking Boost too. But enough about me.
>
>> In order to compile for 32bit on a 64bit host, I have a -D parameter
>> called BUILD64. Here is my logic to initialize this var:
>>
>> if( WIN32 )
>> set( BUILD64 ${CMAKE_CL_64} )
>> else()
>> option( BUILD64 "Build a 64-bit product" OFF )
>> if( BUILD64 )
>> message( STATUS "64-bit build" )
>> endif( )
>> endif()
>
> Are you sure this logic is right? It looks very odd. Does CMake set
> WIN32 for a 64-bit Windows toolchain? Didn't you say you were
> building on Linux?
>
>> The syntax for finding boost is thus:
>> set( Boost_USE_MULTITHREADED ON )
>> set( Boost_USE_STATIC_LIBS ON )
>> set( Boost_DETAILED_FAILURE_MSG ON )
>> # set( Boost_DEBUG ON )
>> find_package( Boost 1.33.0 COMPONENTS program_options )
>
> You don't set ADDITIONAL_VERSIONS. That's probably not the problem.
> IIRC, it's:
>
> set(Boost_ADDITIONAL_VERSIONS "1.44 1.44.0")
>
> ... if you wanted to try it anyway.
>
> Regards,
> Adam J Richardson
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkzSgx0ACgkQSUH6dLOqvqmfKwCg6qttDVOXnpqHYoZwfjzUyHax
> ubMAniQAF6EYxsIUYkqXPQiMwFxop6uB
> =ngaQ
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list