gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Linker errors with my new NiFi app[SOLVED]

#143561 - yellowstar - Tue Oct 23, 2007 10:03 pm

I am getting linker errors with my NiFi app.(not pong)
(built on the wireless lib)

But,
I'm getting linker errors.

I'm trying to use a lib I wrote for wireless stuff.(same stuff
as in pong)

Another thing:
I noticed that the my lib is only 8
bytes for some reason.

Here's what the app will do:
This is for Slot-1 users whom want to backup/overwrite eeprom
to/from sav files.
It's a EEPROM reader and file sender.
First the host gets booted with the card.
Then the client.
The host reads the EEPROM.
And then, it sends the EEPROM,
for the client to save to the card.
For overwriting the EEP,
it's the opposite.
The client sends the sav file.
The host recieves it,
then it overwrites the EEPROM with the sav file.

Code:

Makefile
LIBS   := -lfat -llobby9d -lnds9 -lyellwireless


Code:

linking NiFi_EEP.arm9.elf
connect.o: In function `main':
c:/AndrewConsoleStuff/MMaxLibWifi/NiFi_EEP/arm9/source/connect.cpp:91: undefined reference to `AskMode()'
c:/AndrewConsoleStuff/MMaxLibWifi/NiFi_EEP/arm9/source/connect.cpp:94: undefined reference to `FindPlayers()'
prog.o: In function `ProgMain()':
c:/AndrewConsoleStuff/MMaxLibWifi/NiFi_EEP/arm9/source/prog.cpp:35: undefined reference to `Init_Timers()'
c:/AndrewConsoleStuff/MMaxLibWifi/NiFi_EEP/arm9/source/prog.cpp:43: undefined reference to `GetPlayerQuit()'
collect2: ld returned 1 exit status


Code:

#ifndef YELL_WIRELESS_H_
#define YELL_WIRELESS_H_

void Init_Timers();

bool GetPlayerQuit();//Returns wether or not
//wether your opponet has quit.
//Based on wether or not a timeout on
//that player stays for 3-5 seconds.

void AskMode();
void FindPlayers();

#endif


Last edited by yellowstar on Fri Nov 09, 2007 7:39 pm; edited 4 times in total

#143562 - simonjhall - Tue Oct 23, 2007 10:07 pm

The includes for these don't work correctly when you're compiling C code. Take the ipc_init and safe_malloc prototypes and stick extern "C" in front of them.

eg,
Code:
void camels_eat_shoes(int how_many);

would become
Code:
extern "C" void camels_eat_shoes(int how_many);

I'd give you a proper example if I had the code infront of me, but I don't ;-)
_________________
Big thanks to everyone who donated for Quake2

#143564 - Mighty Max - Tue Oct 23, 2007 10:10 pm

Ah, so am i still missing the ifdef encapsulation on some files *hides*
_________________
GBAMP Multiboot

#143566 - yellowstar - Tue Oct 23, 2007 10:23 pm

I found out I wasn't including the safe_malloc.h
file.

Also,
I can't find the headers for the other errors.

#143567 - Mighty Max - Tue Oct 23, 2007 10:37 pm

yellowstar wrote:

Also,
I can't find the headers for the other errors.


MessageQueue.h

Cleanup of the includes for apps is somewhere down in the todo list :p
_________________
GBAMP Multiboot

#143585 - yellowstar - Wed Oct 24, 2007 2:54 am

I found it.(before I saw your post Mighty)

I found it by searching for the first function
in the include dir.
I never saw those prototypes
in that file before.(when I wanted to find them.)


It compiles correctly now.

I'm going to post about this game
in the wireless topic,
with a download.

EDIT:
I have posted there.
Here's a link to my post.

#144910 - yellowstar - Fri Nov 09, 2007 4:10 am

I have renamed and updated this topic,
for a new problem,
for a differen't program.

All the above posts aren't for this new problem,
they are for the old pong issue.

#144918 - gmiller - Fri Nov 09, 2007 5:25 am

your link may be failing because your library is listed last and it might use routines in library listed further to the left on the line. The linker usually process the libraries from left to right so libraries that reference other library ode need to be listed on the left relative to the library that hos the routines it calls. This might also mean you need to list a library more than one.

for examle:

libmyA calls code library libmyB which calls code min libmyC

So the link order would be:

-lmyA -lmyB -lmyC (followed by other libraies)

Yours might go:

-lyellwireless -lfat -llobby9d -lnds9

#144949 - yellowstar - Fri Nov 09, 2007 7:29 pm

I solved it.

Make wasn't find the main source file
for the lib, and thus not compiling anything.(anything that I wanted)

The reason for this,
was because the source directory and the file
wasn't lowercase.(first character)

Once that was fixed,
it worked.

I had this exact same problem
with another lib I wrote.(that lib didn't deal with any wireless things)