Skip to content

Problem building AMReX as a shared library with CMake on MacOS #425

@RemiLehe

Description

@RemiLehe

When trying to build AMReX as a shared library on MacOS, I am getting a compilation error ; the same error was also reported by @MaxThevenet in off-line discussion.

More precisely, when running:

mkdir builddir
cd builddir
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=ON ..
make install

I get

[100%] Linking CXX shared library libamrex.dylib
Undefined symbols for architecture x86_64:
  "getLevelBld()", referenced from:
      amrex::Amr::InitAmr()    in AMReX_Amr.cpp.o
  "_amrex_probinit", referenced from:
      amrex::Amr::readProbinFile(int&)  in AMReX_Amr.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [Src/libamrex.dylib] Error 1
make[1]: *** [Src/CMakeFiles/amrex.dir/all] Error 2
make: *** [all] Error 2

This error does not occur when compiling AMReX as a static library (i.e. removing -DBUILD_SHARED_LIBS=ON). Also, I am able to build AMReX as a shared library on Ubuntu (as opposed to MacOS).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions