Thread overview
VS2013 with LDC setup
May 30, 2015
Ronnie
May 30, 2015
Johan Engelen
May 30, 2015
Ronnie
May 30, 2015
Ronnie
May 30, 2015
Ronnie
May 30, 2015
Ronnie
May 30, 2015
Ronnie
May 30, 2015
Hi

Has anyone got a full build and debugging environment working with LDC 0.15.2 and VS2013 for 64bit?

For this test program using DMD compiler in VisualD it all works fine. I can compile,link, and debug.

import std.stdio;

int main(string[] argv)
{
    writeln("Hello D-World!");
    return 0;
}

If I set the compiler to LDC I have to start by running vsvars64.bat first then devenv.exe for it to pick up the correct link.exe (rather than optilink), and I've added C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;H:\Apps\Visual Studio\VC\lib\amd64\ to the "Library Search Path" to ensure it picks up kernel32.lib and LIBCMTD.lib

That got rid of a lot of errors so far, but it's still failing at the last step

Here's buildlog.html output if anyone can help. It seems to be related to the linking somehow. Any help appreciated.

(Separately, can dub work with ldc2 on windows? - I'll ask on a separate thread since it's also giving errors)


set LIB=;H:\Apps\D\ldc2\lib;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;H:\Apps\Visual Studio\VC\lib\amd64\
set WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.1\
set VCINSTALLDIR=H:\Apps\Visual Studio\VC\
"H:\apps\VisualD\pipedmd.exe" H:\Apps\D\ldc2\bin\ldc2.exe -m64 -g -X -Xf="Debug\ConsoleApp1.json" -deps="Debug\ConsoleApp1.dep" -of="Debug\ConsoleApp1.exe_cv" -L/MAP:"Debug\ConsoleApp1.map" main.d
if errorlevel 1 goto reportError
if not exist "Debug\ConsoleApp1.exe_cv" (echo "Debug\ConsoleApp1.exe_cv" not created! && goto reportError)
echo Converting debug information...
"H:\apps\VisualD\cv2pdb\cv2pdb.exe" "Debug\ConsoleApp1.exe_cv" "Debug\ConsoleApp1.exe"
if errorlevel 1 goto reportError
if not exist "Debug\ConsoleApp1.exe" (echo "Debug\ConsoleApp1.exe" not created! && goto reportError)

goto noError

:reportError
echo Building Debug\ConsoleApp1.exe failed!

