[cfe-dev] Link errors in Windows

nullnull null.function at gmail.com
Sat Feb 19 22:04:51 PST 2011


I need clang for my experimentations in Windows. I tried to compile and link
with clang on Windows. However, I'm getting a bunch of linking errors. For
example:

error LNK2005: _InterlockedIncrement64 already defined in cc-000000.o
error LNK2005: _InterlockedDecrement64 already defined in cc-000000.o
error LNK2005: _InterlockedExchange64 already defined in cc-000000.o
error LNK2005: _InterlockedExchangeAdd64 already defined in cc-000000.o


I was able to see the reason. When a source file includes "Windows.h" and
does use Win32 APIs, then clang emits some Win32 API definitions in the
object files. I've confirmed by looking bitcode.


========
define i64 @InterlockedAnd64(i64* %Destination, i64 %Value) nounwind {
entry:
  %Destination.addr = alloca i64*, align 4
  %Value.addr = alloca i64, align 8
  %Old = alloca i64, align 8
  store i64* %Destination, i64** %Destination.addr, align 4
  store i64 %Value, i64* %Value.addr, align 8
  br label %do.body
...
=======

These definitions exist in every object files, resulting in duplication
linking errors.


I do believe there would be a very simple workaround for it. I'm compiling
clang/llvm sources directly. Is there any quick  solution for that?

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110220/9f283602/attachment.html>


More information about the cfe-dev mailing list