0

When compile int128 division method with clang-cl (Clang-11.0 and MSVC2019), it occurs this error.
Code like:

__int128 a, b;
auto c = a / b;

and compiler outputs:

1>lld-link :error : undefined symbol: __divti3
1>>>> referenced by <path>\int128.h:594

How to fix it ?

273K
  • 29,503
  • 10
  • 41
  • 64
X.Zheng
  • 59
  • 6

1 Answers1

1

You have to link your executable with clang_rt.builtins-x86_64.lib.
You can find it in

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\<Version>\lib\x64
273K
  • 29,503
  • 10
  • 41
  • 64
  • GCC and Clang only support 128-bit integers in 64-bit mode, even in Linux. It's not because of the calling convention because large structs can be still be returned via a hidden pointer – phuclv Aug 06 '21 at 07:26
  • Thanks, I added it from LLVM and works perfectly fine: `C:\Program Files\LLVM\lib\clang\13.0.0\lib\windows\clang_rt.builtins-x86_64.lib` – Adam Dec 31 '21 at 07:32