Hi Pai, I think that there is an easier way to do this. More exactly: armadillo should not be a target since we don't have to compile anything: we should just be able to specify the library we need to link against and (possibly) a path to the headers and be done.
Have you installed armadillo in a standard location? If so then you should be able to just append TARGET_LINK_LIBRARIES(${TARGET} armadillo) to the end of CMakeLists.txt (after the call to PROJECT and DEAL_II_INVOKE_AUTOPILOT) and things should work correctly. Thanks, David Wells P.S. the CMake module for setting up armadillo looks for a lot of things that don't exist on my computer; I recommend avoiding using FIND_PACKAGE. On Wednesday, May 16, 2018 at 2:54:39 AM UTC-4, Pai Liu wrote: > > Hi all, > > I am learning Step-8 in the tutorial. I want to use the library > "Armadillo" (which is a library for scientific computing and linear > algebra) together with dealii in step-8.cc. > To compile a cpp file that only depends on the Armadillo library, one > needs to excute the following commends at the commend line : "g++ > example.cpp -o example -O2 -larmadillo" > So I replace "mylib" in dealii documentation about modifying > cmakelist.txt with "armadillo", and modify the CMakeList.txt file as the > following > > _____________________________________________________________________ > CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) > > FIND_PACKAGE(deal.II 8.5.0 REQUIRED > HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} > ) > DEAL_II_INITIALIZE_CACHED_VARIABLES() > > PROJECT(myproject) > > ADD_LIBRARY(armadillo) > DEAL_II_SETUP_TARGET(armadillo) > > ADD_EXECUTABLE(mycode step-8.cc) > DEAL_II_SETUP_TARGET(mycode) > > TARGET_LINK_LIBRARIES(mycode armadillo) > _____________________________________________________________________ > > And I got the the following error: > > -- Using the deal.II-8.5.1 installation found at > /home/liu/deal.ii-candi/deal.II-v8.5.1 > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_initialize_cached_variables.cmake > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_setup_target.cmake > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_query_git_information.cmake > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_pickup_tests.cmake > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_add_test.cmake > -- Include macro > /home/liu/deal.ii-candi/deal.II-v8.5.1/share/deal.II/macros/macro_deal_ii_invoke_autopilot.cmake > You have called ADD_LIBRARY for library armadillo without any source > files. This typically indicates a problem with your CMakeLists.txt file > -- Configuring done > CMake Error: Cannot determine link language for target "armadillo". > CMake Error: CMake can not determine linker language for target: armadillo > -- Generating done > -- Build files have been written to: /home/liu/P/homogenization > > > > > > Can anyone help me about this issue about add library? > Many thanks in advance! > > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.