Hi dugan, yes it is the same person. I have found a solution which works.
If you add
Code:
--enable-jpg-shared=no
to the configure line in your slackbuild, then loading jpgs works with slackware 14.2
On hindsight, it is obvious that enable-jpg-shared=yes (the default if not specified) will not work as the system (ie slackware 14.2) library is different from the one included in the sdl2_image source code. The only way to make that work would be either overwriting the default slackware jpeg library and headers(probably not a preferred option), or to replace the sdl2_image jpg source with the slackware turbo-jpg source and hope it works.
note: this is not an issue with earlier versions of slackware which don't use the turbo-jpg library.
If you still would like me to chase the libsdl mailing list I can do so, although from the reasoning above, I don't see how the source could easily be changed to accommodate both jpg libraries at the same time.
Regards, Tim
test case program is listed below,
Code:
#include <stdbool.h>
#include <SDL.h>
#include <SDL_image.h>
int main(int argc, char ** argv)
{
bool quit = false;
SDL_Event event;
SDL_Init(SDL_INIT_VIDEO);
IMG_Init(IMG_INIT_JPG);
SDL_Window * window = SDL_CreateWindow("SDL2 Displaying Image",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
/* SDL_Surface * image = SDL_LoadBMP("image.bmp"); */
SDL_Surface *image;
image = IMG_Load("image.jpg");
if (!image) {
printf("IMG_Load: %s\n", IMG_GetError());
}
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, image);
while (!quit)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
quit = true;
break;
}
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(texture);
SDL_FreeSurface(image);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
IMG_Quit();
SDL_Quit();
return 0;
}
makefile for above is below
Code:
LIBS = `pkg-config --libs sdl2 SDL2_image`
CFLAGS = `pkg-config --cflags sdl2 SDL2_image`
OBJS = testprog.o
VERSION = 1.0
DATADIR += ""
PROG = testprog
# top level rule to create the program
ALL = $(PROG)
all: $(ALL)
#compiling other source files
%.c: src/%.c src/*.h
$(CC) $(CFLAGS) -c -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(DATADIR)\"
$<
#linking the program
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(PROG) $(LIBS)
clean:
$(RM_ $(OBJS) $(ALL)
test program requires a image.jpg picture in the same directory as the program