www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to statically link Derelict SDL2 satellite libs

reply eskaypee <eskaypee example.com> writes:
I'm on Linux 64 bit, all SDL libraries (-dev versions) are 
installed, dub is set up with:

     "dependencies": {
     "derelict-sdl2": "~>3.0.0-beta"
     },
     "subConfigurations": {
     "derelict-sdl2": "derelict-sdl2-static"
     },
     "libs":
     ["sdl2"]

All the SDL core library functions work fine but when I try to 
use SDL_image library's IMG_Load() or IMG_LoadTexture() I get a 
linker error, for example:

undefined reference to `IMG_LoadTexture'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.

I have:
import derelict.sdl2.image;

at the top of my program. I'm guessing that the "libs" section of 
my dub subConfiguration needs to include the name of the image 
satellite library?
Dec 13 2017
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 13 December 2017 at 20:59:41 UTC, eskaypee wrote:
 I'm on Linux 64 bit, all SDL libraries (-dev versions) are 
 installed, dub is set up with:

     "dependencies": {
     "derelict-sdl2": "~>3.0.0-beta"
     },
     "subConfigurations": {
     "derelict-sdl2": "derelict-sdl2-static"
     },
     "libs":
     ["sdl2"]
 I'm guessing that the "libs" section of my dub subConfiguration 
 needs to include the name of the image satellite library?
Yes, you need to link with SDL_image. https://www.libsdl.org/projects/SDL_image/
Dec 14 2017
parent reply eskaypee <eskaypee example.com> writes:
On Thursday, 14 December 2017 at 14:45:51 UTC, Mike Parker wrote:
 Yes, you need to link with SDL_image.
Sorry Mike, just noticed the end of my original question was missing: I have SDL_Image installed (dev version) but can't see how to refer/add it to the "libs" section (if that's how it gets linked in?). Totally new to D, dub and SDL and using only a text editor rather than an IDE so a bit befuddled!
Dec 14 2017
parent reply Mike Parker <aldacron gmail.com> writes:
On Thursday, 14 December 2017 at 15:07:12 UTC, eskaypee wrote:
 On Thursday, 14 December 2017 at 14:45:51 UTC, Mike Parker 
 wrote:
 Yes, you need to link with SDL_image.
Sorry Mike, just noticed the end of my original question was missing: I have SDL_Image installed (dev version) but can't see how to refer/add it to the "libs" section (if that's how it gets linked in?). Totally new to D, dub and SDL and using only a text editor rather than an IDE so a bit befuddled!
Should be: "libs" : [ "SDL2_image", "SDL2"]
Dec 14 2017
parent eskaypeee <eskaypee example.com> writes:
On Thursday, 14 December 2017 at 15:43:22 UTC, Mike Parker wrote:
 Should be:

 "libs" : [ "SDL2_image", "SDL2"]
Thank you, it now works. I think I did try that but in lower case, which didn't work. I was following the example dub file on this page: http://derelictorg.github.io/packages/sdl2/ which uses lower case... "libs": ["sdl2"] However, I now find that I can reference that core library in upper or lower case in dub.json whereas 'SDL2_image' has to be in that precise case. Maybe something to do with symlinks on my computer...?
Dec 14 2017