mardi 22 août 2023

Linker error undefined symbols for arm64 symengine

I'm trying to work with symengine on my Mac, however there is a persistent linking error I'm unable to solve. I installed symengine the "default" way with condo install symengine. I'm trying to compile the following minimal example random.cpp

#include <iostream>
#include <symengine/expression.h>

using SymEngine::Expression;


int main() {
    Expression e("e");
    std::cout << "Defined Expression: " << e << "\n";
    return 0;
};

with clang++ -std=c++11 -I/path/to/symengine/include random.cpp. However, I get the following error telling me that ld is unable to find symbols for my arm64 architecture:

Undefined symbols for architecture arm64:
  "SymEngine::Expression::Expression(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in random-79496f.o
  "SymEngine::Basic::__str__() const", referenced from:
      SymEngine::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, SymEngine::Expression const&) in random-79496f.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After a google search I tried to compile with -stdlib=libc++, but the error persists. -v gives the following additional output:

"/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 13.0.0 13.1 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o a.out -L/usr/local/lib /var/folders/58/n0sq8txx0bn1cz6w6kxzyh500000gn/T/random-79496f.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a

For me it seems that the linker cannot find the right library, but I'm not quite sure what the error message tells me. Any help is very much appreciated!

Aucun commentaire:

Enregistrer un commentaire