How to setup D with SFML? (using bindbc-sfml)

Salih Dincer salihdb at hotmail.com
Wed Apr 12 10:05:14 UTC 2023


On Tuesday, 11 April 2023 at 10:24:09 UTC, Ki Rill wrote:
> My `dub.json`:
> ```Json
> {
> 	"authors": [
> 		"rillki"
> 	],
> 	"copyright": "Copyright © 2023, rillki",
> 	"dependencies": {
> 		"bindbc-sfml": "~>1.0.2"
> 	},
> 	"description": "D/SFML project template",
> 	"license": "BSL",
> 	"name": "d-sfml-project-template",
> 	"targetPath": "bin",
> 	"versions": [
> 		"SFML_Audio",
> 		"SFML_Graphics",
> 		"SFML_Network",
> 		"SFML_System",
> 		"SFML_Window",
> 		"SFML_250"
> 	]
> }
> ```
>
> I will try to make it work... Meanwhile, if someones spots what 
> I am doing wrong, please reply to this post.

If I use your dub.json, my terminal screen says:

> user at debian:~/Downloads$ cd dsfml
> user at debian:~/Downloads/dsfml$ dub
>     Fetching bindbc-sfml 1.0.2 (getting selected version)
>      Fetching bindbc-loader 1.0.3 (getting selected version)
>      Starting Performing "debug" build using /usr/bin/dmd for 
> x86_64.
>      Building bindbc-loader 1.0.3: building configuration [noBC]
>      Building bindbc-sfml 1.0.2: building configuration 
> [dynamic]
>      Building d-sfml-project-template ~master: building 
> configuration [application]
>       Linking d-sfml-project-template
>       Running bin/d-sfml-project-template
> Error Program exited with code -11

If I add "BindSFML_Static" to the DUB's version directive, I 
switch to static, which I guess you don't want. But then I also 
get a bunch of undefined errors:

> /usr/bin/ld: 
> /home/user/.dub/cache/d-sfml-project-template/~master/build/application-debug-TGcRCxHHanKq_MbfWLee8g/d-sfml-project-template.o: in function `_Dmain':
> /home/user/Downloads/dsfml/source/app.d:11: undefined reference 
> to `sfRenderWindow_create'
> ...
> collect2: error: ld returned 1 exit status
> Error: linker exited with status 1
> Error /usr/bin/dmd failed with exit code 1.

If you wanted static I would add and run libraries easy, like 
this:
```Json
	"libs": [
		"csfml-audio",
		"csfml-graphics"
	],
	"versions": [
		"SFML_Audio",
		"SFML_Graphics",
		"BindSFML_Static",
	]
}
```
In summary, DUB takes care of everything for us. It should be 
same in W$...

SDB at 79



More information about the Digitalmars-d-learn mailing list