[Insight-users] Fwd: using boost with ITK

Mike Jackson mike.jackson at bluequartz.net
Sun Jan 17 09:32:56 EST 2010


Ok, ditch the if ( NOT MXA_BOOST_HEADERS_ONLY) and endif().
 Replace with just the
set (MXA_BOOST_COMPONENTS program_options file_system system)
line.

Also, are you starting with a CLEAN build directory to test this? It
is highly recommended at this point. If CMake does not find Boost the
first time through then something is wrong. Did you try setting the
Boost_DEBUG to ON and investigating any additional output that cmake
produces?
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net

On Sat, Jan 16, 2010 at 2:19 PM, Mark Roden <mmroden at gmail.com> wrote:
> OK, this still isn't working for me.  I can get regular boost, but not
> the boost filesystem library.
>
> My CMakeLists.txt:
>
> # ---------- Find Boost Headers/Libraries -----------------------
> SET (Boost_FIND_REQUIRED TRUE)
> SET (Boost_FIND_QUIETLY TRUE)
> set (Boost_USE_MULTITHREADED TRUE)
> set (Boost_USE_STATIC_LIBS TRUE)
> SET (Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0" "1.39" "1.39.0")
>
>
> if ( NOT MXA_BOOST_HEADERS_ONLY)
>  set (MXA_BOOST_COMPONENTS program_options file_system system)
> endif()
>
> FIND_PACKAGE(Boost COMPONENTS  ${MXA_BOOST_COMPONENTS} )
> INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
> LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
>
> Also, as a system variable,
> BOOST_ROOT = C:\developer\i386\boost_1_40
>
> I built it into that directory using the command:
>
> bjam.exe toolset=msvc-9.0 --with-test --with-filesystem
> --with-program_options --with-date_time --with-thread
> --prefix=C:\Developer\i386\boost_1_40 variant=release,debug
> threading=multi link=static runtime-link=shared install
>
> with a bjam.exe that was put in the c:\developer\vs9\boost_1_40
> directory, where I had previously unzipped the boost redistributables.
>
> The problem is that the filesystem is still not being found.  The
> Boost_LIBRARY_DIRS points to C:/Developer/i386/boost_1_40/lib, which
> is where both libboost_filesystem-vc90-mt-1_40.lib and
> libboost_filesystem-vc90-mt-gd-1_40.lib are sitting.  However,
> Boost_FILE_SYSTEM_LIBRARY_DEBUG and Boost_FILE_SYSTEM_LIBRARY_RELEASE
> are both pointing to NOTFOUND, and setting those libraries explicitly
> causes them to still be not found and the paths in CMake to reset
> themseves to Not Found, even after I explicitly set them.
>
> If I remove the file_system from the MXA_BOOST_COMPONENTS variable in
> the CMakeLists.txt file, then the CMake build works fine, but I can't
> use boost::filesystem (which makes sense).
>
> What am I doing wrong?  How can I get the boost filesystem into my
> code using cmake?
>
> Also, once I get this to work, I should be able to call the filesystem
> stuff exactly as I would according to the tutorials, right?  That is,
>
> #include "boost/filesystem.hpp"   // includes all needed
> Boost.Filesystem declarations
> #include <iostream>               // for std::cout
> using boost::filesystem;          // for ease of tutorial presentation;
>                                  //  a namespace alias is preferred
> practice in real code
> (from http://www.boost.org/doc/libs/1_40_0/libs/filesystem/doc/index.htm)
>
> Thanks,
> Mark
>
> On Wed, Jan 13, 2010 at 4:39 PM, Michael Jackson
> <mike.jackson at bluequartz.net> wrote:
>> Just depends on what bug fixes you need from the later versions of boost. If
>> 1.40 was working for you then by all means, drop back to that version. I am
>> about to drop back to 1.36 personally.
>>
>> To try and diagnose the problem add SET(Boost_DEBUG 1) just before the call
>> to "find_package(Boost ... ). Do that on a clean build directory.
>>
>>  Post the relevant sections of the output that deal with boost and post the
>> names of your boost libraries and where they are installed. It might help
>> you "see" what might be going wrong.
>>
>> _________________________________________________________
>> Mike Jackson                  mike.jackson at bluequartz.net
>> BlueQuartz Software                    www.bluequartz.net
>> Principal Software Engineer                  Dayton, Ohio
>>
>> On Jan 13, 2010, at 6:28 PM, Mark Roden wrote:
>>
>>> Hi Mike,
>>>
>>> Thanks for the help, but I'm still getting the same behavior.  I'm
>>> going back to version 1.40, unless there's some compelling reason to
>>> keep banging my head against the wall.
>>>
>>> Mark
>>>
>>> On Wed, Jan 13, 2010 at 11:50 AM, Michael Jackson
>>> <mike.jackson at bluequartz.net> wrote:
>>>>
>>>> the libraries should be in C:/Developer/i386/boost_1_41/lib and not in
>>>> stage. FindBoost expects and "Install" of boost.
>>>>
>>>> This is the command I use to compile and install boost on Windows 7 x64,
>>>> Visual Studio 9 from a "Visual Studio 32 bit" command prompt:
>>>>
>>>> This assumes that "bjam.exe" is on your path somewhere.
>>>>
>>>> bjam.exe toolset=msvc-9.0 --with-test --with-filesystem
>>>> --with-program_options --with-date_time --with-thread
>>>> --prefix=C:\Developer\VS9\boost_1_41 variant=release,debug
>>>> threading=multi
>>>> link=static runtime-link=shared install
>>>>
>>>>
>>>> Adjust as necessary for your tastes (like adding the file_system AND
>>>> system
>>>> libraries).
>>>> --
>>>> Mike
>>>>
>>>> On Jan 13, 2010, at 2:42 PM, Mark Roden wrote:
>>>>
>>>>> Hi Mike,
>>>>>
>>>>> I'm further along, but I'm now getting this error:
>>>>>
>>>>> The following Boost libraries could not be found:
>>>>>
>>>>>        boost_file_system
>>>>>
>>>>> I've followed your instructions exactly.  I'm not sure why the
>>>>> filesystem libraries aren't found; they're in the stage directory.
>>>>> I've tried setting the filesystem directories like so:
>>>>>
>>>>>
>>>>>
>>>>> debug:C:/Developer/i386/boost_1_41/stage/lib/libboost_filesystem-vc90-mt-gd-1_41.lib
>>>>> release:
>>>>>
>>>>> C:/Developer/i386/boost_1_41/stage/lib/libboost_filesystem-vc90-mt-1_41.lib
>>>>>
>>>>> However, the error shows up again and the directories get reset.  Any
>>>>> ideas?
>>>>>
>>>>> Thanks,
>>>>> Mark
>>>>> On Wed, Jan 13, 2010 at 10:06 AM, Michael Jackson
>>>>> <mike.jackson at bluequartz.net> wrote:
>>>>>>
>>>>>> This is what I do when using boost:
>>>>>>
>>>>>> I install boost into C:\Developer\i386\boost_1_41
>>>>>>
>>>>>> The naming on that is VERY important as that is the directory that
>>>>>> FindBoost.cmake looks for on Windows.
>>>>>>
>>>>>> Now, in your CMakeLists.txt file I have the following:
>>>>>> # ---------- Find Boost Headers/Libraries -----------------------
>>>>>> SET (Boost_FIND_REQUIRED TRUE)
>>>>>> SET (Boost_FIND_QUIETLY TRUE)
>>>>>> set (Boost_USE_MULTITHREADED TRUE)
>>>>>> set (Boost_USE_STATIC_LIBS TRUE)
>>>>>> SET (Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0" "1.39" "1.39.0")
>>>>>>
>>>>>>
>>>>>> if ( NOT MXA_BOOST_HEADERS_ONLY)
>>>>>>  set (MXA_BOOST_COMPONENTS program_options )
>>>>>> endif()
>>>>>>
>>>>>> FIND_PACKAGE(Boost COMPONENTS  ${MXA_BOOST_COMPONENTS} )
>>>>>> INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
>>>>>> LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
>>>>>>
>>>>>>
>>>>>> And lastly in my environment I have the following set:
>>>>>>
>>>>>> BOOST_ROOT=C:\Developer\i386\boost_1_41
>>>>>>
>>>>>> Then from a clean build directory I can run cmake to configure my
>>>>>> project.
>>>>>> These settings work for my systems (Windows 7 x64, Visual Studio 9) and
>>>>>> OS X
>>>>>> 10.5 and Linux Ubuntu 09.10. YMMV
>>>>>>
>>>>>> Hope that helps
>>>>>> _________________________________________________________
>>>>>> Mike Jackson                  mike.jackson at bluequartz.net
>>>>>>
>>>>>>
>>>>>> On Jan 13, 2010, at 12:49 PM, Mathieu Malaterre wrote:
>>>>>>
>>>>>>> [better on cmake mailing list]
>>>>>>>
>>>>>>> On Wed, Jan 13, 2010 at 6:44 PM, Mark Roden <mmroden at gmail.com> wrote:
>>>>>>>>
>>>>>>>> Hi Mike,
>>>>>>>>
>>>>>>>> I've downloaded Boost 1.41 and run the bootstrap.bat file to build it
>>>>>>>> on Windows.
>>>>>>>>
>>>>>>>> With CMake 2.8, I get the error:
>>>>>>>> Could NOT find Boost
>>>>>>>>
>>>>>>>> after I set boost_INCLUDE_DIR to be where I downloaded the boost
>>>>>>>> libraries.  Additionally, the other parameters (debug and release
>>>>>>>> versions of the filesystem and system libraries) automatically reset
>>>>>>>> to blank when that error shows up.
>>>>>>>>
>>>>>>>> What am I missing?
>>>>>>>
>>>>>>>
>>>>>>> $ cmake --help-module FindBoost
>>>>>>> ...
>>>>>>>
>>>>>>>  Currently this module searches for the following version numbers:
>>>>>>>    1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
>>>>>>>    1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
>>>>>>> 1.40,
>>>>>>>    1.40.0
>>>>>>> ...
>>>>>>>  These last three variables are available also as environment
>>>>>>>    variables:
>>>>>>>
>>>>>>>       BOOST_ROOT or BOOSTROOT      The preferred installation
>>>>>>> prefix for searching for
>>>>>>>                                    Boost.  Set this if the module
>>>>>>> has problems finding
>>>>>>>                                    the proper Boost installation.
>>>>>>>
>>>>>>> ...
>>>>>>>
>>>>>>>
>>>>>>> what this means is that 1.41 is not a 'known' version. Either get
>>>>>>> FindBoost from CMake CVS or use BOOST_ROOT.
>>>>>>>
>>>>>>> 2cts
>>>>>>> --
>>>>>>> Mathieu
>>>>>>> _____________________________________
>>>>>>> Powered by www.kitware.com
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at
>>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>>
>>>>>>> Kitware offers ITK Training Courses, for more information visit:
>>>>>>> http://www.kitware.com/products/protraining.html
>>>>>>>
>>>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>>>
>>>>>>
>>>>
>>>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>


More information about the Insight-users mailing list