EXL / NXEngine

A port of the open-source rewrite Cave Story game engine for various platforms. Original author is Caitlin "rogueeve" Shaw, https://nxengine.sourceforge.io/
https://exlmoto.ru/nxengine/
GNU General Public License v3.0
170 stars 35 forks source link

sdllib not found,could someone help me? #6

Closed kingling closed 3 years ago

kingling commented 3 years ago

I'm a novice. Can someone help me? I just want to run my own modified version on my gkd350h. I build mipsel-linux-g++ with buildroot and copy libs to /opt then try make -f Makefile.dingux but got this.

2020-12-22 20-23-29屏幕截图 2020-12-22 20-24-35屏幕截图

I've tried change -lSDL→-llibSDL and then try SDLmain.a but neither worked,still can't find it or get some functions undefined. Is there something wrong with my SDLlibs? Help me please.

EXL commented 3 years ago

Hi, @kingling

What toolchain are you using?

kingling commented 3 years ago

Thank you for your reply. I build toolchain follow this page https://blog.csdn.net/gubenpeiyuan/article/details/7895469 on ubuntu 20.04, It took quite a long time, but thank goodness the file mipsel-linux-g++ seems to work. then download ftp://ftp.ritmixrussia.ru/Ritmix/sw/RZX-50_SDK.zip and unzip&tar to /opt folder,and try make but got that picture.

EXL commented 3 years ago

@kingling I'm not sure if mixing different toolchains is a good way to go.

But try change line №19 in Makefile.dingux file from:

LIBS          = -lSDLmain -lSDL -lSDL_ttf -lSDL_mixer 

to:

LIBS          = -L/opt/mipsel-linux-uclibc/usr/lib -lSDLmain -lSDL -lSDL_ttf -lSDL_mixer 
kingling commented 3 years ago

After modification line 19 in Makefile.dingux It seems to have solved the problem but i got this: ......mipsel-buildroot-linux-uclibc/bin/ld: cannot find /lib/libc.so.0 ......mipsel-buildroot-linux-uclibc/bin/ld: cannot find /usr/lib/uclibc_nonshared.a ......mipsel-buildroot-linux-uclibc/bin/ld: cannot find /lib/ld-uClibc.so.0 i think the files needed should be use on mipsel, these files were found in /opt/mipsel-linux-uclibc/lib or .../usr/lib,but not in ubuntu's /lib or /usr/lib, i tried add a file contains "/opt/mipsel-linux-uclibc/lib(also /usr/lib)" named mipsel.conf to /etc/ld.so.conf.d to tell ld where the files needed is, however it doesn't work. So i copy ALL FILES to ubuntu's /lib dir,and then make again, the 3 messages above disappear and more appear...like this: ld:warning:libiconv.so.2(and other .so) needed by /opt/.../libSDL.so not found, them some function in SDL(ttf,mixer)libs undefined.I had copy all of libs. Actually, before I download and make buildroot, I tried the mipsel-linux-g++ found in /opt/mipsel-linux-uclibc/usr/bin,it tell me there are no such file or dir, I really see it and add the PATH, I'm confused and don't know what to do now. I've taken up too much of your time, but please give me some advice in your spare time.

EXL commented 3 years ago

@kingling

So i copy ALL FILES to ubuntu's /lib dir,and then make again, the 3 messages above disappear and more appear...

This is very dangerous and incorrect way. You can break the OS by replaced {x86,x86_64} system libraries like libc.so with mipsel ones!

Can you try building your application using the RZX-50 SDK and not your buildroot toolchian? Perhaps it will work on your piece of MIPS hardware like GKD350H.

Recipe:

cd ~/Downloads/
curl -LOJ ftp://ftp.ritmixrussia.ru/Ritmix/sw/RZX-50_SDK.zip
unzip RZX-50_SDK.zip
sudo tar -jxvf SDK_for_ritmix_rzx-50/Toolchain-mipsel-linux-uclib/mipsel-linux-uclibc.tar.bz2 -C /opt/
git clone https://github.com/EXL/NXEngine --depth=1 -b master
cd NXEngine/
PATH=/opt/mipsel-linux-uclibc/usr/bin/:$PATH make -f Makefile.dingux

Then copy nx.dge which is executable file for Linux MIPS.

EXL commented 3 years ago

@kingling

Useful links for you on Dingoonity forums:

  1. Game Kiddy GKD350H Handheld Game Console Release
  2. My ports to the GKD350H

