Обсуждение: pgsql and C++ compiling question
I am able to compile and link a c++ app with libpq++, provided I use g++. If I attempt to compile with egcs I get the following link-time errors. Any ideas as to what I may be doing wrong? Any help would be much appreciated.
cca.o: In function `__malloc_alloc_template<0>::oom_malloc(unsigned int)':
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x17): undefined reference to `endl(ostream &)'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x21): undefined reference to `cerr'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x26): undefined reference to `ostream::operator<<(char const *)'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x31): undefined reference to `ostream::operator<<(ostream &(*)(ostream &))'
cca.o: In function `basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::Rep::copy(unsigned int, char const *, unsigned int)':
cca.o(.basic_string<char, string_char_traits<char>, __default_alloc_template<1, 0> >::Rep::gnu.linkonce.t.copy(unsigned int, char const *, unsigned int)+0x2a): undefined reference to `string_char_traits<char>::copy(char *, char const *, unsigned int)'
/usr/local/pgsql/lib/libpq++.so: undefined reference to `__out_of_range(char const *)'
/usr/local/pgsql/lib/libpq++.so: undefined reference to `__length_error(char const *)'
collect2: ld returned 1 exit status
make: *** [cca] Error 1
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x17): undefined reference to `endl(ostream &)'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x21): undefined reference to `cerr'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x26): undefined reference to `ostream::operator<<(char const *)'
cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x31): undefined reference to `ostream::operator<<(ostream &(*)(ostream &))'
cca.o: In function `basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::Rep::copy(unsigned int, char const *, unsigned int)':
cca.o(.basic_string<char, string_char_traits<char>, __default_alloc_template<1, 0> >::Rep::gnu.linkonce.t.copy(unsigned int, char const *, unsigned int)+0x2a): undefined reference to `string_char_traits<char>::copy(char *, char const *, unsigned int)'
/usr/local/pgsql/lib/libpq++.so: undefined reference to `__out_of_range(char const *)'
/usr/local/pgsql/lib/libpq++.so: undefined reference to `__length_error(char const *)'
collect2: ld returned 1 exit status
make: *** [cca] Error 1
Regards,
Tim
* Tim Barnard <tbarnard@povn.com> [001208 15:25]: > I am able to compile and link a c++ app with libpq++, provided I use g++. If I attempt to compile with egcs I get the followinglink-time errors. Any ideas as to what I may be doing wrong? Any help would be much appreciated. > > cca.o: In function `__malloc_alloc_template<0>::oom_malloc(unsigned int)': > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x17): undefined reference to `endl(ostream&)' > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x21): undefined reference to `cerr' > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x26): undefined reference to `ostream::operator<<(charconst *)' > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x31): undefined reference to `ostream::operator<<(ostream&(*)(ostream &))' > cca.o: In function `basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::Rep::copy(unsignedint, char const *, unsigned int)': > cca.o(.basic_string<char, string_char_traits<char>, __default_alloc_template<1, 0> >::Rep::gnu.linkonce.t.copy(unsignedint, char const *, unsigned int)+0x2a): undefined reference to `string_char_traits<char>::copy(char*, char const *, unsigned int)' > /usr/local/pgsql/lib/libpq++.so: undefined reference to `__out_of_range(char const *)' > /usr/local/pgsql/lib/libpq++.so: undefined reference to `__length_error(char const *)' > collect2: ld returned 1 exit status > make: *** [cca] Error 1 I believe g++ and egcs changed binary compatibility, so you need a libpq++ compiled with egcs. Larry > > Regards, > Tim > -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
on Dec 8, 2000, 1:53, Igor V. Rafienko replied:
-----
Name mangling is different between egcs and g++? Why are you trying to
compile with egcs?
[snip]
-----
compile with egcs?
[snip]
-----
I was not aware of this. I have several other binaries, not using pgsql, that were compiled under egcs and desired to the same compiler across all projects. If this is not possible, then I'll have to use g++ as well.
Tim
Larry Rosenman <ler@lerctr.org> writes: > * Tim Barnard <tbarnard@povn.com> [001208 15:25]: > > I am able to compile and link a c++ app with libpq++, provided I use g++. If I attempt to compile with egcs I get thefollowing link-time errors. Any ideas as to what I may be doing wrong? Any help would be much appreciated. > > > > cca.o: In function `__malloc_alloc_template<0>::oom_malloc(unsigned int)': > > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x17): undefined reference to `endl(ostream&)' > > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x21): undefined reference to `cerr' > > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x26): undefined reference to `ostream::operator<<(charconst *)' > > cca.o(.__malloc_alloc_template<0>::gnu.linkonce.t.oom_malloc(unsigned int)+0x31): undefined reference to `ostream::operator<<(ostream&(*)(ostream &))' > > cca.o: In function `basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::Rep::copy(unsignedint, char const *, unsigned int)': > > cca.o(.basic_string<char, string_char_traits<char>, __default_alloc_template<1, 0> >::Rep::gnu.linkonce.t.copy(unsignedint, char const *, unsigned int)+0x2a): undefined reference to `string_char_traits<char>::copy(char*, char const *, unsigned int)' > > /usr/local/pgsql/lib/libpq++.so: undefined reference to `__out_of_range(char const *)' > > /usr/local/pgsql/lib/libpq++.so: undefined reference to `__length_error(char const *)' > > collect2: ld returned 1 exit status > > make: *** [cca] Error 1 > I believe g++ and egcs changed binary compatibility Actually, no g++ releases are compatible. Nor is the same one across multiple glibcs. C++ is just a bad bet for binary compatibility - this will hopefully change when gcc 3 is out, but thats not just around the corner -- Trond Eivind Glomsrød Red Hat, Inc.