:noError
Output
ConsoleApp1.obj : error LNK2017: 'ADDR32' relocation to '.debug_info' invalid without /LARGEADDRESSAWARE:NO
ConsoleApp1.obj : error LNK2017: 'ADDR32' relocation to '.debug_info' invalid without /LARGEADDRESSAWARE:NO
ConsoleApp1.obj : error LNK2017: 'ADDR32' relocation to '.debug_info' invalid without /LARGEADDRESSAWARE:NO
ConsoleApp1.obj : error LNK2017: 'ADDR32' relocation to '.debug_info' invalid without /LARGEADDRESSAWARE:NO
druntime-ldc-debug.lib(errno.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(errno.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
druntime-ldc-debug.lib(msvc.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(msvc.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
LINK : fatal error LNK1165: link failed because of fixup errors
Error: H:\Apps\Visual Studio\VC\BIN\amd64\link.exe failed with status: 1165
Building Debug\ConsoleApp1.exe failed!
May 30, 2015
On Saturday, 30 May 2015 at 16:29:56 UTC, Ronnie wrote:
> ConsoleApp1.obj : error LNK2017: 'ADDR32' relocation to '.debug_info' invalid without /LARGEADDRESSAWARE:NO

To 'fix' that linker error, you have to add "-L/LARGEADDRESSAWARE:NO" to the LDC cmdline for debug builds. I have it added to ldc2.conf.
May 30, 2015
Thanks Johan.

Almost there it seems

set LIB=;H:\Apps\D\ldc2\lib;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;H:\Apps\Visual Studio\VC\lib\amd64\
set WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.1\
set VCINSTALLDIR=H:\Apps\Visual Studio\VC\
"H:\apps\VisualD\pipedmd.exe" H:\Apps\D\ldc2\bin\ldc2.exe -m64 -g -X -Xf="Debug\ConsoleApp1.json" -deps="Debug\ConsoleApp1.dep" -of="Debug\ConsoleApp1.exe_cv" -L/MAP:"Debug\ConsoleApp1.map" main.d
if errorlevel 1 goto reportError
if not exist "Debug\ConsoleApp1.exe_cv" (echo "Debug\ConsoleApp1.exe_cv" not created! && goto reportError)
echo Converting debug information...
"H:\apps\VisualD\cv2pdb\cv2pdb.exe" "Debug\ConsoleApp1.exe_cv" "Debug\ConsoleApp1.exe"
if errorlevel 1 goto reportError
if not exist "Debug\ConsoleApp1.exe" (echo "Debug\ConsoleApp1.exe" not created! && goto reportError)

goto noError

:reportError
echo Building Debug\ConsoleApp1.exe failed!

:noError



Output
druntime-ldc-debug.lib(errno.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(errno.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
druntime-ldc-debug.lib(msvc.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(msvc.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
Converting debug information...
Debug\ConsoleApp1.exe_cv: no codeview debug entries found
Building Debug\ConsoleApp1.exe failed!


Rather unhelpful error now; but it feels close!
May 30, 2015
OK so a little bit further now.

So if I check "Build and use local phobos" then it dies with #include <errno.h> not found - fair enough, I can understand that.

And if I don't do that

Output
druntime-ldc-debug.lib(errno.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(errno.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
druntime-ldc-debug.lib(msvc.c.obj) : warning LNK4099: PDB 'vc120.pdb' was not found with 'druntime-ldc-debug.lib(msvc.c.obj)' or at 'H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Debug\vc120.pdb'; linking object as if no debug info
Converting debug information...
Debug\ConsoleApp1.exe_cv: no codeview debug entries found
Building Debug\ConsoleApp1.exe failed!

May 30, 2015
And if I try to do a release version

ConsoleApp1.obj : error LNK2019: unresolved external symbol _D3std5stdio6stdoutS3std5stdio4File (std.stdio.File std.stdio.stdout) referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv (void std.stdio.writeln!(immutable(char)[]).writeln(immutable(char)[]))
ConsoleApp1.obj : error LNK2019: unresolved external symbol _D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyamZb (pure @safe bool std.exception.enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong)) referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFAyaZv (void std.stdio.writeln!(immutable(char)[]).writeln(immutable(char)[]))
ConsoleApp1.obj : error LNK2019: unresolved external symbol _Dmodule_ref referenced in function _D4main16__moduleinfoCtorZ (main.__moduleinfoCtor)
ConsoleApp1.obj : error LNK2019: unresolved external symbol _d_run_main referenced in function main
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D14TypeInfo_Const6__vtblZ (TypeInfo_Const.__vtbl)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D14TypeInfo_Array6__vtblZ (TypeInfo_Array.__vtbl)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_m6__initZ (TypeInfo_m.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D18TypeInfo_Invariant6__vtblZ (TypeInfo_Invariant.__vtbl)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_a6__initZ (TypeInfo_a.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D12TypeInfo_Axa6__initZ (TypeInfo_Axa.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_b6__initZ (TypeInfo_b.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_i6__initZ (TypeInfo_i.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_h6__initZ (TypeInfo_h.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D10TypeInfo_k6__initZ (TypeInfo_k.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D12TypeInfo_Aya6__initZ (TypeInfo_Aya.__init)
ConsoleApp1.obj : error LNK2001: unresolved external symbol _D3std5stdio12__ModuleInfoZ (std.stdio.__ModuleInfo)
Release\ConsoleApp1.exe : fatal error LNK1120: 16 unresolved externals
Building Release\ConsoleApp1.exe failed!
Details saved as "file://H:\Users\Mushfaque.Cradle\documents\D\ConsoleApp1\ConsoleApp1\Release\ConsoleApp1.buildlog.html"
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
May 30, 2015
Aha I think I've found the issue (for anyone else).

LDC indeed produces a running executable called in this case Debug\Console1App.exe_cv which produces a "Hello D-World" when run.

Cv2pdb tries to convert to pdb debugging information but errors out with "no codeview debug entries found."

In release mode, no issues compiling or running.

So how do I get ldc2 to generate this debugging info? "-g" doesn't seem to work.

I'm using 0.15.1 beta 1 and LLVM 3.60
May 30, 2015
On Saturday, 30 May 2015 at 19:34:10 UTC, Ronnie wrote:
> Aha I think I've found the issue (for anyone else).
>
> LDC indeed produces a running executable called in this case Debug\Console1App.exe_cv which produces a "Hello D-World" when run.
>
> Cv2pdb tries to convert to pdb debugging information but errors out with "no codeview debug entries found."
>
> In release mode, no issues compiling or running.
>
> So how do I get ldc2 to generate this debugging info? "-g" doesn't seem to work.
>
> I'm using 0.15.1 beta 1 and LLVM 3.60

Final post on this subject. Solved it finally.

Set the Properties/Debugger to "Mago". That disables the CV2PDB call, but still allows you to debug within VS (oddly).