prolems when compiling cpp

support for the ARM toolchain
Post Reply
antoniojesusnc
Posts: 2
Joined: Wed Nov 02, 2011 1:26 am

prolems when compiling cpp

Post by antoniojesusnc » Wed Nov 02, 2011 2:04 am

sorry for the place I post, but I don`t know exactly where I have to do it

Hi, I'm new around here, so first of all I introduce myself.
My name is Antonio and I started programming in your library.
I'm using libnds and I managed to compile without problem files .c.
The problem comes when I compile files.cpp, which generates the
following error
arm-eabi-g++ -MMD -MP -MF /c/nds/Projects/Pruebas/P1/build/main.d -g -Wall -O2 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -iquote /c/nds/Projects/Pruebas/P1/include -I/c/nds/devkitPro/libnds/include -I/c/nds/Projects/Pruebas/P1/nflib/include -I/c/nds/Projects/Pruebas/P1/build -DARM9 -fno-rtti -fno-exceptions -c /c/nds/Projects/Pruebas/P1/source/main.cpp -o main.o 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/g'
1>linking P1.elf
1>c:/nds/devkitpro/devkitarm/bin/../lib/gcc/arm-eabi/4.6.1/../../../../arm-eabi/lib/thumb/ds_arm9_crt0.o: In function `CIDLoop':
1>(.init+0x218): undefined reference to `main'
1>collect2: ld returned 1 exit status
1>make[1]: * [/c/nds/Projects/Pruebas/P1/P1.elf] Error 1
1>make: * [build] Error 2

please, help me
thanks for your help

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

Re: prolems when compiling cpp

Post by WinterMute » Wed Nov 02, 2011 2:13 pm

You're missing a main function, all C/C++ code begins execution from int main(int argc, char **argv)
Help keep devkitPro toolchains free, Donate today

Personal Blog

antoniojesusnc
Posts: 2
Joined: Wed Nov 02, 2011 1:26 am

Re: prolems when compiling cpp

Post by antoniojesusnc » Thu Nov 10, 2011 5:39 pm

Thanks for your answer but the problem is not there. If I call the project .cpp instead of .c it works perfectly.
The problem arises as I write the word "class". As I write this keyword appears the error above.
I installed everything in linux and I get the same error.The same occurred when I installed win xp.
Any idea about my problem?

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: prolems when compiling cpp

Post by vuurrobin » Fri Nov 11, 2011 2:14 pm

all c++ code must be in a file with the cpp extension, and all c code goes in a file with a c extension. if you put c++ code in a c file, it will get compiled with the c compiler. and seeing as c doesn't have classes, you get an error.

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: prolems when compiling cpp

Post by mtheall » Sat Nov 12, 2011 12:15 am

Now you don't make sense. In the first post you said if you do it with .c it works but with .cpp it does not work. Then you say if you compile it with .cpp it works but with .c it does not work.

Classes don't exist in C, so it will be a compile error with a .c file.

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests