Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
57 user(s) are online (36 user(s) are browsing Forums)

Members: 2
Guests: 55

smf, MickJT, more...

Headlines

 
  Register To Post  

SDL2_image on A1222
Just popping in
Just popping in


See User information
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 *rendererchar *path)
{
    
SDL_Texture *texture NULL;

    
texture IMG_LoadTexture(rendererpath);
    if (
texture == NULL)
    {
        
printf("Unable to create texture from %s! SDL Error: %s\n"pathSDL_GetError());
        return 
NULL;
    }

    return 
texture;
}

int main(int argcchar *argv[])
{
    
setvbuf(stdoutNULL_IONBF0);

    
printf("Start\n");
#ifdef DEBUG
    
printf("Debug mode\n");
#endif

    
int iGameWidth 1024iGameHeight 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, -1SDL_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(texFondNULLNULL00);

    
// boingball
    
SDL_Texture *texBoingBall;
    
int iTexBoingBall_wiTexBoingBall_h;
    
float iTexBoingBall_x 0iTexBoingBall_y 0iTexBoingBall_vx 4iTexBoingBall_vy 4;
    
texBoingBall LoadTexture(renderer"gfx/boingball.png");
    
SDL_QueryTexture(texBoingBallNULLNULL, &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 = {001024768};
        
SDL_RenderCopy(renderertexFondNULL, &rectDestFond);

        
// Dessine la BoingBall
        
SDL_Rect rectDestBoingBall = {iTexBoingBall_xiTexBoingBall_yiTexBoingBall_wiTexBoingBall_h};
        
SDL_RenderCopy(renderertexBoingBallNULL, &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.main.c
    
$(CC) $(shell gccprefs) -$(CXXFLAGS) -o  $(OBJDIR)main.o main.c

    
OBJS 
= $(OBJDIR)main.o

$(EXE) : $(OBJS)
    $(
LD) $(CXXFLAGS) $(OBJS) -lSDL2 -lSDL2_image -LSDL2_ttf $(shell gccprefs) -$(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.-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:180undefined 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:189undefined 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:217undefined 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:294undefined 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:327undefined 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:357undefined 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

Go to top
Re: SDL2_image on A1222
Amigans Defender
Amigans Defender


See User information
@MisterJBAM

libSDL2_image has a few dependencies that have to be linked against, too. You seem to be missing libtiff and the libwebp libraries.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: SDL2_image on A1222
Just popping in
Just popping in


See User information
@trixie
The problem is that they are well installed.

I used autoinstall and they are well in SDK:local

so I don't understand why it doesn't work

Go to top
Re: SDL2_image on A1222
Just can't stay away
Just can't stay away


See User information
@MisterJBAM

path of such files (.a/.so)?

I use this on my makefile:
CXXLIB = -LSDK:SDK:local/newlib/lib/

LFLAGS = $(CXXLIB) -lSDL2_image -ltiff -lwebp -lwebpdemux -lsharpyuv -lpng16 -ljpeg -lSDL2 -lz -lpthread -athread=native


being SDK:SDK:local/newlib/lib/ my path to the SDL2 and SDL_image .a/.so files (and its dependencies)

Go to top
Re: SDL2_image on A1222
Site Builder
Site Builder


See User information
Quote:
- I installed sdk 54.16
- I use GCC 4.2.4


GCC 4.x is not part of the SDK 54.16? How did you install it and why you prefer to use that old version? Is there some kind of a benefit using it?

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: SDL2_image on A1222
Home away from home
Home away from home


See User information
@MisterJBAM

gcc on amiga is not very smart when it comes to finding (perfectly) installed deps.

just like the others have written, you need to write out every dependant library in the linker line, otherwise it will always error.

Also order is important, if something complains, just shuffle the deps around, tedious and annoying, but ... well, amiga

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: SDL2_image on A1222
Amigans Defender
Amigans Defender


See User information
@MisterJBAM

Quote:
The problem is that they are well installed.

Yes, but your makefile doesn't seem to include the relevant linking flags...

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: SDL2_image on A1222
Just popping in
Just popping in


See User information
@jabirulo

Quote:
path of such files (.a/.so)?


SDK:local/newlib/lib

I tried what you gave me but to no avail.
could you please share an entire makefile?

@walkero

GCC 4.2.4 was installed by default (maybe with Cubic), is there a more recent version?

@Raziel

I'm starting to realize these problems

Go to top
Re: SDL2_image on A1222
Amigans Defender
Amigans Defender


See User information
@MisterJBAM

Quote:
GCC 4.2.4 was installed by default (maybe with Cubic), is there a more recent version?

Absolutely! The latest SDK gives you GCC 6, 8, 10 and 11. You should use at least GCC 8, unless you need to compile for the A1222's SPE, in which case you'll need GCC 6 (because SPE support was dropped in later versions).

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: SDL2_image on A1222
Just can't stay away
Just can't stay away


See User information
@MisterJBAM

PROG game

OS 
:= $(shell uname)

ifeq ($(strip $(OS)),AmigaOS)
    
AMIGADATE = $(shell c:date LFORMAT %d.%m.%Y)
    
CXXINC = -ISDK:local/newlib/include/SDL2
    CXXLIB 
= -LSDK:SDK:local/newlib/lib/
else
    
AMIGADATE = $(shell date +"%-d.%-m.%Y")
    
#CXXINC = -I/usr/local/amiga/ppc-amigaos/SDK/local/common/include
    #CXXLIB = -L/usr/local/amiga/ppc-amigaos/SDK/local/newlib/lib
endif

DEBUG = -DDEBUG


CFLAGS 
= -Wall -Wswitch -gstabs $(DEBUG) -D__AMIGADATE__=\"$(AMIGADATE)\" $(CXXINC)
LFLAGS = $(CXXLIB) -lSDL2_image -ltiff -lwebp -lwebpdemux -lsharpyuv -lpng16 -ljpeg -lSDL2 -lz -lpthread -athread=native


OBJS 
main.o input.o entities.o gui.o


CXX 
ppc-amigaos-gcc
STRIP 
ppc-amigaos-strip
DELETE 
delete


# top-level rule to create the program.
all: $(PROG)

# compiling other source files.
%.o: %.%.h
    
$(CXX) $(CFLAGS) -$@ -$<

# linking the program.
$(PROG): $(OBJS)
    $(
CXX) $(OBJS) -$(PROG).debug $(LFLAGS)
    $(
STRIP) -$(PROG) $(PROG).debug

# cleaning everything that can be automatically recreated with "make".
clean:
    $(
DELETE) $(PROG) $(PROG).debug $(OBJS)

Go to top
Re: SDL2_image on A1222
Site Builder
Site Builder


See User information
Quote:
GCC 4.2.4 was installed by default (maybe with Cubic), is there a more recent version?


Yeah, CubicIDE has an old version. I do not let the plugin do the SDK installation.
SDK has multiple different versions which you can select with its installer. There is GCC 8, 10, 11 and 6 for SPE compatibility (A1222).

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: SDL2_image on A1222
Just popping in
Just popping in


See User information
@jabirulo

Thanks, I'll take the time to look at that and repeat tests

@walkero

Quote:
There is GCC 8, 10, 11 and 6 for SPE compatibility (A1222).


thanks for the info, I will correct that

Go to top
Re: SDL2_image on A1222
Not too shy to talk
Not too shy to talk


See User information
@walkeroQuote:
walkero wrote:[quote]
SDK has multiple different versions which you can select with its installer. There is GCC 8, 10, 11 and 6 for SPE compatibility (A1222).


I am using gcc v.6 for SPE programming.
Please, are there any reason to use v.8 or v.10 for standard powerpc codes?
Had they some advantage / feature over v.11 ?

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project