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]

gcc-3.4.1 -Wl,-static -lstdc++


building 2 gcc-3.4.1 versions on RedHat Enterprise 3.0 (the first one configured with
--disable-shared):

$ /usr/local/gcc-3.4.1.st/bin/c++ -v
Reading specs from /opt/local/gcc-3.4.1.st/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/usr/local/gcc-3.4.1.st --enable-threads=posix --enable-__cxa_atexit --disable-shared --enable-languages=c,c++,f77 --with-cpu=pentium4
Thread model: posix
gcc version 3.4.1

$ /usr/local/gcc-3.4.1/bin/c++ -v
Reading specs from /opt/local/gcc-3.4.1/bin/../lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/usr/local/gcc-3.4.1 --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,f77 --with-cpu=pentium4
Thread model: posix
gcc version 3.4.1



the question/problem is, which compiler options must be supplied
that the (shared) version behaves like the first one;

-static-libgcc -Wl,-static -lstdc++

does not do the job as following testprogram (otto248.c) shows:



/*********************************************************/
#include <iostream>
using namespace std;

int main(void)
{
    cout << "throw and catch const char*: ";
    try { throw "const char*"; }
    catch(const char* err)
    {
	cout << " caught const char*" << endl;
    }
    catch(...)
    {
	cout << "caught unknown exception" << endl;
    }

    return 0;
}
/*********************************************************/

$ /usr/local/gcc-3.4.1.st/bin/c++ -Wall -O2 -o otto248 otto248.c
$ ldd otto248
        libm.so.6 => /lib/tls/libm.so.6 (0xb75b9000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb7481000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb75eb000)
$ ./otto248
throw and catch const char*:  caught const char*


$ /usr/local/gcc-3.4.1/bin/c++ -Wall -O2 -static-libgcc -Wl,-static -lstdc++ -o otto248 otto248.c
$ ldd otto248
        not a dynamic executable
$ ./otto248
throw and catch const char*: Aborted

with best regards,
Werner Mausshardt

-- 
Werner Mausshardt		E-mail: werner.mausshardt@bruker.de
Software Department		Tel: +49 721 5161 448
Bruker BioSpin GmbH		Fax: +49 721 5161 480


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