GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jun-2009, 16:39
ajb181 ajb181 is offline
New Member
 
Join Date: Jun 2009
Posts: 5
ajb181 is on a distinguished road

ld Linker error


Im having trouble linking my c++ project.

getting 1000's of linker errors like..

Code:
../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o): In function `LinuxFileStructElement::GetChild(int)': /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:95: undefined reference to `mcount' /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:98: undefined reference to `operator new(unsigned int)' /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:98: undefined reference to `operator delete(void*)' /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:98: undefined reference to `__cxa_end_cleanup' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o): In function `LinuxFileStructElement': /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:18: undefined reference to `mcount' /home/alex/dev/candy/lib/removable_media/ms200/linux_file_struct_element.cpp:80: undefined reference to `__cxa_end_cleanup' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.extab+0xa8): undefined reference to `__gxx_personality_v0' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.extab+0xc4): undefined reference to `__gxx_personality_v0' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.extab+0xe0): undefined reference to `__gxx_personality_v0' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.extab+0xfc): undefined reference to `__gxx_personality_v0' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.extab+0x11c): undefined reference to `__gxx_personality_v0' ../../tools/build/../../release/lib/.//libremovable_media.a(linux_file_struct_element.o):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr1'

have done a bit of googling and asking round the office also Looked into the manual of gcc ld but can not find any flags to help me. Im a little stuck at the moment. I have a suspicion its not linking to the g++ object files correctly..

export PROJECT=release-1.1.0-alpha
export TOOLCHAIN=uclibcgnueabi


# You shouldn't need to change these variables
export ARCH=arm
export TARGET=arm-fusion-linux
export CROSS_COMPILE=${TARGET}-${TOOLCHAIN}-
export PRJROOT=${DEVROOT}${PROJECT}
export HOST=i686-cross-linux-gnu
export PREFIX=/opt
export ROOTFS=${PRJROOT}/rootfs/${TOOLCHAIN}
export IMAGEDIR=${PRJROOT}/images/${TOOLCHAIN}
# export TARGET_PREFIX=${PREFIX}/${TARGET}
export PATH=${PREFIX}/${TOOLCHAIN}/bin:${PATH}


## C Compiler Configuration ##

CC = $(CROSS_COMPILE)gcc
CC_SPECIAL_FLAGS = $(CPP_FLAGS) -Wall -c -fPIC -D_REENTRANT
CC_DEBUG_FLAGS = -g -ggdb -O0 -DDEBUG -rdynamic -pg
CC_RELEASE_FLAGS = -O2 -DNDEBUG
CC_OUTPUT_FLAG = -o

## C++ Compiler Configuration ##

CXX = $(CROSS_COMPILE)g++
CXX_SPECIAL_FLAGS = $(CC_SPECIAL_FLAGS) -pipe
CXX_DEBUG_FLAGS = $(CC_DEBUG_FLAGS)
CXX_RELEASE_FLAGS = $(CC_RELEASE_FLAGS)
CXX_OUTPUT_FLAG = -o

## Linker Configuration ##

LD = $(CROSS_COMPILE)ld
LD_SPECIAL_FLAGS =
LD_DEBUG_FLAGS = #-pg
LD_RELEASE_FLAGS =
LD_OUTPUT_FLAG = -o

Any help would be much appreciated
  #2  
Old 11-Jun-2009, 19:09
ajb181 ajb181 is offline
New Member
 
Join Date: Jun 2009
Posts: 5
ajb181 is on a distinguished road

Re: ld Linker error


I have since progressed past these errors by using g++ the link the lib's instead of ld. But am puzzled as you why this cant be done with ld?

Any ideas would be appreciated
  #3  
Old 24-Jun-2009, 06:56
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 221
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: ld Linker error


Quote:
Originally Posted by ajb181
I have since progressed past these errors by using g++ the link the lib's instead of ld. But am puzzled as you why this cant be done with ld?

Any ideas would be appreciated

Obviously, it *is* being done by ld, which g++ invokes. You're simply not invoking it properly.

$ ld --help > ld.help.txt (using your arm-based ld!)

...read thoroughly and all will be clear.

You are likely not invoking ld with the proper arguments. However, as you've found out, g++ oftentimes makes it easier to link because it translates compiler input arguments to linker input arguments, which are a bit more arcane for those who do not regularly independently invoke ld.

Most likely, you're not passing enough variables to ld, such as which linker script to use and how to link the objects...assuming that you're even passing the objects. (I glanced at your post, so if it is there and I didn't see it, call me lazy.) There are a LOT of variables that need to be passed to ld, particularly when cross compiling. You often need to pass the machine type, output file type, etc. ld will tell you the kinds of object files it expects and what the output type (choices) will be. Use objcopy to convert from one type to another. Note that machine type can also be specified in the linker script. Writing your own, custom linker script may be suitable for your particular target however, it sounds as if you probably already have a suitable script. You may want to find out what it contains so that you can better understand "the world" according to gcc. While learning, execute all "binutils" binaries using the -v (verbose) option. You'll be inundated with information that, once the confusion passes, makes everything much more clear.

Just about every toolchain is an extremely complex world developed over years of work by many people. It is very difficult to assume that anyone would "just know" all of what is contained in that world.


MxB
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 11:13
Linked Lists advice request promsan C Programming Language 74 23-May-2007 09:29
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 12:25
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 11:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 21:30

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:37.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.