[cfe-dev] Clang debug linking options on Windows

don hinton via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 14 10:09:16 PDT 2015


Took a look at llvm/tools/clang/lib/Driver/Tools.cpp, and it looks like all
you need to do is pass "/MTd" and clang will add the following:

-D_DEBUG
-D_MT
--dependent-lib=libcmtd

You'll probably need it for both the compile and link steps.

I don't have windows, so I can't verify, so I hope this helps...
don

On Mon, Sep 14, 2015 at 9:53 AM, Russell Wallace via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> _MT has no effect; same errors.
>
> On Mon, Sep 14, 2015 at 2:19 PM, Joshua Gerrard <joshua.gerrard at roli.com>
> wrote:
>
>> Also try defining _MT
>>
>> --
>> Joshua Gerrard
>> JUCE Software Developer
>>
>> The Seaboard GRAND is a breakthrough new musical instrument called “the
>> piano of the future” (CNN) and “influential, innovative, and inspiring” and
>> “ingenious” (Telegraph). With orders from 34 countries, the Seaboard GRAND
>> is now shipping and available for sale at www.roli.com/seaboard
>>
>> Office: +44(0)207 254 2155
>> Cell:    07885 557494
>>
>> ROLI
>> 2 Glebe Road, London E8 4BD
>> www.roli.com
>>
>> Discover more about us on Facebook - Twitter - Youtube
>>
>> ROLI Ltd. is a registered company in England and Wales, and this e-mail
>> and its attachment(s) are intended for the above named only and are
>> confidential. If they have come to you in error then you must take no
>> action based upon them but contact us immediately. Any disclosure, copying,
>> distribution or any action taken or omitted to be taken in reliance on it
>> is prohibited and may be unlawful. Although this e-mail and its attachments
>> are believed to be free of any virus, it is the responsibility of the
>> recipient to ensure that they are virus free. If you contact us by e-mail
>> then we will store your name and address to facilitate communications. Any
>> statements contained herein are those of the individual and not the
>> organisation.
>>
>>
>> On 11 September 2015 at 23:49, Russell Wallace via cfe-dev <
>> cfe-dev at lists.llvm.org> wrote:
>>
>>> That almost works. What am I still missing? I tried -g but no effect.
>>>
>>> C:\t>clang -D_DEBUG -I/llvm/build/include -I/llvm/include -S -emit-llvm
>>> -fms-compatibility-version=19 a.cpp
>>>
>>> C:\t>clang a.ll \llvm\build\Debug\lib\*.lib
>>> warning: overriding the module target triple with
>>> x86_64-pc-windows-msvc18.0.0 [-Woverride-module]
>>> 1 warning generated.
>>> LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other
>>> libs; use /NODEFAULTLIB:library
>>> LLVMSupport.lib(TargetParser.obj) : error LNK2001: unresolved external
>>> symbol _CrtDbgReportW
>>> libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol
>>> _CrtDbgReportW
>>> libcpmtd.lib(syserror.obj) : error LNK2001: unresolved external symbol
>>> _CrtDbgReportW
>>> LLVMSupport.lib(ConvertUTFWrapper.obj) : error LNK2001: unresolved
>>> external symbol _CrtDbgReportW
>>> LLVMSupport.lib(Host.obj) : error LNK2001: unresolved external symbol
>>> _CrtDbgReportW
>>> LLVMSupport.lib(MemoryBuffer.obj) : error LNK2001: unresolved external
>>> symbol _CrtDbgReportW
>>> etc...
>>>
>>> On Fri, Sep 11, 2015 at 9:14 PM, Reid Kleckner <rnk at google.com> wrote:
>>>
>>>> You're crossing the relase/debug MSVC CRT streams. Make sure all
>>>> objects in a given image are using the same CRT.
>>>>
>>>> In your specific example, you should add -D_DEBUG to the command line.
>>>> You want to simulate the effect of passing /MTd to cl.exe or clang-cl.exe.
>>>>
>>>> On Fri, Sep 11, 2015 at 10:07 AM, Russell Wallace via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> I'm trying to compile some code via IR and link it with the debug
>>>>> libraries on Windows, but getting errors. A minimal test case:
>>>>>
>>>>> C:\t>type a.cpp
>>>>> #define _HAS_EXCEPTIONS 0
>>>>> #include <llvm/Support/Signals.h>
>>>>>
>>>>> int main() {
>>>>>   llvm::sys::PrintStackTraceOnErrorSignal();
>>>>>   return 0;
>>>>> }
>>>>>
>>>>> C:\t>clang -I/llvm/build/include -I/llvm/include -S -emit-llvm
>>>>> -fms-compatibility-version=19 a.cpp
>>>>>
>>>>> C:\t>clang a.ll \llvm\build\Debug\lib\*.lib
>>>>> warning: overriding the module target triple with
>>>>> x86_64-pc-windows-msvc18.0.0 [-Woverride-module]
>>>>> 1 warning generated.
>>>>> LLVMSupport.lib(Signals.obj) : error LNK2038: mismatch detected for
>>>>> '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in a-db717b.o
>>>>> LLVMSupport.lib(Signals.obj) : error LNK2038: mismatch detected for
>>>>> 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value
>>>>> 'MT_StaticRelease' in a-db717b.o
>>>>> LLVMSupport.lib(Path.obj) : error LNK2038: mismatch detected for
>>>>> '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in a-db717b.o
>>>>> LLVMSupport.lib(Path.obj) : error LNK2038: mismatch detected for
>>>>> 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value
>>>>> 'MT_StaticRelease' in a-db717b.o
>>>>> LLVMSupport.lib(raw_ostream.obj) : error LNK2038: mismatch detected
>>>>> for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in a-db717b.o
>>>>> ...etc...
>>>>>
>>>>> There's probably an option that I'm missing?
>>>>>
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at lists.llvm.org
>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>
>>>
>>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150914/f84daf8b/attachment.html>


More information about the cfe-dev mailing list