EmbDev.net

Forum: ARM programming with GCC/GNU tools iostream - related linker error (GNU/Linux Compiler g++)


Author: Asim (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi,

I am getting following linker errors using g++

***`__static_initialization_and_destruction_0'
***iostream:76: undefined reference to `std::ios_base::Init::Init()'
***iostream:76: undefined reference to `std::ios_base::Init::~Init()'

GNU/Linux using g++

.\Objects\main.o: In function 
`__static_initialization_and_destruction_0':

/cygdrive/c/Hitex/GnuToolPackageArm/bin/../lib/gcc/arm-hitex-elf/4.1.1/. 
./../../../include/c++/4.1.1/iostream:76:  undefined reference to 
`std::ios_base::Init::Init()'

/cygdrive/c/Hitex/GnuToolPackageArm/bin/../lib/gcc/arm-hitex-elf/4.1.1/. 
./../../../include/c++/4.1.1/iostream:76:  undefined reference to 
`std::ios_base::Init::~Init()'

It is a very simple C++ code which is not using any special C++ 
features.
The code compiles,links and runs fine when <iostream> is "NOT" included 
in the main.cpp file.

but as soon as <iostream> is included in the main.cpp file, the code 
compiles, but the above linker error is generated.

Any help is appreciated!!!
Thanks!

Author: Rolf Magnus (Guest)
Posted on:

Rate this post
0 useful
not useful
> GNU/Linux using g++

Sure about that? Your paths look like this is Windows/Cygwin.

What's you compiler/linker command line?

Author: Asim Shaikh (asim)
Posted on:

Rate this post
0 useful
not useful
arm-hitex-elf-g++ -mcpu=arm7tdmi -c -gdwarf-2 -xc -MD -Wall -O0 
-mthumb-interwork -mapcs-frame  -fsigned-char  -mlittle-endian  -marm
 -I.\Source\  -I.\ -o .\Objects\interrupt.o 
.\Source\System\interrupt.cpp

arm-hitex-elf-as -mcpu=arm7tdmi  -gdwarf2  -mthumb-interwork
-I.\Source\  -I.\ -o .\Objects\startup.o .\Source\System\startup.s

arm-hitex-elf-g++ -mcpu=arm7tdmi  -c -gdwarf-2 -xc++  -Wall -O0 
-mthumb-interwork -mapcs-frame  -fsigned-char  -mlittle-endian  -marm
 -I.\Source\  -I.\ -o .\Objects\main.o .\main.cpp

arm-hitex-elf-ld  -T.\Settings\main.ld.tmp --cref -t -static 
-nostartfiles -Map=.\DOC\DemoC++.map  -stats -lhcclib -lc -lgcc -lm
-o .\Objects\DemoC++.elf

.\Objects\main.o: In function 
`__static_initialization_and_destruction_0':
/cygdrive/c/Hitex/GnuToolPackageArm/bin/../lib/gcc/arm-hitex-elf/4.1.1/. 
./../../../include/c++/4.1.1/iostream:76:  undefined reference to 
`std::ios_base::Init::Init()'

/cygdrive/c/Hitex/GnuToolPackageArm/bin/../lib/gcc/arm-hitex-elf/4.1.1/. 
./../../../include/c++/4.1.1/iostream:76:  undefined reference to 
`std::ios_base::Init::~Init()'


arm-hitex-elf-ld: link errors found, deleting executable 
`.\Objects\DemoC++.elf'
arm-hitex-elf-ld: mode armelf
.\Objects\interrupt.o (3kb)
.\Objects\startup.o (6kb)
.\Objects\main.o (35kb)

Author: Andreas Ferber (aferber)
Posted on:

Rate this post
0 useful
not useful
Asim Shaikh wrote:
> arm-hitex-elf-ld  -T.\Settings\main.ld.tmp --cref -t -static
> -nostartfiles -Map=.\DOC\DemoC++.map  -stats -lhcclib -lc -lgcc -lm
> -o .\Objects\DemoC++.elf

You are not linking against the C++ runtime (libstdc++), which would 
provide you with your missing symbols.

It is recommended to use g++ itself (arm-hitex-elf-g++ in your case) for 
linking. This ensures that all necessary runtime libraries are included 
automatically. If you want to provide parameters to the linker itself 
(like -nostartfiles or -Map in your case), you can do this using the 
"-Wl,..." parameter to g++, for example "-Wl,-nostartfiles".

Andreas

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.