-
HudsonBr
- Posts: 29
- Joined: Wed May 05, 2021 8:15 pm
Post
by HudsonBr » Wed Mar 13, 2024 9:08 pm
Hello, trying a SDL2 bm example for GC and getting this error:
Main.cpp
linking ... red.elf
C:/devkitPro/devkitPPC/bin/../lib/gcc/powerpc-eabi/13.2.0/../../../../powerpc-eabi/bin/ld.exe: C:/devkitPro/devkitPPC/bin/../lib/gcc/powerpc-eabi/13.2.0/../../../../powerpc-eabi/lib/crtmain.o: in function `__crtmain':
crtmain.c:(.text.__crtmain+0x3c): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [C:\devkitPro\devkitPPC/gamecube_rules:31: /c/projects/128-Bit/gamecube/red/red.elf] Error 1
make: *** [Makefile:102: build] Error 2
Code: Select all
#include <gccore.h>
#include <SDL2/sdl.h>
int main(void) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("error: Failed to initialize");
return 1;
}
// Create a window
SDL_Window *window = SDL_CreateWindow("GameCube SDL2 Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
if (!window) {
SDL_Log("SDL_CreateWindow Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
// Main loop
SDL_Event event;
int quit = 0;
while (!quit) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = 1;
}
}
}
// Cleanup
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
any clue ?
thanks in advance
..::Game Developer::..
-
HudsonBr
- Posts: 29
- Joined: Wed May 05, 2021 8:15 pm
Post
by HudsonBr » Fri Mar 15, 2024 9:08 pm
After trying some stuff i got to point i get the message
linking ... home.elf
/opt/devkitpro/devkitPPC/bin/../lib/gcc/powerpc-eabi/13.2.0/../../../../powerpc-eabi/bin/ld: /opt/devkitpro/portlibs/gamecube/lib/libSDL2main.a(SDL_gamecube_main.o): in function `main':
/home/davem/projects/devkitpro/pacman-packages/gamecube/SDL2/src/SDL2-2.28.5/_build/../src/main/gamecube/SDL_gamecube_main.c:49:(.text.startup.main+0x48): undefined reference to `SDL_main'
collect2: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/devkitPPC/gamecube_rules:31: /home/home.elf] Error 1
make: *** [Makefile:106: build] Error 2
using the Makefile with this configs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) `$(PREFIX)pkg-config --cflags sdl2`
CXXFLAGS = $(CFLAGS)
#LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--section-start,.init=0x81000000
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project -logg
#---------------------------------------------------------------------------------
LIBS := -lharfbuzz -lm -lfreetype -lbz2 -lpng16 -lz -ljpeg -laesnd -lfat -logc -lm -lvorbisidec -lmodplug -lstdc++ -lmpg123 -lopusfile -lopus -lFLAC -logg `$(PREFIX)pkg-config --libs sdl2`
and the code is:
Code: Select all
#include <gccore.h>
#include <SDL2/SDL.h>
int main(void) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("error: Failed to initialize");
return 1;
}
// Create a window
SDL_Window *window = SDL_CreateWindow("NGC SDL2 Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
if (!window) {
SDL_Log("SDL_CreateWindow Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
// Main loop
SDL_Event event;
int quit = 0;
while (!quit) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = 1;
}
}
}
// Cleanup
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
any help ?
thank in advance.
..::Game Developer::..
-
HudsonBr
- Posts: 29
- Joined: Wed May 05, 2021 8:15 pm
Post
by HudsonBr » Fri Mar 15, 2024 9:35 pm
I did this work around:
Code: Select all
int main(void);
int SDL_main(int argc, char *argv[]) {
return main();
}
int main(void) {...
and it is working.
..::Game Developer::..
Who is online
Users browsing this forum: No registered users and 2 guests