Symbol lookup error

Hi all,

I am trying to write a specific rheological creep law for my research, and I put the .h and .cc file in the include/material_model/rheology and source/material_model/rheology folder, respectively.

Like any other file, the .cc file ends with a MACRO command, like:

namespace aspect
{
namespace MaterialModel
{
#define INSTANTIATE(dim) \
namespace Rheology \
{ \
template class TestRheology; \
}

ASPECT_INSTANTIATE(INSTANTIATE)

#undef INSTANTIATE
}
}

I’ve referenced this file in other file, and it looked like the syntax check was ok. Finally, there was an error like this:

…/…/build/aspect: symbol lookup error: ./libTest.so: undefined symbol: _ZN6aspect13MaterialModel8Rheology30TestRheologyILi2EEC1Ev

Any ideas to solve this problem ?

Best,
Xie

Why is there a .so file? If you add new files to include/ and source/ you just need to run cmake and make in the build directory of ASPECT.

You can check using c++filt _ZN6aspect13MaterialModel8Rheology30TestRheologyILi2EEC1Ev what symbol is behind this cryptic (“mangled”) name. You will need to implement it. I assume your constructor is not implemented in your cc file.

Hi Timo,

Thanks for replying,

the .so is a plugin that I wrote, I tried to run cmake and make in the build folder, and this time I got an error like:

In file included from /home/chris/ASPECT/aspect/build/CMakeFiles/aspect.dir/Unity/unity_14_cxx.cxx:6:
/home/chris/ASPECT/aspect/source/material_model/rheology/TestRheology.cc:18:4: error: redeclaration of ‘const aspect::MaterialModel::Rheology::TestRheologyParameters aspect::MaterialModel::Rheology::TestRheology::compute_creep_parameters(unsigned int, const std::vector<double, std::allocator >&, const std::vector&) const’ may not have default arguments [-fpermissive]
18 | TestRheology::compute_creep_parameters(const unsigned int composition,
| ^~~~~~~~~~~~~~~~~~~
In file included from /home/chris/ASPECT/aspect/build/CMakeFiles/aspect.dir/Unity/unity_14_cxx.cxx:6:
/home/chris/ASPECT/aspect/source/material_model/rheology/TestRheology.cc:53:11: error: redeclaration of ‘double aspect::MaterialModel::Rheology::TestRheology::compute_viscosity(double, double, unsigned int, const std::vector<double, std::allocator >&, const std::vector&) const’ may not have default arguments [-fpermissive]
53 | double TestRheology::compute_viscosity(const double strain_rate_II,
| ^~~~~~~~~~~~~~~~~~~
/home/chris/ASPECT/aspect/source/material_model/rheology/TestRheology.cc:91:11: error: redeclaration of ‘double aspect::MaterialModel::Rheology::TestRheology::get_reference_viscosity_dislocation(unsigned int, const std::vector<double, std::allocator >&, const std::vector&) const’ may not have default arguments [-fpermissive]
91 | double TestRheology::get_reference_viscosity(const unsigned int composition,
| ^~~~~~~~~~~~~~~~~~~
/home/chris/ASPECT/aspect/source/material_model/rheology/TestRheology.cc:136:9: error: redeclaration of ‘void aspect::MaterialModel::Rheology::TestRheology::parse_parameters(dealii::ParameterHandler&, const std::shared_ptr<std::vector >&)’ may not have default arguments [-fpermissive]
136 | void TestRheology::parse_parameters(ParameterHandler &prm,

Sorry for the typographical mess, but it looks like these errors all involve a keyword: redeclaration

This makes me confused.

Best,
Xie

TestRheology.cc:18:4: error: redeclaration of ‘…’ may not have default arguments [-fpermissive]

You are not allowed to specify default arguments in the lines mentioned. Just remove those.

Sorry, I don’t get it, what do you mean “just remove those” ?

Best,
Xie

Xie,
if you have
class X {
void f(int i=4);
};

void X::f(int i=4) {...}

then the compiler will complain about the fact that you provide a default value (the “=4”) for argument “i” in the definition (the last line) when you have already done so in the declaration (line 2). C++ just doesn’t allow that. You have to pick one place or the other, but not both.

Best
W.

Thanks, the problem has been solved.

Best,
Xie