[Dune] Problem linking boost with cmake

Aleksejs Fomins aleksejs.fomins at lspr.ch
Mon Dec 1 11:33:47 CET 2014


It worked, thank you

On 12/01/2014 10:50 AM, Markus Blatt wrote:
> Hi,
> 
> On Mon, Dec 01, 2014 at 10:04:30AM +0100, Aleksejs Fomins wrote:
>> I am sorry to post on a very similar issue that was already largely
>> discussed, but I can't make it work by using the previous suggestions.
>>
>> I have:
>> * Specified boost libraries in the opts file
>> * written find_package(Boost 1.55.0 COMPONENTS system) in the cmake
>> macros file
>> * written target_link_libraries(curvilineargmshtest ${Boost_LIBRARIES})
>> in the CMakeLists.txt file.
>>
>> The boost library is found by dunecontrol, but no flags are passed to
>> the compilation of the target.
>>
>> I appreciate your suggestions,
> 
>>  build directory: build-cmake
>> make 
>> [ 50%] Built target dune_curvilineargrid
>> [100%] Building CXX object dune/curvilineargrid/io/file/test/CMakeFiles/curvilineargmshtest.dir/curvilineargmshtest.cc.o
>> In file included from /home/fomins/gitwork/hades-github-lspr-ag/dune-curvilineargrid/dune/curvilineargrid/io/file/curvilineargmshreader.hh:44:0,
>>                  from /home/fomins/gitwork/hades-github-lspr-ag/dune-curvilineargrid/dune/curvilineargrid/io/file/test/curvilineargmshtest.cc:43:
>> /home/fomins/gitwork/hades-github-lspr-ag/dune-curvilineargrid/dune/curvilineargrid/feedback/loggingmessage.hh:16:53: fatal error: boost/date_time/posix_time/posix_time.hpp: No such file or directory
>>  #include <boost/date_time/posix_time/posix_time.hpp>
>>                                                      ^
>> compilation terminated.
>> make[2]: *** [dune/curvilineargrid/io/file/test/CMakeFiles/curvilineargmshtest.dir/curvilineargmshtest.cc.o] Error 1
>> make[1]: *** [dune/curvilineargrid/io/file/test/CMakeFiles/curvilineargmshtest.dir/all] Error 2
>> make: *** [all] Error 2
> 
> As you can see from the error message a boost header is not
> found. Which means that an include path is missing. You can see how to
> specify by using CMake's documentation, e.g. "cmake --help-module FindBoost":
> 
> cmake version 2.8.9
>   FindBoost
>        Try to find Boost include dirs and libraries
> 
>        Usage of this module as follows:
> 
>        NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable
>        below.  Due
>        to Boost naming conventions and limitations in CMake this find
>        module
>        is NOT future safe with respect to Boost version numbers, and
>        may
>        break.
> 
>        == Using Header-Only libraries from within Boost: ==
> 
>           find_package( Boost 1.36.0 )
>           if(Boost_FOUND)
>              include_directories(${Boost_INCLUDE_DIRS})
>              add_executable(foo foo.cc)
>           endif()
> 
>        
> 
>        
> 
>        == Using actual libraries from within Boost: ==
> 
>           set(Boost_USE_STATIC_LIBS        ON)
>           set(Boost_USE_MULTITHREADED      ON)
>           set(Boost_USE_STATIC_RUNTIME    OFF)
>           find_package( Boost 1.36.0 COMPONENTS date_time filesystem
> 	  system ... )
> 
>        
> 
>           if(Boost_FOUND)
>              include_directories(${Boost_INCLUDE_DIRS})
>              add_executable(foo foo.cc)
>              target_link_libraries(foo ${Boost_LIBRARIES})
>           endif()
> ...
> 
> So you have to add the include directory as above.
> 
> Markus
> 
> 
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20141201/86b0c68f/attachment.sig>


More information about the Dune mailing list