Jump to content
  • Advertisement
Sign in to follow this  
Crypter

GCC errors - please help!

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I just downloaded a GBA emulater and compiler. The compiler includes the GCC compiler. I never used this compiler before. I ran this simple program..
#include <iostream>

class CLogStream;

class cLogStream //: std::ostream
{
	std::string m_strData;    //errors??

public:
    cLogStream () {}
	~cLogStream () {}
};

int main()
{
return 0;
}

This code is from my original logging system, which works great in MSVC++. Anyways, GCC is giving me errors..
gcc -o zengine.elf main.cpp -lm
ccdgJ7pr.o: In function `__static_initialization_and_destruction_0(int, int)':
ccdgJ7pr.o(.text+0x54): undefined reference to `std::ios_base::Init::Init()'
ccdgJ7pr.o(.text+0x7c): undefined reference to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
What could be the cause for this? My code works with MSVC++ 6. (Okay..The pluses aren showing..Its _cplusplus.) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Try using g++ instead of gcc:

g++ -o zengine.elf main.cpp -lm

EDIT: Note that g++ is the same GNU compiler as gcc, but gcc does not use the C++ libraries by default while g++ does.

[Edited by - Peregrin on September 11, 2005 10:27:56 PM]

Share this post


Link to post
Share on other sites
What Peregrin said. It says in the man pages that gcc will know to use the c++ compiler if the file extension is a c++ type (.cxx .cc .cpp etc.), but in practice i've found that not to be the case.

Share this post


Link to post
Share on other sites
Quote:
Original post by kdogg
What Peregrin said. It says in the man pages that gcc will know to use the c++ compiler if the file extension is a c++ type (.cxx .cc .cpp etc.), but in practice i've found that not to be the case.


The errors displayed are linker errors. Considering it's not whining about "class" being undefined, I'd say it's compiling the C++ code just fine (and hence using the correct compiler for that). It's just not linking all the necessary libraries.

Depending on your system layout, you may be able to simply add -lstdc++ to GCC's options - but why not just use the g++ commandline?

Share this post


Link to post
Share on other sites
Although this isn't related to your errors, for your program to be legal you need to include <string> if you use std::string.

Share this post


Link to post
Share on other sites
Yuck, command lines. I'd avoid them if possible. I used to use GCC for 32bit DOS programming a few years back - it IS a good compiler, if a little peculiar compared to VS (which may be VS's fault).

Share this post


Link to post
Share on other sites
Thanks for replying!

I tried using g++, but I get the same exact errors.

@me22:
D'uh! I forgot about that! Anyways, after adding
#include <string> and running g , I get one error..

g++ -o zengine.elf ..\zengine\main.cpp -lm../lib/gcc-lib/arm-agb-
elf/3.0.2/../../../../arm-agb-elf/lib/libstdc .a(pure.o): In function
`__cxa_pure_virtual':../../../../gcc-3.0.2/libstdc -v3/libsupc /pure.cc:49:
undefined reference to`write'collect2: ld returned 1 exit status

What could cause this? Please help!

btw, Why doesnt my pluses appear in the "Show Preview?"

Share this post


Link to post
Share on other sites
Okay, Im stuck. It is definitaly a linker prob..
but I have no idea whats causing the stupid error.

Ill post everything I can, and hope someone here
can help.

Code:

#include <iostream>

int main()
{
return 0;
}

The makefile that I use (make.bat):

PATH=c:\devkitadv\bin;%PATH%
g++ -o zengine.elf main.cpp -lm
objcopy -O binary zengine.elf zengine.bin
pause

The error..

C:\DevKitAdv>g++ -o zengine.elf main.cpp -lm
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/
3.0.2/../../../../arm-agb-elf/lib/libstdc++.a(pure.o):
In function `__cxa_pure_virtual':
../../../../gcc-3.0.2/libstdc++-v3/libsupc++/pure.cc:49:
undefined reference to `write'
collect2: ld returned 1 exit status

Ive never used this compiler before..Please help!!

Share this post


Link to post
Share on other sites
Dont quote me on this, but I dont think that gcc for the gba has a <iostream>.

You cant use it ecause it doesnt exist.

And by the way, have you tried using HAM? Its my favorite IDE and it works awesome.

Share this post


Link to post
Share on other sites
Your code compiles and links without a hitch with my copy of GCC. Where did you get yours?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!