Thanks a lot, this made things clear. I have made some tests myself to understand this concept better, I will post my results here.
This is the sample program I used (a cleaner and minified version of previous example):
import dsfml.graphics;
void main()
{
auto window = new RenderWindow(VideoMode(800,600), "Hello DSFML!");
auto circle = new CircleShape(10);
circle.fillColor = Color.Red;
circle.position = Vector2f(300,100);
Event event;
while(window.isOpen())
{
while(window.pollEvent(event))
{
if(event.type == Event.Closed)
{
window.close();
}
}
window.clear(Color.Black);
window.draw(circle);
window.display();
}
}
Before you begin to read you must know that:
- I have extracted my library in the path D:\Development\Libraries\DSFML\
- I have placed all of the binaries to a special folder that is registered to PATH environment variable.
Now for the compilation commands.
First Option: Is to link directly and straight to the DSFML library path.Sample:
dmd main.d D:\Development\Libraries\DSFML\dsfml\graphics.d D:\Development\Libraries\DSFML\dsfml\system.d D:\Development\Libraries\DSFML\dsfml\window.d -ID:\Development\Libraries\DSFML\ -L+D:\Development\Libraries\DSFML\DSFMLLibs\ csfml-graphics.lib csfml-system.lib csfml-window.lib
Explanation:
dmd The compiler.main.d
The source code of your application.D:\Development\Libraries\DSFML\dsfml\graphics.d
D:\Development\Libraries\DSFML\dsfml\system.d
D:\Development\Libraries\DSFML\dsfml\window.d
The source code of the DSFML library, this allows the code to be compiled, same as our application.-ID:\Development\Libraries\DSFML
The include path of the DSFML library, this allows import statements to work.-L+D:\Development\Libraries\DSFML\
DSFMLLibs\
This is the Optlink method, so we can set the linker path once and then link to libraries alone. Alternatively it may not be added, but then .lib files will need to use relative or absolute paths to be found.I have removed space from this folder just to be sure dmd won't break paths and avoid using double quotes.csfml-graphics.lib
csfml-system.lib
csfml-window.lib
No need to use paths here.Second Option: Is to compile a static version of DSFML and link directly to the library path. Same as previous but now there is already a compiled version of DSFML.Example:
dmd main.d -ID:\Development\Libraries\DSFML -L+D:\Development\Libraries\DSFML\DSFMLLibs\ csfml-system.lib csfml-window.lib csfml-graphics.lib dsfml.lib
Explanation:
dmd Compilermain.d
Source-ID:\Development\Libraries\DSFML
Include path to let import statements work-L+D:\Development\Libraries\DSFML\DSFMLLibs
\ Use Optlink to set linker path. It's very important to use slash/backslash in the end to indicate that this is a folder, do not forget it.csfml-system.lib csfml-window.lib csfml-graphics.lib
dsfml.libThe libraries, note that I have placed
dsfml.lib inside the
DSFMLLibs folder.
Use any preffered method of compilation according to your needs.