Linking with SDL3
  • Caterpillar
    Caterpillar
    Posts: 39 from 2018/6/9
    Could someone guide me on what linker params I should use for SDL3 please as I'm not having a lot of luck so far.

    I have a simple test application that creates a blank window and renderer, paints the window background and checks for quit or the escape key to exit. I figure if I'm going to try SDL then it may as well be SDL3. Converting the code from 2 to 3 was easy but I haven't managed to link the app yet.

    For SDL2 I have something like this (please note this is mostly typed, not copy/pasted so excuse any potential typos):
    Code:

    gcc -noixemul src/main.o gg:usr/local/lib/sdl2.a gg:ppc-morphos/lib/libnix/libGL.a

    That worked.

    For SDL3 I got (from sdl3-config):
    Code:

    gcc -noixemul src/main.o gg:usr/local/lib/sdl3.a gg:ppc-morphos/lib/libnix/libGL.a gg:ppc-morphos/lib/libpthread.a gg:ppc-morphos/lib/libc.a gg:ppc-morphos/lib/libm.a


    That spits out a bunch of errors, mostly about _ixbasearray.

    I'm not entirely new to C by any means but my main job is java so I'm not desperately familiar with all the different types of libs there are any why, for example, there are libb32 folders and so on.

    [ Edited by MartinW 18.05.2025 - 02:52 ]
  • »18.05.25 - 02:51
    Profile
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2396 from 2003/4/10
    From: France
    Hi MartinW,

    this is an example of Makefile for a SDL3 project i have ported:

    Code:
    #
    # Makefile for MorphOS C++ project
    #

    # Compiler and tools
    CC = ppc-morphos-gcc-11
    STRIP = ppc-morphos-strip

    # Build date for version info
    AMIGADATE = $(shell date +"%-d.%-m.%Y")
    DEFINE = -pthread -fsigned-char -D__AMIGADATE__=\"$(AMIGADATE)\"
    INCLUDE = -Iinclude
    -I/gg/usr/local/include
    -I/gg/usr/local/include/SDL3
    -I/gg/usr/local/include/SDL3_mixer
    -I/gg/usr/local/include/SDL3_ttf
    -I/gg/usr/local/include/SDL3_image

    # Compiler and linker flags
    CFLAGS = -noixemul -O2 -Wall -fsigned-char $(INCLUDE) $(DEFINE)
    LIBS = -noixemul -L/gg/usr/local/lib -lSDL3_mixer -lSDL3_image -lSDL3_ttf -lSDL3 -lGL -lstdc++ -pthread -lc -lm

    # Executable name
    TARGET = Wetris

    # Find all .cpp source files in src directory
    SRCS = $(wildcard src/*.c)

    # Generate corresponding object file names
    OBJS = $(SRCS:.c=.o)

    # Default target
    all: $(TARGET)

    # Link object files to create executable
    $(TARGET): $(OBJS)
    $(CC) $(LDFLAGS) $^ $(LIBS) -o $@
    # Uncomment to strip debug symbols:
    # $(STRIP) --strip-all $(TARGET)

    # Compile .c files to .o object files
    %.o: %.c
    $(CC) $(CFLAGS) -c $< -o $@

    # Remove all generated files
    clean:
    rm -f $(OBJS) $(TARGET)

    # Generate assembly dump for debugging
    dump:
    objdump --disassemble-all --reloc $(TARGET) > $(TARGET).s


    I hope could help you.
  • »18.05.25 - 03:18
    Profile Visit Website
  • Caterpillar
    Caterpillar
    Posts: 39 from 2018/6/9
    I think it might be that I'm lacking the flags '-pthread -fsigned-char', but I'm currently using Flow Studio and no matter where I add these in the settings they don't seem to get added to the Makefile. Maybe I'll go with my own Makefile and see if that helps.

    [EDIT] That works - thank you. Would be nice to work out how to get the same behaviour from Flow Studio but I can just use a custom Makefile for the moment.

    [ Edited by MartinW 18.05.2025 - 12:07 ]
  • »18.05.25 - 11:30
    Profile