Jump to page: 1 2
Thread overview
Linking with a c library on windows with ldc
Apr 01, 2016
maik klein
Apr 01, 2016
Kagamin
Apr 01, 2016
maik klein
Apr 01, 2016
ZombineDev
Apr 01, 2016
maik klein
Apr 01, 2016
Johan Engelen
Apr 01, 2016
maik klein
Apr 01, 2016
maik klein
Apr 01, 2016
Kai Nacke
Apr 01, 2016
maik klein
Apr 07, 2016
MrSmith
Apr 07, 2016
maik klein
Apr 07, 2016
MrSmith
Apr 08, 2016
kink
Apr 08, 2016
MrSmith
April 01, 2016
I just wanted to build my project on windows, but it turned out to be much harder than I thought. In DMD there is some legacy stuff with 32bit apps but I mostly ignored it because I want to ouput 64 bit binaries anways. The problem is dmd always return an ICE if want to generate a 64bit binary.

So I thought I would give ldc a try.

The first problem was with dub, as currently it still outputs a '.a' lib on windows, so I had to fix that.

I am currently linking with glfw on linux like this

dependency "derelict-glfw3" version="~>2.0.0"
subConfiguration "derelict-glfw3" "derelict-glfw3-static"
sourceFiles "deps/linux64/libglfw3.a"
libs "Xi" "pthread" "X11" "Xxf86vm" "Xrandr" "pthread" "GL" "GLU" "Xinerama" "Xcursor"

This is how I did it on windows

dependency "derelict-glfw3" version="~>2.0.0"
subConfiguration "derelict-glfw3" "derelict-glfw3-static"
sourceFiles "deps/win64/libglfw3.lib"
libs "opengl32"

I just installed vs2013 and vcredist2013 and vsredist2015 on windows 7.

First I got a linker error that it couldn't find opengl32, so I temporarily removed it.

Then I got a linker error with legacy_stdio. I made a quick google search and I found an issue for ldc. Apparently I had to remove a line from  ldc2.ini to make it work with vs2013.

But there was nothing related to legacy_stdio inside this .ini so I removed vs2013 and installed vs2015.

But I get an error with vs2015 for both dmd and ldc.

So my question:

What do I need to install? Have I done anything wrong? Are there any docs that can help me?
April 01, 2016
The error message and other diagnostic means can help you.
April 01, 2016
On Friday, 1 April 2016 at 12:52:45 UTC, Kagamin wrote:
> The error message and other diagnostic means can help you.

There is no error message other then the linking has failed. Which diagnostic tools are available?


April 01, 2016
On Friday, 1 April 2016 at 14:13:05 UTC, maik klein wrote:
> On Friday, 1 April 2016 at 12:52:45 UTC, Kagamin wrote:
>> The error message and other diagnostic means can help you.
>
> There is no error message other then the linking has failed. Which diagnostic tools are available?

What is the exact linking error?
April 01, 2016
On Friday, 1 April 2016 at 14:17:41 UTC, ZombineDev wrote:
> On Friday, 1 April 2016 at 14:13:05 UTC, maik klein wrote:
>> On Friday, 1 April 2016 at 12:52:45 UTC, Kagamin wrote:
>>> The error message and other diagnostic means can help you.
>>
>> There is no error message other then the linking has failed. Which diagnostic tools are available?
>
> What is the exact linking error?

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.

With Vs2013 the linking error was something along the lines "Error: Failed to link with legacy_stdio".

I am on a fresh install of Windows 7 but I will reinstall Windows 7 tomorrow when my new SSD arrives. I think only Vs2013 works with ldc?
April 01, 2016
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

April 01, 2016
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
April 01, 2016
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.


April 01, 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
April 01, 2016
On Friday, 1 April 2016 at 15:47:42 UTC, Kai Nacke wrote:
> On Friday, 1 April 2016 at 15:14:32 UTC, maik klein wrote:
>> [...]
>
> 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
It seems that for some reason I didn't install the common c++ extension for VS2015.

Oh my god it finally builds and links, I can't believe it.

LDC is now my default compiler, keep up the good work and thanks for the help.

« First   ‹ Prev
1 2