This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17694] New: g++ fails to link libstdc++ when linking libraries only


I'm not completely sure this is a bug, but it worked in 3.3.1 and broke some of
our code when we moved to 3.4.1

# Compiling a simple c++ program from the command line works:
##############################################################
$ cat tst.cpp
#include <fstream>
#include <iostream>

main( )
{
   using namespace std;
   cout << "hello world" << endl;
}
 

# But, if we first create a library, then link with that library, the link
# fails.   Internally, it seems that g++ is failing to link in libstdc++ in
# this case:
###########################################################################
$ g++ tst.cpp -o tst
$ ./tst
hello world
$ 
$ g++ tst.cpp -o tst
$ ./tst
hello world
$ g++ -c tst.cpp    
$ ar r libtst.a tst.o    
$ g++ -L. -ltst -otst                  
./libtst.a(tst.o)(.text+0xd): In function `std::__verify_grouping(char const*,
unsigned int, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::size() const'


# It works if we explicitly include -lstdc++, but that was not needed in 3.3.1
#######################################################################
$ g++ -L. -ltst -lstdc++ -o tst
$ ./tst 
hello world
$

-- 
           Summary: g++ fails to link libstdc++ when linking libraries only
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: psfales at lucent dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17694


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]