Linking error: undefined reference BoyScoutUpdateSong()

Post Reply
thepursuer
Posts: 1
Joined: Sat Mar 11, 2023 5:53 am

Linking error: undefined reference BoyScoutUpdateSong()

Post by thepursuer » Sat Mar 11, 2023 6:12 am

I've just started programming for the GBA so I'm pretty late to the game. But if anybody is still lurking out there, maybe they can help me with a problem. I've been going through the examples (copy paste the files and build using cmake) and hit a wall with PlayBoyScout. I've set up my project to work with cmake:

Code: Select all

├── CMakeLists.txt
├── data
│   ├── ScoutSplash.pcx        
│   └── tune.bgf
└── src
    ├── CMakeLists.txt
    └── PlayBoyScout.cpp 
And my cmake files:

Code: Select all

# Specify the minimum version of CMake required
cmake_minimum_required(VERSION 3.16)

# Set the CMake toolchain file
list(APPEND CMAKE_MODULE_PATH C:/devkitPro/cmake)
include(GBA)
include(Platform/NintendoGBA)

# Set the project name and version
project(my_gba_project VERSION 1.0)

add_subdirectory(src)

Code: Select all

# Add all .c files in the src directory to the executable target
file(GLOB SOURCES *.cpp **/*.cpp)
add_executable(my_gba_executable ${SOURCES})

# dkp_add_embedded_binary_library(splash_lib ${SPLASH})
dkp_add_embedded_binary_library(bgf_target ${PROJECT_SOURCE_DIR}/data/tune.bgf)
dkp_add_embedded_binary_library(pcx_target ${PROJECT_SOURCE_DIR}/data/ScoutSplash.pcx)
# Set the linker directories for devkitPro
target_link_libraries(my_gba_executable PUBLIC mm gba pcx_target bgf_target)

gba_create_rom(my_gba_executable)
But I get linker errors stating undefined reference to anything BoyScout related. I've checked the libgba.a with nm and found that those symbols do infact exist in that library and I've linked it in the cmake file. irqInit(), for example seems to be defined. What could be happening here? Do I have some configuration errors?

WinterMute
Site Admin
Posts: 1741
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Linking error: undefined reference BoyScoutUpdateSong()

Post by WinterMute » Wed May 10, 2023 11:14 am

Would be better to add CMakeLists.txt to the existing project rather than copying the original files elsewhere. These files should not contain windows paths nor should they replicate what our existing cmake framework does. We're still working on documenting that & getting it right. I was able to build this particular example with this CMakeLists.txt in the root of the project.

Code: Select all

cmake_minimum_required(VERSION 3.13)

project(PlayBoyscout VERSION 1.0)

add_executable(PlayBoyScout ${PROJECT_SOURCE_DIR}/source/PlayBoyScout.c)

dkp_add_embedded_binary_library(bgf_target ${PROJECT_SOURCE_DIR}/data/tune.bgf)
dkp_add_embedded_binary_library(pcx_target ${PROJECT_SOURCE_DIR}/data/ScoutSplash.pcx)

target_link_libraries(PlayBoyScout PRIVATE pcx_target bgf_target gba)

gba_create_rom(PlayBoyScout)
This should be configured with the arm-none-eabi-cmake wrapper found in /opt/devitpro/portlibs/gba/bin from the msys2 shell we provide like this

Code: Select all

/opt/devkitpro/portlibs/gba/bin/arm-none-eabi-cmake -B build -S .
Please note: This needs to be run from the msys2 bash shell, it won't work properly from cmd, powershell etc. That shell identifies as MSYS_NT similar to this

Code: Select all

$ uname -a
MSYS_NT-10.0-19044 ashpool 3.4.6.x86_64 2023-04-01 11:43 UTC x86_64 Msys
you can then build using

Code: Select all

make -C build
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests