Skip to content

Undefined symbol on MacOS with strict linking #206

Closed
@jeroen

Description

@jeroen

Compiling on MacOS without the -undefined dynamic_lookup linker flag reveals an undefined symbol. You can test this like so:

sed -i.bak 's/-undefined dynamic_lookup//g' $(R RHOME)/etc/Makeconf

And then installing from source will fail:

** configured file: 'R/tbb-autodetected.R.in' => 'R/tbb-autodetected.R'
  *** configured file: 'src/install.libs.R.in' => 'src/install.libs.R'
  *** configured file: 'src/Makevars.in' => 'src/Makevars'
  ** finished configure for package 'RcppParallel'
  ** libs
  using C++ compiler: ‘Apple clang version 14.0.0 (clang-1400.0.29.202)’
  using SDK: ‘’
  (tbb) Building TBB using bundled sources ...
  OS: macos
  arch=intel64
  compiler=clang
  runtime=cc14.0.0_os12.7.2
  tbb_build_prefix=macos_intel64_clang_cc14.0.0_os12.7.2
  work_dir=/private/var/folders/qv/pdh5wsgn0lq3dp77zj602b5c0000gn/T/RtmpXzRtgl/R.INSTALL3d205139f0cb/RcppParallel/src/build/macos_intel64_clang_cc14.0.0_os12.7.2_release
  (tbb) TBB compilation finished successfully.
  clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include  -I/opt/R/x86_64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2  -c init.cpp -o init.o
  clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include  -I/opt/R/x86_64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2  -c options.cpp -o options.o
  clang++ -arch x86_64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o RcppParallel.so init.o options.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
  Undefined symbols for architecture x86_64:
    "tbb::interface7::internal::task_arena_base::internal_max_concurrency(tbb::interface7::task_arena const*)", referenced from:
        _defaultNumThreads in options.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [RcppParallel.so] Error 1
  ERROR: compilation failed for package ‘RcppParallel’

This is important when cross compiling (for example on p3m), otherwise the resulting binary cannot be loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions