Hello
Having always been on Amiga Classic, I finally took the Amiga-NG step by getting an A1222 (I am a AOS4.1 beginner)
Wanting to take advantage of the power of this one, I would like to develop in SDL2 on it and I must admit that I am having a little trouble setting this up (this is different from Windows).
I'm currently stuck with SDL Image
For information :
- I use Cubic IDE for dev
- I installed sdk 54.16
- I use GCC 4.2.4
- I installed SDL2
- I also installed libSDL2_image, libSDL2_ttf, libjpeg, libwebp, libiff, libsmpeg2, libsdl2_net, libsdl2_mixer, libsdl2_gfx each time using the Autoinstall
It works correctly to compile in C and SDL2, but error for the SDL_image
Here is my code (which works on windows)
#include
#include
#include
#include
#define SDL_ASSERT_LEVEL 2
int test = 1;
SDL_Texture *LoadTexture(SDL_Renderer *renderer, char *path)
{
SDL_Texture *texture = NULL;
texture = IMG_LoadTexture(renderer, path);
if (texture == NULL)
{
printf("Unable to create texture from %s! SDL Error: %s\n", path, SDL_GetError());
return NULL;
}
return texture;
}
int main(int argc, char *argv[])
{
setvbuf(stdout, NULL, _IONBF, 0);
printf("Start\n");
#ifdef DEBUG
printf("Debug mode\n");
#endif
int iGameWidth = 1024, iGameHeight = 768;
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
printf("Failed to initialise SDL\n");
return -1;
}
SDL_Window *window = SDL_CreateWindow("A1222 - test SDL2 by JBAM",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
iGameWidth,
iGameHeight,
SDL_WINDOW_SHOWN);
if (window == NULL)
{
SDL_Log("Could not create a window: %s", SDL_GetError());
return -1;
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == NULL)
{
SDL_Log("Could not create a renderer: %s", SDL_GetError());
return -1;
}
else
{
int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
return -1;
}
}
// fond
SDL_Texture *texFond;
texFond = LoadTexture(renderer, "gfx/fond.png");
SDL_QueryTexture(texFond, NULL, NULL, 0, 0);
// boingball
SDL_Texture *texBoingBall;
int iTexBoingBall_w, iTexBoingBall_h;
float iTexBoingBall_x = 0, iTexBoingBall_y = 0, iTexBoingBall_vx = 4, iTexBoingBall_vy = 4;
texBoingBall = LoadTexture(renderer, "gfx/boingball.png");
SDL_QueryTexture(texBoingBall, NULL, NULL, &iTexBoingBall_w, &iTexBoingBall_h);
// GAME LOOP
while (test == 1)
{
SDL_Event event;
if (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
test = 0;
break;
}
}
iTexBoingBall_x += iTexBoingBall_vx;
iTexBoingBall_y += iTexBoingBall_vy;
if (iTexBoingBall_x + iTexBoingBall_w > iGameWidth)
{
iTexBoingBall_vx = -iTexBoingBall_vx;
iTexBoingBall_x = iGameWidth - iTexBoingBall_w;
}
if (iTexBoingBall_x iGameHeight)
{
iTexBoingBall_vy = -iTexBoingBall_vy;
iTexBoingBall_y = iGameHeight - iTexBoingBall_h;
}
if (iTexBoingBall_y < 0)
{
iTexBoingBall_vy = -iTexBoingBall_vy;
iTexBoingBall_y = 0;
}
// Efface l'écran
SDL_RenderClear(renderer);
// dessine le fond
SDL_Rect rectDestFond = {0, 0, 1024, 768};
SDL_RenderCopy(renderer, texFond, NULL, &rectDestFond);
// Dessine la BoingBall
SDL_Rect rectDestBoingBall = {iTexBoingBall_x, iTexBoingBall_y, iTexBoingBall_w, iTexBoingBall_h};
SDL_RenderCopy(renderer, texBoingBall, NULL, &rectDestBoingBall);
// Présente l'écran
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_DestroyTexture(texBoingBall);
IMG_Quit();
SDL_Quit();
return 0;
}
here is my makefile
EXE = bin/gcc-amigaos4-latest/Boing-ball
OBJDIR = o/gcc-amigaos4-latest/
SDK_PATH = SDK:local/newlib/
CC = gcc
LD= gcc
CXXFLAGS= -Wall -O2 -I$(SDK_PATH)include -I$(SDK_PATH)include/SDL2
all : $(EXE)
$(OBJDIR)main.o : main.c
$(CC) $(shell gccprefs) -c $(CXXFLAGS) -o $(OBJDIR)main.o main.c
OBJS = $(OBJDIR)main.o
$(EXE) : $(OBJS)
$(LD) $(CXXFLAGS) $(OBJS) -lSDL2 -lSDL2_image -LSDL2_ttf $(shell gccprefs) -o $(EXE)
strip:
strip --remove-section=.comment $(EXE)
clean:
-delete $(EXE)
-delete $(OBJDIR)\*.o
and here is the error I got
gcc -Wall -O2 -ISDK:local/newlib/include -ISDK:local/newlib/include/SDL2 o/gcc-amigaos4-latest/main.o -lSDL2 -lSDL2_image -LSDL2_ttf -lauto -o bin/gcc-amigaos4-latest/Boing-ball
/SDK/local/newlib/lib/libSDL2_image.a(libSDL2_image_la-IMG_tif.o): In function `IMG_LoadTIF_RW':
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:173: undefined reference to `TIFFClientOpen'
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:179: undefined reference to `TIFFGetField'
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:180: undefined reference to `TIFFGetField'
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:186: undefined reference to `TIFFReadRGBAImageOriented'
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:199: undefined reference to `TIFFClose'
/home/michael/SDL2_image-2.8.2/src/IMG_tif.c:189: undefined reference to `TIFFClose'
/SDK/local/newlib/lib/libSDL2_image.a(libSDL2_image_la-IMG_webp.o): In function `IMG_LoadWEBP_RW':
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:199: undefined reference to `WebPGetFeaturesInternal'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:217: undefined reference to `WebPDecodeRGBAInto'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:219: undefined reference to `WebPDecodeRGBInto'
/SDK/local/newlib/lib/libSDL2_image.a(libSDL2_image_la-IMG_webp.o): In function `IMG_LoadWEBPAnimation_RW':
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:294: undefined reference to `WebPGetFeaturesInternal'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:307: undefined reference to `WebPDemuxInternal'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:311: undefined reference to `WebPDemuxGetI'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:327: undefined reference to `WebPDecodeRGBAInto'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:316: undefined reference to `WebPDemuxGetFrame'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:334: undefined reference to `WebPDecodeRGBInto'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:357: undefined reference to `WebPDemuxDelete'
/home/michael/SDL2_image-2.8.2/src/IMG_webp.c:345: undefined reference to `WebPDemuxDelete'
make: *** [bin/gcc-amigaos4-latest/Boing-ball] Error 1
Done.
Thanking you for the help you can give me