View unanswered posts | View active topics It is currently Wed Jan 16, 2019 12:03 pm



Reply to topic  [ 5 posts ] 
 prolems when compiling cpp 
Author Message

Joined: Wed Nov 02, 2011 1:26 am
Posts: 2
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


Wed Nov 02, 2011 2:04 am
Profile
Site Admin

Joined: Tue Aug 09, 2005 3:21 am
Posts: 1314
Location: UK
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

devkitPro IRC support
Personal Blog


Wed Nov 02, 2011 2:13 pm
Profile ICQ WWW

Joined: Wed Nov 02, 2011 1:26 am
Posts: 2
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?


Thu Nov 10, 2011 5:39 pm
Profile
User avatar

Joined: Fri Jul 11, 2008 8:49 pm
Posts: 222
Location: The Netherlands
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.

_________________
my blog:
http://vuurrobin.100webcustomers.com/


Fri Nov 11, 2011 2:14 pm
Profile WWW

Joined: Thu Feb 03, 2011 10:47 pm
Posts: 210
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.


Sat Nov 12, 2011 12:15 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads