Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: DSFML Link/Build Issues  (Read 11332 times)

0 Members and 1 Guest are viewing this topic.

funthingsarefun

  • Guest
DSFML Link/Build Issues
« on: October 01, 2016, 08:53:08 pm »
New to D, so excuse any possible oversight(s) & and the lengthy post. 
Been at this awhile so I need some outside input.
Also, apologies in advance if I'm posting in the wrong place or thread.

The steps I took:
1. Grab DSFML & DSFML-C from their respective Githubs
2. Build DSFML-C using Cmake GUI 3.6.1 with: https://sourceforge.net/projects/mingw-w64/
3. Checked BUILD_SHARED_LIBS & UNCHECKED SFML_USE_STATIC_STD_LIBS
4. Following: http://dsfml.com/docs/buildingfromsource.html
4a. Built DSFML with
rdmd build
5. In Codeblocks before linking, a generic Hello World works fine.
6. For DMD under "Search Directories->Compiler I have:
 - S:\DSFML-master\src
 - S:\DSFMLC-master\build\src
7. For Linker I have:
- S:\DSFML-master\lib
- S:\DSFMLC-master\build\lib
8. Under "Linker Settings" I have:
- dsml-graphics
- dsfml-window
- dsfml-audio
- dsfml-network
- dsfml-system

Using the hello world test from: http://dsfml.com/doc.html
The important stuff from my build log are:
Code: [Select]
dmd.exe  -O  -w   -IS:\DSFML-master\src -IS:\DSFMLC-master\build\src -c hello.d -ofobj\Release\hello.obj
dmd.exe bin\Release\Test.exe  obj\Release\hello.obj  dsfml-graphics.lib dsfml-window.lib dsfml-audio.lib dsfml-network.lib dsfml-system.lib
OPTLINK (R) for Win32  Release 8.00.17

The issues:
(click to show/hide)

And the Errors [16]:
(click to show/hide)

Any help or advice is greatly appreciated, thank you.
Also any Dub-less solutions would be great.

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: DSFML Link/Build Issues
« Reply #1 on: October 01, 2016, 11:27:14 pm »
I've never used Codeblocks for a D project, but from your log it looks like the linker settings aren't being used.

Quote
Code: [Select]
dmd.exe  -O  -w   -IS:\DSFML-master\src -IS:\DSFMLC-master\build\src -c hello.d -ofobj\Release\hello.obj
dmd.exe bin\Release\Test.exe  obj\Release\hello.obj  dsfml-graphics.lib dsfml-window.lib dsfml-audio.lib dsfml-network.lib dsfml-system.lib
OPTLINK (R) for Win32  Release 8.00.17

The -I switch is for specifying where source code is, but there isn't any linker switches in there. You might try adding those in manually and see if that works. It should look like this: -L+lib/location/here. You'll need to link the DSFMLC libraries too in order to get everything to work correctly(you showed linking only to the DSFML libs in your steps).

Additionally,  it looks like you're producing 32 bit libs. I didn't see this in your steps, so don't forget to run implib(which I've bundled with DSFMLC) on your dll's to make import libraries optlink can use.

Let me know if you need any other help! And if anything is ever unclear, please shoot me an email so I can update the tutorials.
DSFML - SFML for the D Programming Language.

funthingsarefun

  • Guest
Re: DSFML Link/Build Issues
« Reply #2 on: October 02, 2016, 12:28:41 am »
So I rebuilt both for 64 bit this time, and implib is only for 32 bit, correct?
I'm confused on a few things though.
1. What to do with the "dsfmlc-XXX-2.dll"?
Link to them in the search directories or do they need to be placed in the /debug and /release dirs?
2. The -I switch, isn't it redundant when you're already specifying the folders to refer to? Or is Code Blocks just not doing what it's supposed to, so you have to explicitly specify where to look?
Also what things am I exactly linking to?

The search directories to the src or the libraries or both?
Also if you could be a little hand-holdy with the specifics that'd be nice.
I really need to learn more manual compiler stuff after this.
« Last Edit: October 02, 2016, 12:40:07 am by funthingsarefun »

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: DSFML Link/Build Issues
« Reply #3 on: October 04, 2016, 02:21:32 am »
So I rebuilt both for 64 bit this time, and implib is only for 32 bit, correct?

Correct. DMD's 32 bit linker(optlink) only accepts import libraries in a certain format, but 64 bit code uses a different linker. DMD uses the MSVC toolchain for 64 bit code, so make sure you're using the right compiler for that.

Quote
I'm confused on a few things though.
1. What to do with the "dsfmlc-XXX-2.dll"?
Link to them in the search directories or do they need to be placed in the /debug and /release dirs?

Those go in the same directory as your compiled .exe

Quote
2. The -I switch, isn't it redundant when you're already specifying the folders to refer to? Or is Code Blocks just not doing what it's supposed to, so you have to explicitly specify where to look?
Also what things am I exactly linking to?
The search directories to the src or the libraries or both?

Sorry if I wasn't clear. When I mentioned the -I switch, I was referring to it being used already (in your log) and that the -L switch was not being used even though you specified the directories in your linker settings. You'll need to manually add the linker options to include those directories to the searched list since Codeblocks doesn't appear to be doing it.

Quote
Also if you could be a little hand-holdy with the specifics that'd be nice.
I really need to learn more manual compiler stuff after this.

Have you taken a look at the building your first DSFML program tutorial? It should walk you through and explain a lot of things. If you need more help, let me know.
DSFML - SFML for the D Programming Language.