I think you should ask the GKD350H toolchain and SDK with all useful libraries like SDL there Or ask for it some developers like @gameblabla

gameblabla commented 3 years ago

Hi, i'm using my own statically linked toolchain as the rootfs it came with has numerous issues so this was the only way to avoid it while still keeping the system intact. https://github.com/gcw0/buildroot-static

Git clone it and compile it with make sdk. Then take the toolchain in output/host and put it in /opt/350h-toolchain or /opt/gcw0-toolchain

The makefile that came with NXEngine is kinda bad but still, it shouldn't be too hard to modifiy it. Just make sure that CC and CXX are pointing to the mipsel toolchain.

Also using the RZX-50's toolchain won't work, it's not even the same arch. (mips32r1 vs mips32r2. One being softfloat and the other being hardfloat) If you don't want to compile the toolchain, you can also use the GCW0's toolchain as it's mostly compatible with it (albeit a bit old) : http://www.gcw-zero.com/files/opendingux-gcw0-toolchain.2014-08-20.tar.bz2

kingling commented 3 years ago

Thank you very much for your help,@EXL @gameblabla but I download the gcw0-toolchain and unzip to /opt then add /opt/gcw0-toolchain/usr/bin to PATH,then I tried mipsel-linux-g++,it still tells me bash: /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++: no such file or dir... I reinstall ubuntu20.04 and try again,but still. follow EXL‘s script in the new os it show "make: mipsel-linux-g++: command not found. I think there maybe some problems with PATH? I'll try linuxmint or other os later.

kingling commented 3 years ago

Dear sir, I install linuxmint 20 and run @EXL's script again,result is thesame,mipsel-linux-g++ not found. 截图_2020-12-23_16-36-05 then I build toolchain provide by gameblabla on UOS based on ARM64(I install linuxmint on a 1037u pad,it maybe too weak for the task),and put the outputs to /opt, then add PATH, the mipsel-linux-g++(on arm64)worked, then modify Makefile.dingux like this: CC = mipsel-linux-gcc CXX = mipsel-linux-g++ DEFINES = -D_320X240 -D_DINGUX -D_SDL_MIXER # -D_L10N_CP1251 CFLAGS = -pipe -mips32 -O2 -mabi=32 -mhard-float -ffast-math -G0 $(DEFINES) #-msoft-float CXXFLAGS = -pipe -mips32 -O2 -O2 -mabi=32 -mhard-float -ffast-math -G0 $(DEFINES) #-msoft-float INCPATH = -I/opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/include -I/opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/include/SDL -I. LINK = mipsel-linux-g++ LFLAGS = -Wl,-O1 -Wl,-rpath,/opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/lib LIBS = -L/opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/lib -lSDLmain -lSDL -lSDL_ttf -lSDL_mixer STRIP = mipsel-linux-strip DEL_FILE = rm -f Then make and got: /opt/gcw0-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-musl/10.2.0/../../../../mipsel-buildroot-linux-musl/bin/ld: /opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/lib/libSDL_mixer.a(playmidi.o):(.bss+0x1e830): multiple definition of channel'; sslib.o:(.bss+0xc): first defined here /opt/gcw0-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-musl/10.2.0/../../../../mipsel-buildroot-linux-musl/bin/ld: /opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/lib/libSDL.a(SDL_alsa_audio.o): in functionALSA_CloseAudio': SDL_alsa_audio.c:(.text+0x16c): undefined reference to snd_pcm_close' /opt/gcw0-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-musl/10.2.0/../../../../mipsel-buildroot-linux-musl/bin/ld: /opt/gcw0-toolchain/mipsel-buildroot-linux-musl/sysroot/usr/lib/libSDL.a(SDL_alsa_audio.o): in functionALSA_finalize_hardware.isra.0': and other undefined references, could you please teach me what to do next?

EXL commented 3 years ago

@kingling

Dear sir, I install linuxmint 20 and run @EXL's script again,result is thesame,mipsel-linux-g++ not found.

I think this problem appears because you try to run 32-bit program (mipsel-linux-g++) on 64-bit system. You should install some 32-bit support libraries e.g. apt install libc6:i386 to your system to be able to run tools from ancient compiled toolchains on modern linux distros. Or just use some old and 32-bit version of Ubuntu or Linux Mint in a virtual machines.

See more information on Linux Mint forums Help please installing 32-bit C libraries on a 64-bit system.

multiple definition of 'channel'

It looks like a name conflict in the global scope. Try to change line №21 in sound/sslib.cpp file from this:

