Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#303 Missing items from standard libraries at link time

OTHER
closed
Danny Smith
gcc (462)
works-for-me
User_Error
2013-01-30
2003-03-01
Dan Mathews
No

If I compile and link a program that refers to ostringstream and its
associated operators ("<<") and I/O manipulators (setw,
precision, etc.) ("GNU" #define set to 0) I get a large number of link
errors similar to the
following:

C:\Temp/ccKWbaaa.o(.text+0xfb2):DelDups32.cpp:
undefined reference to
`__gxx_personality_sj0'
C:\Temp/ccKWbaaa.o(.text+0x1741):DelDups32.cpp:
undefined reference to
`__gxx_personality_sj0'
C:\Temp/ccKWbaaa.o(.text+0x176e):DelDups32.cpp:
undefined reference to
`std::ios_base::ios_base()'
C:\Temp/ccKWbaaa.o(.text+0x1773):DelDups32.cpp:
undefined reference to `VTT for std::basic_ostringstream<char,
std::char_traits<char>, std::allocator<char>
>'
C:\Temp/ccKWbaaa.o(.text+0x1783):DelDups32.cpp:
undefined reference to `vtable for std::basic_ios<char,
std::char_traits<char> >'

If I remove the references to
ostringstream and its associated operators and manipulators
("GNU" define set to 1) I _still_
get:

C:\Temp/ccgzbaaa.o(.text+0xfb2):DelDups32.cpp:
undefined reference to `__gxx_personality_sj0'

It would
appear that the distribution I downloaded is missing some library
files...

Note also that "toupper" should be defined in one of
the standard libraries but apparently isn't.

Attached is a zip
file containing the complete set of associated supporting files.

Discussion

  • Luke Dunstan
    Luke Dunstan
    2003-03-01

    • status: open --> pending
     
  • Luke Dunstan
    Luke Dunstan
    2003-03-01

    Logged In: YES
    user_id=30442

    It sounds like you need to use the "g++" command to link
    your C++ program instead of using "gcc". Are you
    #including <ctype.h> when using toupper? (it definitely
    works for me). In future if you give your command lines in
    your bug report that would be useful too...

    By the way, there is no attachment and I am seeing a
    pattern that attachments never seem to work except when
    added later _after_ the bug is initially submitted. When you
    attached the file, did you check the box "Check to Upload
    and Attach a File:" ? It would really help us to know whether
    this is a SourceForge problem or not.

     
  • Dan Mathews
    Dan Mathews
    2003-03-01

    • status: pending --> open
     
  • Dan Mathews
    Dan Mathews
    2003-03-01

    Zip file containing all supporting files (source, batch, G++ compiler output)

     
    Attachments
  • Dan Mathews
    Dan Mathews
    2003-03-01

    Logged In: YES
    user_id=722870

    On the subject of missing files: Since I thought that I might not have
    checked the box the first time around on the previous bug report, I was
    very careful to make sure it was checked the last time around, so I am
    tending to think that the problem is on your end at this time.

    As far
    as the so-called "bug", you were correct in your guess regarding GCC vs.
    G++, so I guess you can close this bug report. However, I must admit that I
    am not clear about the difference between G++ and GCC, since GCC
    clearly _compiled_ my program properly, and G++ --help does not show
    most of the compiler options that the GCC help does.

    I am
    sending you the zip file again just in case - note that the batch file that I use
    to compile has been upgraded to use G++.

    Finally, an
    observation: The program in question compiles, links, and runs without
    error when compiled and linked with Visual C++ .NET (and has done so
    for years on that and previous versions of the Micro$oft compilers as it is
    an old program that I was making minor enhancement to). However it
    bombs when run after being compiled with g++. (I obviously haven't
    looked into the reason(s) why, having just gotten the information that I
    need to use g++.) The whole reason I got involved with gcc/g++ is
    because optimization is not done in the version of Visual C++ .NET that I
    own when compiling to machine code, and the performance of the
    resulting executables is truly terrible compared to the performance of
    the executables when compiled to .NET. Since I don't want to write
    programs that depend on the .NET runtime, this is of great concern to me,
    and I found that, generally speaking, gcc executables run sustantially
    faster than even those compiled and linked with Visual C++ 5.0 (the last
    version of a non-.NET compiler that I own, and a true optimizing compiler).
    (By the way, congratulations on a job well done!!!!)

     
  • Dan Mathews
    Dan Mathews
    2003-03-01

    Logged In: YES
    user_id=722870

    I forgot to mention, in M$ C++, "toupper" is defined in "stdlib.h" as well as
    "ctype.h", and my style is to _not_ include a header file unless I know that I
    need it....

     
  • Luke Dunstan
    Luke Dunstan
    2003-03-02

    • status: open --> closed-works-for-me
     
  • Luke Dunstan
    Luke Dunstan
    2003-03-02

    Logged In: YES
    user_id=30442

    The gcc and g++ commands are just "compiler drivers" that
    invoke the appropriate compiler/linker executables
    (cc1.exe for C, cc1plus.exe for C++). The main difference
    with g++ is that it tells the linker to use the C++ library
    libstdc++, so using "gcc ... -lstdc++" will probably have the
    same effect.

    I tried running your program very briefly and it seemed to
    work fine, so I can't help you with that problem. Don't try
    running it under MSYS rxvt though because your program
    accesses the console directly.

     
  • Earnie Boyd
    Earnie Boyd
    2013-01-30

    • Description has changed:

    Diff:

    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> User_Error
    • milestone: component_package --> OTHER