ut icon indicating copy to clipboard operation
ut copied to clipboard

Linker error when using `should` and compiling as a module

Open Volper212 opened this issue 3 years ago • 0 comments

Expected Behavior

Compilation without any error.

Actual Behavior

/usr/bin/ld: /tmp/main-566205.o: in function `main::$_0::operator()() const':
main.cpp:(.text+0x198): undefined reference to `boost::ext::ut::v1_1_8::should'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to Reproduce the Problem

  1. Paste the module to a new file called ut.cpp
  2. Compile the module into boost.ut.pcm:
  clang++ -std=c++20 -stdlib=libc++ -D __cpp_modules -c -fmodules -Xclang -emit-module-interface -o boost.ut.pcm ut.cpp
  1. Paste the following into a new file called main.cpp:
import boost.ut; // It works when I do #include "ut.cpp" tho

int main() {
    using namespace boost::ut;
    "test"_test = [] {
        should("work") = [] {};       
    };
}
  1. Build main.cpp:
clang++ -std=c++20 -stdlib=libc++ -fmodules -fprebuilt-module-path=. main.cpp

Specifications

  • Version: Latest, copied directly from Github
  • Platform: Arch Linux
  • Compiler: clang version 11.1.0

If that's not how the module should be compiled and imported, please tell me the correct way.

Volper212 avatar May 01 '21 10:05 Volper212