Page 1 of 1

prolems when compiling cpp

Posted: Wed Nov 02, 2011 2:04 am
by antoniojesusnc
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

Re: prolems when compiling cpp

Posted: Wed Nov 02, 2011 2:13 pm
by WinterMute
You're missing a main function, all C/C++ code begins execution from int main(int argc, char **argv)

Re: prolems when compiling cpp

Posted: Thu Nov 10, 2011 5:39 pm
by antoniojesusnc
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?

Re: prolems when compiling cpp

Posted: Fri Nov 11, 2011 2:14 pm
by vuurrobin
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.

Re: prolems when compiling cpp

Posted: Sat Nov 12, 2011 12:15 am
by mtheall
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.