View previous topic :: View next topic |
Author |
Message |
Windstoss n00b
Joined: 08 Jul 2002 Posts: 19
|
Posted: Tue Aug 13, 2002 5:09 pm Post subject: undefined references, gcc2/gcc3 |
|
|
Hi,
I have installed both gcc2 and gcc3.
Code: |
# qpkg -I -i gcc
sys-devel/gcc-3.1.1-r1 *
Modern GCC C/C++ compiler [ http://www.gnu.org/software/gcc/gcc.html ]
sys-devel/gcc-2.95.3-r7 *
Modern GCC C/C++ compiler and an included, upgraded version of texinfo to boot [ http://www.gnu.org/software/gcc/gcc.html ]
|
I modified the buggy gcc-3.1 ebuild so it recognizes gcc-2 and installs gcc as gcc-3.1 etc. (return 0)
/etc/make.conf contains:
Code: |
GCC=gcc-3.1
CPP=cpp-3.1
CXX=c++-3.1
CC=$GCC
|
So on default emerge uses gcc-3
But: When compiling lichipcard (its not in portage yet) with gcc-2.95 (can't be compiled with gcc3) I get tons of undefined references. I talked with the developer of this lib/utility and he excluded any problems with the source itself so it looks like gcc is misconfigured.
Some of them:
Quote: |
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/stl_alloc.h:442: undefined reference to `KApplication::KApplication(bool, bool)'
main.o: In function `basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> >::replace(unsigned int, unsigned int, basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0> > const &, unsigned int, unsigned int)':
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `QApplication::setMainWidget(QWidget *)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KApplication::~KApplication(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KAboutData::~KAboutData(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `QApplication::exec(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KApplication::~KApplication(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KAboutData::~KAboutData(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KApplication::~KApplication(void)'
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/std/bastring.cc:131: undefined reference to `KAboutData::~KAboutData(void)'
collect2: ld returned 1 exit status
make[4]: *** [klcsetup] Error 1
make[4]: Leaving directory `/home/tristan/downloaded/libchipcard-0.5.3/src/kde/klcsetup'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/tristan/downloaded/libchipcard-0.5.3/src/kde'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/tristan/downloaded/libchipcard-0.5.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/tristan/downloaded/libchipcard-0.5.3'
|
Besides I noticed that the qt-mt check when configuring does not work when using gcc-2.95. (but: works with gcc-3.1)
I uncommented CC=gcc-3.1 etc. in /etc/make.conf
and did a:
Quote: |
emerge kportagemaster
It ends with:
checking for Qt... configure: error: Qt (>= Qt 3.0.3) (library qt-mt) not found. Please check your installation!
For more details about this problem, look at the end of config.log.
Make sure that you have compiled Qt with thread support!
|
Here is the end of the config.log
Quote: |
configure:6704: checking for Qt
configure: 6768: /usr/qt/3/include/qstyle.h
taking that
configure:6880: rm -rf SunWS_cache; c++ -o conftest -DNDEBUG -DNO_DEBUG -O2 -fno-exceptions -fno-check-ne
w -I/usr/qt/3/include -I/usr/X11R6/include -DQT_THREAD_SUPPORT -D_REENTRANT -L/usr/qt/3/lib -L/usr/X11
R6/lib conftest.C -lqt-mt -lpng -lz -lm -ljpeg -ldl -lXext -lX11 -lSM -lICE -lresolv -lpthread 1>&5
/var/tmp/portage/kportagemaster-0.4.2/temp/ccohBBMj.o: In function `main':
/var/tmp/portage/kportagemaster-0.4.2/temp/ccohBBMj.o(.text+0xb): undefined reference to `QString::null'
/var/tmp/portage/kportagemaster-0.4.2/temp/ccohBBMj.o(.text+0x10): undefined reference to `QStyleFactory:
:create(QString const &)'
/var/tmp/portage/kportagemaster-0.4.2/temp/ccohBBMj.o(.text+0x1e): undefined reference to `QCursor::QCurs
or(int)'
/var/tmp/portage/kportagemaster-0.4.2/temp/ccohBBMj.o(.text+0x29): undefined reference to `QCursor::~QCur
sor(void)'
collect2: ld returned 1 exit status
configure: failed program was:
#include "confdefs.h"
#include <qglobal.h>
#include <qapplication.h>
#include <qcursor.h>
#include <qstylefactory.h>
#include <private/qucomextra_p.h>
#if ! (QT_VERSION >= 303)
#error 1
#endif
|
So it looks like gcc-2.95 is not correctly installed. But what exactly is wrong and how to fix that? _________________ 42 |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Tue Aug 13, 2002 6:14 pm Post subject: |
|
|
gcc 2.95 is most likely correctly installed. this is 100% an ABI issue..i bet it only happens with C++ programs
anyway, the reason it dies is because you compiled QT with the gcc-3.1 right? which has a different "name mangeling" mechanism than gcc-2.x. End result...linking errors, usually undefined externals.
This is THE BIGGEST issue with the new gcc and it "breaking binary compatibility" basically if it's C++, you will need to compile all libraires that it links to with the same compiler....
so anyway, a workaround that COULD work (dunno i like gcc-3.2 all the way). emerge qt with gcc-2.9.x, then move that directory to a new one like "/usr/lib/compat/qt/3" or somthing, then emerge qt with the new gcc, you now have it installed with both ABIs...to configure make files to link to older QT, just Code: | export QTDIR="/usr/lib/compat/qt/3" | before the configure step.
now...RUNNING the program is a different story..not quite so simple, you will probably need to toggle QTDIR and run update-env to switch between QT for 2.95 more or QT for 3.x more...
but that's just for QT...what about other libs?
my advice, stick with one compiler if you are compiling a C++ program, it aint worth the effort, and gcc is technically superior anyway in both standards and resultant code. if somthing doesnt compile with new gcc, let the author know and tell them to fix there "broken" code
proxy |
|
Back to top |
|
|
Windstoss n00b
Joined: 08 Jul 2002 Posts: 19
|
Posted: Tue Aug 13, 2002 8:35 pm Post subject: |
|
|
.. funny,
This is what I planned to do next when I don't find a solution.. _________________ 42 |
|
Back to top |
|
|
trythil Tux's lil' helper
Joined: 06 Jun 2002 Posts: 123 Location: RHIT, Terre Haute, IN, USA
|
Posted: Tue Aug 13, 2002 10:00 pm Post subject: |
|
|
FYI, this is an issue with ANY C++ compiler -- not just G++. When using C++ libraries, you MUST compile your application with the same compiler that was used to build the library, because of the way each compiler implements name mangling (which is necessary for such things as function overloading, templates, etc.) |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Wed Aug 14, 2002 1:22 am Post subject: |
|
|
actually, as soon as gcc stabalizes there ABI this will no longer be a problem. Intel is already aiming for gcc 3.x binary compatibility. but of course point taken, this is an ABI issue, not a GCC issue, and is applicable to any compiler. |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Mon Aug 19, 2002 2:53 am Post subject: |
|
|
GCC3 to Portage & Programming, C++ compiler witchcraft. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|