SSChannel channel[SS_NUM_CHANNELS];

To this:

static SSChannel channel[SS_NUM_CHANNELS];

kingling commented 3 years ago

Thank you for your patience @EXL @gameblabla . After installed the 32-bit library and make a few changes to the makefile.dingux, the two toolchains compiled nx.dge successfully. I'll test them on my device later. There should be no problem. Thank you.

EXL commented 3 years ago

@kingling

I'll test them on my device later.

Please report results of running these files here later.

kingling commented 3 years ago

Dear @EXL all nx.dge crashs on my device(GKD350H) ... I compiled them: nx1.dge(rzx50toolchain,-msoftfloat); nx2.dge(rzx50toolchain, -mhardfloat, there were some warnings:xxx.o use hard float, nx.dge use soft float); nx3.dge(gcw0toolchain,-mhardfloat). I copy them to an output folder which is unpacked from cavestroy.opk that runs well on my device. Then try exec the dge files from the file manager installed on the device. They all show a dark screen and then crash to file manager. then I notice there is a debug.txt ... I open and see "loading settings ..." so I delete the setting file and run dges again, this time, they all showed a picture said need decompress resources, but the color of the characters was a little strange, and the background of the letters was purple. debug.txt shows: Loading settings... Couldn't open file settings.dat. No saved settings; using defaults. videoinfo: desktop bpp 32 Graphics::SetResolution(0) Setting scaling 1 and fullscreen=no SDL_SetVideoMode: 320x240 @ 32bpp Graphics::FlushAll() SIFLoader::LoadHeader: read index of 8 sections Loading SIF section 1 from address 004d Loading SIF section 2 from address 044c SIFSpritesSect: loading 490 sprites fonts: using bitmapped from smalfont.bmp safemode print: 'I need to extract some game data' safemode print: 'before I can start up for the first time.' safemode print: '' safemode print: 'Before beginning, you should have the Aeon Genesis' safemode print: 'English translation of version 1.0.0.6, and drop' safemode print: 'Doukutsu.exe and it's "data" directory into the same' safemode print: 'folder as the "nx" program you just ran.' safemode print: '' safemode print: 'If you haven't done that yet, please press ESCAPE now' safemode print: 'and come back in a moment. Otherwise, you can' safemode print: 'press any other key to start the extraction.' run_until_key() returning key 13 safemode print: '= Extracting Files =' safemode print: '[ pxt/fx01.pxt ]' safemode print: 'PXT out of sync' Graphics::Close() I deleted other folders except "data" and try again, the outputs in debug.txt is thesame.

gameblabla commented 3 years ago

I think the error itself is pretty explicit : you need to have the game files in the opk. The issue that might arise is that it could try to save within the OPK, which is read only, causing a crash. You will need to modifiy the source code as to handle this.

kingling commented 3 years ago

I think the error itself is pretty explicit : you need to have the game files in the opk. The issue that might arise is that it could try to save within the OPK, which is read only, causing a crash. You will need to modifiy the source code as to handle this.

Instead of compressing the folder into an OPK file, I run dge directly in the folder, I have add more information above that got from debug.txt. Please give me some more advice, is there any problem use pxt files unpack from other cavestory.opk? shall I use pxt files that extract by the file nx run on linux(x86-64)?

EXL commented 3 years ago

@kingling See this commits:

https://github.com/uncletrunks/NXEngine/commit/6279ac1d401ea1a6f6873d55a26bdced0fef7f73 https://github.com/uncletrunks/NXEngine/commit/a3de07ac8e65be5b538d3948286f0c3c6cc5cde1

And this fork:

https://github.com/koszanski/cavestory

kingling commented 3 years ago

@EXL @gameblabla I built and run this project(https://github.com/koszanski/cavestory) successfully on my device(gkd350h).

Note that it can compile a runnable program with - msoftfloat in makefile, but there will be bugs. For example, XP bar is empty, boss's blood bar changed empty after one shoot (in fact, it is only the display bug) and can call boss repeatedly(see the pictures below). 1258962054 1409413143 983671720

But just use -mhardfloat, all is ok. I have no problem now. Please accept my sincere thanks.

EXL commented 3 years ago

@kingling

Please accept my sincere thanks. I have no problem now.

You are welcome! Please close this issue then.

Additional information:

There is NXEngine-evo with port to SDL2 and modern code base maybe you will be interested in it.

gameblabla commented 3 years ago

I should point out that SDL2 won't work on platforms with no GPU acceleration, which does include the GKD350H.