5

I'm developing a llvm-based compiler and when I try to generate executable file the following error occurs:

./bin/llvmcode.s:35: undefined reference to `operator new[](unsigned long)'

Note that in the generated IR, the function '@_Znam' is called which is located in one of llvm libraries. So, I should have linked the generated assembly file with that library. Here is the code I used to do that:

llvm-as ./bin/llvmcode.ll
llc ./bin/llvmcode.bc
g++ -g ./bin/llvmcode.s \`llvm-config --cppflags --ldflags --libs core jit native\` -O3 -o executable -rdynamic

What's wrong with this code? Any assistance would be appreciated.

arrowd
  • 33,231
  • 8
  • 79
  • 110
user1723583
  • 553
  • 1
  • 6
  • 18
  • Is this not a duplicate of https://stackoverflow.com/questions/14301899/llinking-znam-and-znwm ? – JKRT Dec 26 '18 at 14:55
  • Does this answer your question? [llinking @\_Znam and @\_Znwm](https://stackoverflow.com/questions/14301899/llinking-znam-and-znwm) – joel Jun 29 '21 at 21:26

0 Answers0