www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to get Visual D working with Derelict2?

reply "Chris Pons" <cmpons gmail.com> writes:
Hey everyone,
I am new to D, and interested in using it with Derelict2 for game 
development. I plan on using Visual D, which I have installed 
already. I used the visual studio 2008 solution file to build the 
libraries and the .di files but unfortunately I do not know where 
to put these files once built or alternatively setup Visual D to 
recognize their location.

Lastly, how would I import these libraries in the code?

Such as this, simple test program:

module main;

import derelict.opengl.gl; //<--- This doesn't work, how would I 
import with the //lib and .di files in the right place?

import std.stdio;

void main()
{
    try {
        DerelictGL.load();
        writefln("Successfully loaded the OpenGL shared library.");
    } catch (Exception e) {
        writefln("Could not load the OpenGL shared library.");
    }
}


Thank you for being patient with me!
Feb 15 2012
parent reply Mike Parker <aldacron gmail.com> writes:
On 2/16/2012 5:39 AM, Chris Pons wrote:
 Hey everyone,
 I am new to D, and interested in using it with Derelict2 for game
 development. I plan on using Visual D, which I have installed already. I
 used the visual studio 2008 solution file to build the libraries and the
 .di files but unfortunately I do not know where to put these files once
 built or alternatively setup Visual D to recognize their location.
Right click on your project in the Solution Explorer, select "Properties", then "Configuration Properties"->DMD. Enter the path (absolute or relative) to your import directory (ex: if the DerelictUtil modules are in C:\foo\derelict\util, you would add C:\foo as the import path). Now select "Configuration Properties"->Linker and enter the libraries in Library Files. You'll need to include the path like so: C:\foo\libs\DerelictUtil.lib C:\foo\libs\DerelictGL.lib Alternatively, you can add the following to the top of your source module: pragma(lib, "C:\foo\libs\DerelictUtil.lib"); pragma(lib, "C:\foo\libs\DerelictGL.lib"); ... Makes sure to add every lib you need to link with.
 Lastly, how would I import these libraries in the code?
You don't import "libraries". You import "modules". The import statement tells DMD which source modules to look in for external declarations. It has absolutely nothing to do with library files. And if the root directory for the module package is not on the import path, it won't be able to find them.
Feb 16 2012
parent "Chris Pons" <cmpons gmail.com> writes:
On Thursday, 16 February 2012 at 16:25:04 UTC, Mike Parker wrote:
 On 2/16/2012 5:39 AM, Chris Pons wrote:
 Hey everyone,
 I am new to D, and interested in using it with Derelict2 for 
 game
 development. I plan on using Visual D, which I have installed 
 already. I
 used the visual studio 2008 solution file to build the 
 libraries and the
 .di files but unfortunately I do not know where to put these 
 files once
 built or alternatively setup Visual D to recognize their 
 location.
Right click on your project in the Solution Explorer, select "Properties", then "Configuration Properties"->DMD. Enter the path (absolute or relative) to your import directory (ex: if the DerelictUtil modules are in C:\foo\derelict\util, you would add C:\foo as the import path). Now select "Configuration Properties"->Linker and enter the libraries in Library Files. You'll need to include the path like so: C:\foo\libs\DerelictUtil.lib C:\foo\libs\DerelictGL.lib Alternatively, you can add the following to the top of your source module: pragma(lib, "C:\foo\libs\DerelictUtil.lib"); pragma(lib, "C:\foo\libs\DerelictGL.lib"); ... Makes sure to add every lib you need to link with.
 Lastly, how would I import these libraries in the code?
You don't import "libraries". You import "modules". The import statement tells DMD which source modules to look in for external declarations. It has absolutely nothing to do with library files. And if the root directory for the module package is not on the import path, it won't be able to find them.
Thank you for helping a newbie! Much appreciated!
Feb 16 2012