mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
solve the mystery of undefined reference error
big surprise, C++ is to blame
This commit is contained in:
parent
8409e518ab
commit
8d60ffe314
3 changed files with 23 additions and 0 deletions
14
README.md
14
README.md
|
|
@ -90,3 +90,17 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DZIG_LIBC_DIR=path/to/libc/dir
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
If you get one of these:
|
||||||
|
|
||||||
|
* `undefined reference to `_ZNK4llvm17SubtargetFeatures9getStringB5cxx11Ev'`
|
||||||
|
* `undefined reference to `llvm::SubtargetFeatures::getString() const'`
|
||||||
|
|
||||||
|
This is because of [C++'s Dual ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html).
|
||||||
|
Most likely LLVM was compiled with one compiler while Zig was compiled with a
|
||||||
|
different one, for example GCC vs clang.
|
||||||
|
|
||||||
|
To fix this, compile Zig with the same compiler that LLVM was compiled with, or
|
||||||
|
add `-DZIG_LLVM_OLD_CXX_ABI=yes` to the cmake configure line.
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,6 @@
|
||||||
#define ZIG_STD_DIR "@CMAKE_INSTALL_PREFIX@/@ZIG_STD_DEST@"
|
#define ZIG_STD_DIR "@CMAKE_INSTALL_PREFIX@/@ZIG_STD_DEST@"
|
||||||
#define ZIG_LIBC_DIR "@ZIG_LIBC_DIR@"
|
#define ZIG_LIBC_DIR "@ZIG_LIBC_DIR@"
|
||||||
|
|
||||||
|
#cmakedefine ZIG_LLVM_OLD_CXX_ABI
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
* See http://opensource.org/licenses/MIT
|
* See http://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This must go before all includes.
|
||||||
|
#include "config.h"
|
||||||
|
#if defined(ZIG_LLVM_OLD_CXX_ABI)
|
||||||
|
#define _GLIBCXX_USE_CXX11_ABI 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "zig_llvm.hpp"
|
#include "zig_llvm.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue