Linking with a c library on windows with ldc

Kai Nacke via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Apr 1 08:47:42 PDT 2016


On Friday, 1 April 2016 at 15:14:32 UTC, maik klein wrote:
> On Friday, 1 April 2016 at 14:48:17 UTC, maik klein wrote:
>> On Friday, 1 April 2016 at 14:36:27 UTC, Johan Engelen wrote:
>>> On Friday, 1 April 2016 at 14:26:23 UTC, maik klein wrote:
>>>>
>>>> I currently have Vs2015 installed
>>>>
>>>> Error: `C:\Windows\system32\cmd.exe /s /c 
>>>> "C:\Users\maik\Downloads\ldc2-0.17.1-w
>>>> in64-msvc\bin\amd64.bat lib.exe"` failed with status: 9009
>>>> ldc2 failed with exit code 9009.
>>>
>>> This doesn't look like a linking error to me.
>>> Can LDC create obj files? (use the "-c" cmdline option)
>>>
>>>>  I think only Vs2013 works with ldc?
>>>
>>> We encourage using VS2015.
>>>
>>> -Johan
>>
>> With Vs2015:
>>
>> I can output .obj files with c
>>
>> //test.d
>> import std.stdio;
>>
>> void main(){
>> 	writeln("test");
>> }
>>
>> ldc2 test.d => same error as above
>>
>> ldc2 test.d -c works
>
> Actually the build error is different if I don't use dub
>
> ldc2 test.d
> Using Visual Studio: C:\Program Files (x86)\Microsoft Visual 
> Studio 14.0\
> WARNING: could not find VC\vcvarsall.bat
> link: extra operand '/OPT:REF'
> Try 'link --help' for more information.
> Error: `C:\Windows\system32\cmd.exe /s /c 
> "C:\Users\maik\Downloads\ldc2-0.17.1-w
> in64-msvc\bin\amd64.bat link.exe"` failed with status: 1
>
> So it seems that ldc just doesn't see vcvarsall.bat. I am just 
> not sure where to get it, it doesn't seem to be bundled with 
> visual studio 2015.

Hi Maik!

ldc is built with VS2015 and this is also the recommended VS 
version. You can use VS2013 but this requires manual work and is 
not really tested by the LDC team.

vcvarsall.bat is part of VS2015. It is located in folder 
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC". If you 
use the "VS2015 x64 Native Tools Command Prompt" then the path is 
automatically set and the file should be found by ldc.

It looks like your PATH variable is messed. Can you link a "hello 
world" with cl on the command line? Which link.exe is used if the 
VS path are not set? Could it be that the DMD linker is still in 
your path? If yes then you should remove it from your path.

Regards,
Kai


More information about the digitalmars-d-ldc mailing list