ps2dev / ps2sdk-ports

Ports of useful libraries to PS2SDK
Other
106 stars 43 forks source link

error compiling an SDL2 app #95

Closed SrWither closed 1 year ago

SrWither commented 1 year ago

i have this simple code: main.cpp

#include <SDL2/SDL.h>
#include <stdio.h>

#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

int main(int argc, char* args[]) {
  SDL_Window* window = NULL;
  SDL_Surface* screenSurface = NULL;
  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError());
    return 1;
  }
  return 0;
}

Makefile

EE_BIN=test.elf
EE_OBJS=main.o

EE_LIBS=-ldma -lgraph -ldraw -lkernel -ldebug -lps2_drivers -lgskit -lgskit_toolkit -ldmakit -lSDL2 -lSDL2main -lSDL2_test -lSDL2_mixer

EE_CXXFLAGS += -Wall -I$(PS2SDK)/ports/include -I$(GSKIT)/include
EE_LDFLAGS = -L$(PSDSDK)/ee/common/lib -L$(PS2SDK)/ee/lib -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib

GSKIT=/usr/local/ps2dev/gsKit
PS2SDK=/usr/local/ps2dev/ps2sdk

include $(PS2SDK)/samples/Makefile.eeglobal
include $(PS2SDK)/samples/Makefile.pref

clean:
    rm -rf $(EE_BIN) $(EE_OBJS)

executing the make command returns this output:

