NDS Make problem - undefined reference to main

support for the ARM toolchain
Post Reply
Netaro
Posts: 4
Joined: Tue Apr 28, 2009 11:38 am

NDS Make problem - undefined reference to main

Post by Netaro » Tue Apr 28, 2009 11:51 am

Hello there!

So, i decided to make my own project, and there it is. I copied the makefile from hello_world, and wrote my own cpp file main.cpp.
Here's the error -

Code: Select all

linking testOslibULlibs.elf
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-eabi/4.3.3/../../../../arm-eabi/lib/th
umb/ds_arm9_crt0.o: In function `CIDLoop':
(.init+0x2e0): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [/c/Users/Netaro/Desktop/Projekty2/Programowanie/testOslibULlibs/te
stOslibULlibs.elf] Error 1
make: *** [build] Error 2
Then in make i noticed the make tries to find the necessary files in the folders in the current folder. By manually removing it and giving

Code: Select all

CPPFILES	:= main.cpp
the error changed to :

Code: Select all

make[1]: *** No rule to make target `main.o', needed by `/c/Users/Netaro/Desktop
/Projekty2/Programowanie/testOslibULlibs/testOslibULlibs.elf'.  Stop.
make: *** [build] Error 2


So, i'm stuck. What to do?
And i don't really think it's the problem with the contents of main.cpp, as there is main(), and all the necessary gizmo's. If needed i can copy/paste it.

EDIT:

OK, it compiled only when i put all the source files in source/include directories. So, what to change in makefile to make it look for all the necessary files in the folder makefile is in, as my experiments gave me nothing.

weirdfox
Posts: 29
Joined: Thu Feb 19, 2009 8:45 am
Location: Montreal, Canada
Contact:

Re: NDS Make problem - undefined reference to main

Post by weirdfox » Wed Apr 29, 2009 1:05 am

You have to put the full path (from the makefile's location) for each of your files.
Or use an old Makefile trick like this to scan for all your files, but you have to specify the folders :

Code: Select all

SOURCES     :=    source source/renderer source/audio source/input source/tools \
                  source/message
CFILES      :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES    :=    $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
for your header files, just make sure thier base-path (locateon where to find theme relative to the makefile) is int the Makefile too:

Code: Select all

INCLUDES	:=	include
try, crash, debug and learn :)

Netaro
Posts: 4
Joined: Tue Apr 28, 2009 11:38 am

Re: NDS Make problem - undefined reference to main

Post by Netaro » Wed Apr 29, 2009 10:52 am

It's absolutely the opposite of what i've been asking, weirdfox.
All the files are in one folder. Make, c/cpp, h/hpp... all in one folder.

So, i did this -

Code: Select all

TARGET		:=	$(shell basename $(CURDIR))
BUILD		:=	$(CURDIR)
SOURCES		:=	$(CURDIR)
INCLUDES	:=	$(CURDIR)
And it doesn't work.
Error :
Well, it hangs for a while then a LOT OF make:error 2 appears. Nothing else, but a stream of these.
So, my question to make it clear is - all the files are in the folder where makefile is. Default makefile forces the use of specified folders. Changing the makefile values to $(CURDIR) makes aboslutely nothing good. So, how to do it?

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

Re: NDS Make problem - undefined reference to main

Post by WinterMute » Wed Apr 29, 2009 11:31 am

keeping source & build files in separate folders is tidier and easier to maintain. You can put c/cpp/h/hpp all in the source folder & ignore the includes line. Modifying the Makefile to put everything in one folder will just break.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Netaro
Posts: 4
Joined: Tue Apr 28, 2009 11:38 am

Re: NDS Make problem - undefined reference to main

Post by Netaro » Wed Apr 29, 2009 12:56 pm

WinterMute wrote:keeping source & build files in separate folders is tidier and easier to maintain.
Not for me.
You can put c/cpp/h/hpp all in the source folder & ignore the includes line.
That's what i want to avoid at all costs. Everything in the same folder. In the folder where makefile is. No subfolders. None at all.
Modifying the Makefile to put everything in one folder will just break.
Why?
My makefiles for PSP projects don't break, and le top de la cake, they are in the same folder where the rest of the files are.
But this makefile is preset to search the subfolders.
So, how to modify the makefile NOT TO search the subfolders, but look ONLY in the current directory? My post above says how i tried to do it, and how it failed.

User avatar
Izhido
Posts: 107
Joined: Fri Oct 19, 2007 10:57 pm
Location: Costa Rica
Contact:

Re: NDS Make problem - undefined reference to main

Post by Izhido » Thu Apr 30, 2009 12:03 am

Hm.

You piqued my curiosity. You *greatly* piqued my curiosity.

Why is that? Why must you have everything on a single folder?

I mean, you must have a reason, right? One does not make decisions about software projects simply because "I said so". One makes decisions by carefully examining the available options, then choosing what's best for the project being built. Is there a requirement for the app you're building that everything should be put in one single folder?

Go on, tell us. Don't be shy. Why you need all files in a single folder?

Netaro
Posts: 4
Joined: Tue Apr 28, 2009 11:38 am

Re: NDS Make problem - undefined reference to main

Post by Netaro » Thu Apr 30, 2009 9:03 am

My only reason is that i find my solution cleaner than having multiple folders. That's all, nothing else.

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

Re: NDS Make problem - undefined reference to main

Post by WinterMute » Thu Apr 30, 2009 2:00 pm

The majority of devkitPro toolchain users find the folder approach cleaner than placing everything in one folder, to such an extent that many devkitPSP users have requested templates similar to the devkitARM & devkitPPC ones.

Your basic options are to either use the templates as intended or to write your own build system from scratch.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests