dciabrin / ngdevkit

Open source development for Neo-Geo
GNU Lesser General Public License v3.0
273 stars 26 forks source link

undefined reference to DIP roms #55

Closed ghost closed 3 years ago

ghost commented 3 years ago
m68k-neogeo-elf-gcc fix.o main.o utils.o z80.o -specs ngdevkit-specs -Wl,--defsym,rom_eye_catcher_mode=2  -o prom.elf
/home/gbacretin/Software/ngdevkit/local/m68k-neogeo-elf/lib/gcc/m68k-neogeo-elf/5.5.0/../../../../../m68k-neogeo-elf/bin/ld: /home/gbacretin/Software/ngdevkit/local/m68k-neogeo-elf/lib/gcc/m68k-neogeo-elf/5.5.0/../../../../../m68k-neogeo-elf/lib/ngdevkit-crt0.o: in function `_start':
(.text+0x116): undefined reference to `dip_jp_rom'
/home/gbacretin/Software/ngdevkit/local/m68k-neogeo-elf/lib/gcc/m68k-neogeo-elf/5.5.0/../../../../../m68k-neogeo-elf/bin/ld: (.text+0x11a): undefined reference to `dip_us_rom'
/home/gbacretin/Software/ngdevkit/local/m68k-neogeo-elf/lib/gcc/m68k-neogeo-elf/5.5.0/../../../../../m68k-neogeo-elf/bin/ld: (.text+0x11e): undefined reference to `dip_eu_rom'
collect2: error: ld returned 1 exit status

This issue can be temporarily solved by adding these lines in the compiled c files:

const int dip_jp_rom;
const int dip_eu_rom;
const int dip_us_rom;
dciabrin commented 3 years ago

These symbols are normally linked from libngdevkit.a, which should be included when you link your program with the pkg-config helper:

$ pkg-config --libs ngdevkit   
-L/home/dciabrin/dam/ngdk/local/m68k-neogeo-elf/lib -specs ngdevkit-specs -lngdevkit

libngdevkit.a is built in such a why that you never link any function you don't use from it. So unless you're just interested in the base toolchain without the sugar coating, it's safe to link against libngdevkit.a, it won't cost you anything except what you're using (e.g. the DIP definition).

Can you check if adding that lib fixes the issue?

ghost commented 3 years ago

It does work, although the program seems to not be accepting any inputs, but it's probably something related to a VBlank function name change

dciabrin commented 3 years ago

Hmmm the crt0 that comes with ngdevkit always calls BIOS function SYSTEM_IO for parsing user input, even when you change the vblank default callback function.

If you're using nullbios for your tests, maybe the input checks are failing because of a recent commit [1] that broke the system_io implementation. It is fixed in the most recent commit [2]. [1] abfc1b4212921abe31295b92590a257908b2d7fb [2] 1b1e83815124b33dd72e5d26edef371bf8c70717

ghost commented 3 years ago

I've fixed it, it was an error due to the fact that SYSTEM_IO is already called by ngdevkit

dciabrin commented 3 years ago

Ok I'm closing this then, everything seems to be explained and the DIP linkscript seems to work as expected. Thanks