mips64r5900el-ps2-elf-gcc -T/usr/local/ps2dev/ps2sdk/ee/startup/linkfile -O2 -o test.elf main.o -L/usr/local/ps2dev/ps2sdk/ee/lib -Wl,-zmax-page-size=128 -L/ee/common/lib -L/usr/local/ps2dev/ps2sdk/ee/lib -L/usr/local/ps2dev/ps2sdk/ports/lib -L/usr/local/ps2dev/gsKit/lib  -ldma -lgraph -ldraw -lkernel -ldebug -lps2_drivers -lgskit -lgskit_toolkit -ldmakit -lSDL2 -lSDL2main -lSDL2_test -lSDL2_mixer
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_CloseDevice':
SDL_ps2audio.c:(.text+0x150): undefined reference to `audsrv_stop_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_WaitDevice':
SDL_ps2audio.c:(.text+0x198): undefined reference to `audsrv_wait_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_PlayDevice':
SDL_ps2audio.c:(.text+0x1c8): undefined reference to `audsrv_play_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_OpenDevice':
SDL_ps2audio.c:(.text+0x298): undefined reference to `audsrv_set_format'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_ps2audio.c:(.text+0x2a4): undefined reference to `audsrv_set_volume'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickClose':
SDL_sysjoystick.c:(.text+0x9c): undefined reference to `padPortClose'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickUpdate':
SDL_sysjoystick.c:(.text+0x108): undefined reference to `padGetState'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x118): undefined reference to `padRead'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickRumble':
SDL_sysjoystick.c:(.text+0x2f4): undefined reference to `padSetActDirect'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x34c): undefined reference to `padSetActAlign'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickOpen':
SDL_sysjoystick.c:(.text+0x420): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickInit':
SDL_sysjoystick.c:(.text+0x4c8): undefined reference to `mtapPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x4d8): undefined reference to `mtapPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x50c): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x59c): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(init_ps2_joystick_driver.o): in function `init_joystick_driver':
(.text+0x84): undefined reference to `mtapInit'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: (.text+0x94): undefined reference to `padInit'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(deinit_ps2_joystick_driver.o): in function `deinit_joystick_driver':
(.text+0x14): undefined reference to `padEnd'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(init_ps2_audio_driver.o): in function `init_audio_driver':
(.text+0x6c): undefined reference to `audsrv_init'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(deinit_ps2_audio_driver.o): in function `deinit_audio_driver':
(.text+0xc): undefined reference to `audsrv_quit'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/ps2dev/ps2sdk/samples/Makefile.eeglobal:82: test.elf] Error 1

I have the entire environment in docker with the image of ps2dev:latest

israpps commented 1 year ago

Undefined references to both audio and PADMAN related stuff it seems

SrWither commented 1 year ago

I put -lps2_drivers at the end of LD_LIBS. and now compile

fjtrujy commented 1 year ago

i have this simple code: main.cpp

#include <SDL2/SDL.h>
#include <stdio.h>

#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480

int main(int argc, char* args[]) {
  SDL_Window* window = NULL;
  SDL_Surface* screenSurface = NULL;
  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError());
    return 1;
  }
  return 0;
}

Makefile

EE_BIN=test.elf
EE_OBJS=main.o

EE_LIBS=-ldma -lgraph -ldraw -lkernel -ldebug -lps2_drivers -lgskit -lgskit_toolkit -ldmakit -lSDL2 -lSDL2main -lSDL2_test -lSDL2_mixer

EE_CXXFLAGS += -Wall -I$(PS2SDK)/ports/include -I$(GSKIT)/include
EE_LDFLAGS = -L$(PSDSDK)/ee/common/lib -L$(PS2SDK)/ee/lib -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib

GSKIT=/usr/local/ps2dev/gsKit
PS2SDK=/usr/local/ps2dev/ps2sdk

include $(PS2SDK)/samples/Makefile.eeglobal
include $(PS2SDK)/samples/Makefile.pref

clean:
  rm -rf $(EE_BIN) $(EE_OBJS)

executing the make command returns this output:

mips64r5900el-ps2-elf-gcc -T/usr/local/ps2dev/ps2sdk/ee/startup/linkfile -O2 -o test.elf main.o -L/usr/local/ps2dev/ps2sdk/ee/lib -Wl,-zmax-page-size=128 -L/ee/common/lib -L/usr/local/ps2dev/ps2sdk/ee/lib -L/usr/local/ps2dev/ps2sdk/ports/lib -L/usr/local/ps2dev/gsKit/lib  -ldma -lgraph -ldraw -lkernel -ldebug -lps2_drivers -lgskit -lgskit_toolkit -ldmakit -lSDL2 -lSDL2main -lSDL2_test -lSDL2_mixer
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_CloseDevice':
SDL_ps2audio.c:(.text+0x150): undefined reference to `audsrv_stop_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_WaitDevice':
SDL_ps2audio.c:(.text+0x198): undefined reference to `audsrv_wait_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_PlayDevice':
SDL_ps2audio.c:(.text+0x1c8): undefined reference to `audsrv_play_audio'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_ps2audio.c.obj): in function `PS2AUDIO_OpenDevice':
SDL_ps2audio.c:(.text+0x298): undefined reference to `audsrv_set_format'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_ps2audio.c:(.text+0x2a4): undefined reference to `audsrv_set_volume'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickClose':
SDL_sysjoystick.c:(.text+0x9c): undefined reference to `padPortClose'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickUpdate':
SDL_sysjoystick.c:(.text+0x108): undefined reference to `padGetState'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x118): undefined reference to `padRead'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickRumble':
SDL_sysjoystick.c:(.text+0x2f4): undefined reference to `padSetActDirect'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x34c): undefined reference to `padSetActAlign'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickOpen':
SDL_sysjoystick.c:(.text+0x420): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libSDL2.a(SDL_sysjoystick.c.obj): in function `PS2_JoystickInit':
SDL_sysjoystick.c:(.text+0x4c8): undefined reference to `mtapPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x4d8): undefined reference to `mtapPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x50c): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: SDL_sysjoystick.c:(.text+0x59c): undefined reference to `padPortOpen'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(init_ps2_joystick_driver.o): in function `init_joystick_driver':
(.text+0x84): undefined reference to `mtapInit'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: (.text+0x94): undefined reference to `padInit'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(deinit_ps2_joystick_driver.o): in function `deinit_joystick_driver':
(.text+0x14): undefined reference to `padEnd'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(init_ps2_audio_driver.o): in function `init_audio_driver':
(.text+0x6c): undefined reference to `audsrv_init'
/usr/local/ps2dev/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /usr/local/ps2dev/ps2sdk/ports/lib/libps2_drivers.a(deinit_ps2_audio_driver.o): in function `deinit_audio_driver':
(.text+0xc): undefined reference to `audsrv_quit'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/ps2dev/ps2sdk/samples/Makefile.eeglobal:82: test.elf] Error 1

I have the entire environment in docker with the image of ps2dev:latest

For your example where you just need the next libraries in THIS SPECIFIC ORDER:

EE_LIBS += -lSDL2main -lSDL2 -lpatches -lgskit -ldmakit -lps2_drivers