Sign in to follow this  
NIm

First time using .o files

Recommended Posts

NIm    210
My code has gotten large enough that I've had to split it into different object files. unfortunatly, I'm having difficulty resolving linker errors here is the error(list) it gives:
ld: warning: cannot find entry symbol _start; defaulting to 00000000080486fc
main.o(.text+0xed): In function `loop()':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x147): In function `loop()':
: undefined reference to `operator delete(void*)'
main.o(.text+0x161): In function `loop()':
: undefined reference to `_Unwind_Resume'
main.o(.text+0x135c): In function `itemcreate(char*, char, int)':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x1587): In function `monster::monster(bool)':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x15ed): In function `monster::monster(bool)':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x161e): In function `monster::monster()':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x1650): In function `monster::monster()':
: undefined reference to `operator new(unsigned int)'
main.o(.text+0x169d): In function `monster::~monster()':
: undefined reference to `operator delete(void*)'
main.o(.text+0x16d9): In function `monster::~monster()':
: undefined reference to `operator delete(void*)'
main.o(.text+0x1c99): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
main.o(.text+0x1ca1): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `__dso_handle'
main.o(.text+0x1cca): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
main.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
mapgen.o(.text+0x8f3): In function `drunkTerrain(cell (*) [200], int, int)':
: undefined reference to `_Unwind_Resume'
mapgen.o(.text+0xcfe): In function `drunkTerrain(cell (*) [200], int, int)':
: undefined reference to `_Unwind_Resume'
mapgen.o(.text+0xefd): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
mapgen.o(.text+0xf05): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `__dso_handle'
mapgen.o(.text+0xf2e): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
mapgen.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
make: *** [nimrl] Error 1

Here is my makefile

nimrl:
	g++ -c -omain.o nimrl.cpp
	g++ -c -omapgen.o mapgen.cpp
	ld  -onimrl -lncurses main.o mapgen.o

and here is the function loop mentioned in the error
int loop()                            //loop
{
  char in;
  int xoff,yoff,i;
  cell map[mapmaxx][mapmaxy];
  monster* pc = new monster(1);
  pc->x=100;
  pc->y=100;
  pc->hp=10;
  pc->symbol='@';
  centermap(pc->x,pc->y,xoff,yoff);
  mapgen(map,0); 
  centermap(pc->x,pc->y,xoff,yoff);      //big:5,5,20
  drawmap(map,maxx,maxy,xoff,yoff);
  while (1)
  {
    input(pc,map);
    out.print();
    centermap(pc->x,pc->y,xoff,yoff);
    drawmap(map,maxx,maxy,xoff,yoff);
    mvprintw(pc->y-yoff+1,pc->x-xoff,"@");
    move(pc->y-yoff+1,pc->x-xoff);
  }
  delete pc;
}
Thanks in advance ps. How do oyu get code listings into a white box? [Edited by - NIm on July 18, 2005 10:05:14 AM]

Share this post


Link to post
Share on other sites
Oxyd    1157
Quote:
ld -onimrl -lncurses main.o mapgen.o


Try using g++ for the linking job as well (it invokes ld in the back-end). I.e. g++ -onimrl -lncurses main.o mapgen.o.

Oxyd

Share this post


Link to post
Share on other sites
SiCrane    11839
The [source] tags are used to get the white box.

And your ld command is missing the reference to libstdc++. -lstdc++ should fix at least someof those undefined references.

Share this post


Link to post
Share on other sites
TDragon    679
The compiling stage - i.e. when you produce .o files. Of course you also have to make sure it doesn't get stripped out when you link. (Which means: just don't compile with the -s flag. Which you obviously aren't. So why did I mention this?...)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this