Requesting for help.

Hi,

This mail is regarding the help required from you guys on the LLVM compiler.

I have compiled and built the LLVM compiler myself by looking into the https://llvm.org/docs/GettingStarted.html website. I am using the gold linker for linking the code. While linking the code, I am hitting the issue stating that “undefined reference to printf()”.

Now, as far as the printf() function is concerned, it is present in the libc library normally. However, this library is not present in the LLVM toolchain. I also tried to look for printf() into the libraries in the LLVM tool chain, but I could not find it. I am using the command nm . | grep printf in the libraries in the tool chain.

Can you please help me how to continue? How and which library do I need to install to make the printf() available to the gold linker?
Thanks in advance.

Thanks,
Sumedh

Hello Sumedh,

We'll probably need a bit more information to be able to help.

Just to rule out the simple things; by LLVM compiler I'm assuming you
mean clang? If so you should be able to use clang as your linker
driver, this will insert all the paths, libraries and c-library
startup code that is needed for a successful link. For example clang
hello.c -o hello.exe. You can use the -v option to clang to see what
it is passing to the linker. In general it is not a good idea to call
gold directly unless you know exactly what you want. For example clang
-c hello.c -o hello.o ; ld.gold hello.o -o hello.exe won't be
sufficient.

The LLVM project doesn't provide a C library, you'll need to use the
one provided by your system. In most cases the clang driver will be
able to locate it.

If all this isn't working or you are doing something more complicated
like cross-compiling we'll need a bit more information before we can
help. As mentioned before the -v option to clang is useful.

Peter