Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined __cxxabiv1::__class_type_info vtable #477

Merged
merged 1 commit into from
Aug 14, 2022

Conversation

neverpanic
Copy link
Contributor

Linking C++ code with the C linker causes a missing vtable for in __cxxabiv1::__class_type_info, referenced from runtime type information in el::Linker and el::Resolver. Linking this library with clang++ instead fixes the issue.

From the git log, it was not clear to me why LINKER_LANGUAGE "C" was introduced in the first place. It no longer seems to be necessary.

Full error is:

/usr/bin/clang  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -mmacosx-version-min=12.0 -dynamiclib -Wl,-headerpad_max_install_names -o libexec.dylib -install_name @rpath/libexec.dylib CMakeFiles/exec.dir/source/report/libexec/lib.cc.o CMakeFiles/exec.dir/source/report/libexec/std.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Buffer.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Environment.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Executor.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Linker.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Logger.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Paths.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Resolver.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Session.cc.o
Undefined symbols for architecture arm64:
  "vtable for __cxxabiv1::__class_type_info", referenced from:
      typeinfo for el::Linker in Linker.cc.o
      typeinfo for el::Resolver in Resolver.cc.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

/usr/bin/clang is

$ /usr/bin/clang -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Linking C++ code with the C linker causes a missing vtable for in
__cxxabiv1::__class_type_info, referenced from runtime type information
in el::Linker and el::Resolver. Linking this library with clang++
instead fixes the issue.

From the git log, it was not clear to me why LINKER_LANGUAGE "C" was
introduced in the first place. It no longer seems to be necessary.

Full error is:

| /usr/bin/clang  -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -mmacosx-version-min=12.0 -dynamiclib -Wl,-headerpad_max_install_names -o libexec.dylib -install_name @rpath/libexec.dylib CMakeFiles/exec.dir/source/report/libexec/lib.cc.o CMakeFiles/exec.dir/source/report/libexec/std.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Buffer.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Environment.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Executor.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Linker.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Logger.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Paths.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Resolver.cc.o CMakeFiles/exec_a.dir/source/report/libexec/Session.cc.o
| Undefined symbols for architecture arm64:
|   "vtable for __cxxabiv1::__class_type_info", referenced from:
|       typeinfo for el::Linker in Linker.cc.o
|       typeinfo for el::Resolver in Resolver.cc.o
|   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
| ld: symbol(s) not found for architecture arm64
| clang: error: linker command failed with exit code 1 (use -v to see invocation)

Signed-off-by: Clemens Lang <cal@macports.org>
@rizsotto
Copy link
Owner

Thank you @neverpanic !

@rizsotto rizsotto merged commit b83c3e6 into rizsotto:master Aug 14, 2022
@neverpanic neverpanic deleted the cal-fix-undefined-vtable branch February 1, 2023 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants