[CMake] help with FindBoost.cmake

kdsfinger at gmail.com kdsfinger at gmail.com
Sat Mar 31 11:27:37 EST 2007


On 3/31/07, Tristan Carel <tristan.carel at gmail.com> wrote:
> On 3/31/07, kdsfinger at gmail.com <kdsfinger at gmail.com> wrote:
> > On 3/31/07, Filipe Sousa <natros at gmail.com> wrote:
> > > kdsfinger at gmail.com wrote:
> > > > hi,
> > > > I am using cmake and some library of boost on a linux box. When I use
> > > > the boost::shared_ptr, everything is fine. But when I try to
> > > > #include <boost/filesystem/operations.hpp>
> > > > #include <boost/filesystem/path.hpp>,
> > > > the cmake generates lots of "undefined reference to
> > > > 'boost::filesystem::...' errors. Is there something wrong with the
> > > > FindBoost.cmake? Why I still can use part of the boost like
> > > > boost::shared_ptr? Thanks for help.
> > > > zl2k
> > >
> > > most of boost are header files only, but boost filesystem has it's own
> > > library that you must link against you program. that's why you have
> > > undefined references.
> > >
> > > Filipe Sousa
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > CMake mailing list
> > > CMake at cmake.org
> > > http://www.cmake.org/mailman/listinfo/cmake
> > >
> > >
> >
> > Could you give me more guidance on how to do that? Do I need to change
> > the FindBoost.cmake so that let it find the boost/filesystem? Or
> > should I change the CMakeList.txt? Thanks again.
>
> You don't have to change the module. The comments at the beginning of
> the module tells you that 2 variables have been set by the module
> itself: ${Boost_INCLUDE_DIRS} and ${Boost_LIBRARY_DIRS}. It means that
> the module is in charge to set these 2 variables, and you are the guy
> who has to use them:)
>
> Here is an example of CMakeLists.txt t to compile the `simple_ls.cc'
> available in the boost filesystem documentation.
> --------------------------------------------------
> PROJECT(TestBoost)
> FIND_PACKAGE(Boost)
>
> INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
> LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
>
> ADD_EXECUTABLE(myls simple_ls.cc)
> TARGET_LINK_LIBRARIES(myls boost_filesystem)
> --------------------------------------------------
>
> the critical point is, as said Filipe above, the library must be
> linked against the program, that is what the `TARGET_LINK_LIBRARIES'
> does.
>
> bye
> --
> Tristan Carel
> Music with dinner is an insult both to the cook and the violinist.
> http://www.tristan-carel.com
>

Thank you guys, it's now working great.
zl2k


More information about the CMake mailing list