Adding new obj target

52 views
Skip to first unread message

Zachary 42!

unread,
Nov 9, 2020, 11:35:47 AM11/9/20
to dea...@googlegroups.com
Hi folks,

I am trying to add another include/source directory and subsequent obj to dealii for potential future contributions to dealii. Though I am having linking errors because my new obj needs to link agains the lac_obj (need Trilinos and other interfaces). I thought the ADD_DEPENDICIES in the source/CMakeLists.txt file is where this is taking care of but apparently not. I am following the exact same CMakeLists.txt files as in the other source/dirs but I am still getting the undefined symbols error due to object targets not apparently linking together.

[ 80%] Linking CXX shared library ../lib/libdealii.dylib
Undefined symbols for architecture x86_64:
"dealii::PETScWrappers::SparseMatrix::SparseMatrix<int>(int const&, bool)", referenced from:
test::Operator::Operator(int const&) in Operator.cc.o
test::Operator::Operator(int const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Operator.cc.o
ld: symbol(s) not found for architecture x86_64

So looks like the obj_lac needs to link with the obj_test and it doesn’t appear to be…

Here is my source/Test/CMakeLists.txt file which builds fine:

INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})

SET(_src
Operator.cc
)

SET(_n_includes_per_unity_file 20)

IF(DEAL_II_UNITY_BUILD)
LIST(SORT _unity_include_src)
ENDIF()

SETUP_SOURCE_LIST("${_unity_include_src}"
"${_separate_src}"
${_n_includes_per_unity_file}
_src
)

FILE(GLOB _header
${CMAKE_SOURCE_DIR}/include/test/*.h
)

DEAL_II_ADD_LIBRARY(obj_test OBJECT ${_src} ${_header})

I didn’t change anything in the souce/CMakeLists.txt file.

Daniel Arndt

unread,
Nov 9, 2020, 4:49:21 PM11/9/20
to dea...@googlegroups.com
Zachary,

You also need to make sure that CMake actually sees that your new source directory. In particular, you should add a line saying

ADD_SUBDIRECTORY(Test)

to source/CMakeLists.txt.

Best,
Daniel

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/DE13C37A-F916-4295-AE97-685F856C5291%40gmail.com.

Zachary Streeter

unread,
Nov 9, 2020, 5:24:13 PM11/9/20
to deal.II User Group
Ah sorry, yes I have done that already.  Sorry for forgetting that detail...

If it should work assuming I have added my new directory in source/CMakeLists.txt, maybe my implementation is the problem.  Though, I wouldn't know why since it fails at linking.

Wolfgang Bangerth

unread,
Nov 9, 2020, 6:25:30 PM11/9/20
to dea...@googlegroups.com
On 11/9/20 2:49 PM, Daniel Arndt wrote:
>
> Undefined symbols for architecture x86_64:
>   "dealii::PETScWrappers::SparseMatrix::SparseMatrix<int>(int const&, bool)",
> referenced from:

There is no such function -- the linker tells you that, but it's unclear to me
how it is referenced in test::Operator::Operator(int const &).

I think that what is happening is that you are trying to call
template <typename SparsityPatternType>
explicit SparseMatrix(const SparsityPatternType &sparsity_pattern,
const bool preset_nonzero_locations = true);
with an int instead of a sparsity pattern as first argument. That's not going
to work.

Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Zachary Streeter

unread,
Nov 9, 2020, 7:00:12 PM11/9/20
to deal.II User Group
Thanks Wolfgang,

I think you are correct!  I just tried to use petsc_full_matrix instead and it linked no problem!
Reply all
Reply to author
Forward
0 new messages