[Dune] cmake build, how to specify non-standard libraries

Benedikt Oswald benedikt.oswald at lspr.ch
Tue Nov 25 10:54:10 CET 2014


Hi Markus, thanks, I now do:


CONFIGURE_FLAGS="--enable-parallel --enable-experimental-grid-extensions
CC=mpicc CXX=mpicxx "

CMAKE_PREFIX_PATH="\
$HOME/extlib/boost/1.55.0/gcc/4.8.1;\
$HOME/extlib/parmetis/4.0.3/openmpi/1.6.5/gcc/4.8.1;\
$HOME/extlib/metis/5.1.0/gcc/4.8.1;\
"


CMAKE_FLAGS="\
-DCXXFLAGS=\"-O2 -Wall\" \
-DCMAKE_PREFIX_PATH=\"$CMAKE_PREFIX_PATH\" \
-DCMAKE_LIBRARY_PATH:RELEASE=\"$HOME/extlib/boost/1.55.0/gcc/4.8.1/lib\" \
-DCMAKE_LIBRARY_PATH:DEBUG=\"$HOME/extlib/boost/1.55.0/gcc/4.8.1/lib\" \
-DCMAKE_STANDARD_LIBRARIES:RELEASE=\"-lboost_system\" \
-DCMAKE_STANDARD_LIBRARIES:DEBUG=\"-lboost_system\" \
-DDUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS:BOOL=TRUE \
"
 
 
in my opts files, but unfortunately, the library boost_system is not
picked up, since:

Scanning dependencies of target gpfreadertest
[ 66%] Building CXX object
gpf/test/CMakeFiles/gpfreadertest.dir/gpfreadertest.cc.o
Linking CXX executable gpfreadertest
Undefined symbols for architecture x86_64:
  "boost::system::system_category()", referenced from:
      __static_initialization_and_destruction_0(int, int) in
gpfreadertest.cc.o
  "boost::system::generic_category()", referenced from:
      __static_initialization_and_destruction_0(int, int) in
gpfreadertest.cc.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [gpf/test/gpfreadertest] Error 1
make[1]: *** [gpf/test/CMakeFiles/gpfreadertest.dir/all] Error 2
make: *** [all] Error 2
--- Failed to build vulcain ---
Terminating dunecontrol due to previous errors!


in the CMakeLIsts.txt file for the respective 'gpfreadertest' executable
I use:

link_libraries(${DUNE_Boost_LIBRARIES})
include_directories(${Boost_INCLUDE_DIR})


add_executable("gpfreadertest" gpfreadertest.cc)
target_link_libraries("gpfreadertest" ${DUNE_LIBS}
${LINK_ALL_BOOST_LIBRARIES} ${DUNE_Boost_LIBRARIES})
add_dune_mpi_flags(gpfreadertest)


this is probably not correct ?

Thanks & greetings, Benedikt








Am 24/11/14 um 18:28 schrieb Markus Blatt:
> Hi Benedikt,
>
> On Mon, Nov 24, 2014 at 05:10:46PM +0100, Benedikt Oswald wrote:
>> Dear Dune,
>>
>> one question regarding linking non-standard libraries, say boost.
>> How would I specify them via the cmake opts files ?
>>
>> Someting like this?
>>
>> USE_CMAKE=yes
>>
>> on the other hand, I understand that in the CMAKE_PREFIX_PATH I specify
>> the base directories,
>> but still I need to tell it which specific boost libraries need to be
>> linked.
>>
> This is just for find_package.
>
>
> I suppose you mean passing these libraries to cmake similiar to
> LDFLAGS and LD_LIBRARIES?
>
> If that is not the case, please tell us how you did this with
> autotools.
>
> You might want to check out the following variables:
>
> mblatt at boromir:~$ cmake --help-variable CMAKE_STANDARD_LIBRARIES
> cmake version 2.8.9
>   CMAKE_STANDARD_LIBRARIES
>        Libraries linked into every executable and shared library.
>
>        This is the list of libraries that are linked into all
>        executables and
>        libraries.
>
> mblatt at boromir:~$ cmake --help-variable CMAKE_LIBRARY_PATH
> cmake version 2.8.9
>   CMAKE_LIBRARY_PATH
>        Path used for searching by FIND_LIBRARY().
>
>        Specifies a path which will be used by FIND_LIBRARY().
>        FIND_LIBRARY()
>        will check each of the contained directories for the existence
>        of the
>        library which is currently searched.  By default it is empty,
>        it is
>        intended to be set by the project.  See also
>        CMAKE_SYSTEM_LIBRARY_PATH, CMAKE_PREFIX_PATH.
>
>
>
> But of course the more usual way would be to use find_package to find
> these in your module and specify them via link_libraries. For boost,
> see
>
> cmake --help-module FindBoost
>
> Cheers,
>
> Markus
>
>

-- 
------------------------------------------------------------------------------------------------
Dr. sc. techn. Benedikt Oswald - first engineer - LSPR AG - phone - +41 43 366 90 74
Technoparkstrasse 1, CH-8005 Zürich, benedikt.oswald at lspr.ch - labor vincit omnia improbus
------------------------------------------------------------------------------------------------


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


More information about the Dune mailing list