[LLVMdev] Linking executable error on Windows

Nathan Jeffords blunted2night at gmail.com
Tue Apr 24 19:48:17 PDT 2012


I have been using MinGW to linking the output from clang successfully... I
did find that getting it to work correctly was a little tricky, in
particular, when passing object files to ld, the order is very important.
Specifically, you must pass crt initialization files first.

I use the following line to link a simple one file C++ program, %MWL% and
%GCL% are paths into the MinGW library directories.

ld -L %GCL% --subsystem console %MWL%crt2.o %GCL%crtbegin.o test-c-clang.o
-lmingw32 -lgcc_eh -lgcc -lmsvcrt -lkernel32 %GCL%crtend.o

This requires only using clang to compile the file to an object file using
the -c option, and the -o <object-file-name> option.

I don't think clang is compatible with Visual C++'s standard library
(with regards to compiler generated library calls)

On Tue, Apr 24, 2012 at 4:44 PM, Paul J. Lucas <paul at lucasmail.org> wrote:

> I followed the build instructions for LLVM+clang -- that all went OK.  But
> compiling a simple "hello world" program with clang++ gives a linker error
> -- see attached log file.
>
> - Paul
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120424/5520e2c1/attachment.html>


More information about the llvm-dev mailing list