SGDK Linker Error — Undefined Reference to VGM_init and VGM_play

A place for people with an interest in developing new shmups.
Post Reply
murray83
Posts: 1
Joined: Sun Aug 31, 2025 1:15 pm

SGDK Linker Error — Undefined Reference to VGM_init and VGM_play

Post by murray83 »

Hi all, I'm working on a Mega Drive project using SGDK 2.11 and trying to get VGM playback working. I’ve written a custom vgm.c and vgm.h to handle VGM parsing and playback, and I’ve added a .vgm file to my resources. Everything compiles fine, but I keep hitting a linker error during the final build:

undefined reference to `VGM_init`
undefined reference to `VGM_play`

These are the exact lines from the error:

ld.exe: C:\Users\<user>\AppData\Local\Temp\...\ltrans0.ltrans.o: in function `main.isra.0':
<artificial>:(.text+0x480c): undefined reference to `VGM_init`
<artificial>:(.text+0x481e): undefined reference to `VGM_play`

Wat I’ve done so far:
vgm.c defines:

void VGM_init(void);
void VGM_play(const u8* data, u32 size);

vgm.h declares those functions correctly.

main.c calls:

VGM_init();
VGM_play(music, music_size);

My resource file (res/resources.res) includes:
music VGM music.vgm

My Makefile includes:

PROJECT = vgm_test
SGDK = E:/5-0-3/SGDK/SGDK-2.11
SRC += src/vgm.c src/util.c src/xgm_command.c src/main.c
INC += inc
RESOURCES = res/resources.res
include $(SGDK)/Makefile.gen
I’ve tried make clean and rebuilding, and I’ve confirmed that vgm.c is being compiled and vgm.o is listed in the link step. Still, the linker can’t find those two functions.

Any ideas what I might be missing? Could this be related to LTO or symbol visibility? Appreciate any help — thanks in advance!
Ixmucane2
Posts: 784
Joined: Mon Jan 19, 2009 3:26 pm
Location: stuck at the continue prompt

Re: SGDK Linker Error — Undefined Reference to VGM_init and VGM_play

Post by Ixmucane2 »

  • A log of all commands that make executes would be very informative. Subtle details are important.
  • What is ltrans0.ltrans.o from the linker error? Are you sure you are linking what you think you are linking?
  • Inspect the symbols in (I presume) vgm.o because they could be private, renamed etc. and therefore unavailable for linking.
Post Reply