From owner-freebsd-questions@FreeBSD.ORG Tue Mar 2 18:40:03 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 315B416A4CE for ; Tue, 2 Mar 2004 18:40:03 -0800 (PST) Received: from www.mcmanis.com (www.mcmanis.com [66.125.189.29]) by mx1.FreeBSD.org (Postfix) with SMTP id 5398943D39 for ; Tue, 2 Mar 2004 18:40:02 -0800 (PST) (envelope-from cmcmanis@mcmanis.com) Received: (qmail 32002 invoked from network); 3 Mar 2004 02:50:17 -0000 Received: from nat-198-95-226-231.netapp.com (HELO ddp.hq.netapp.com) (198.95.226.231) by www.mcmanis.com with SMTP; 3 Mar 2004 02:50:17 -0000 From: Charles McManis To: Scott W Date: Tue, 2 Mar 2004 18:43:19 -0800 User-Agent: KMail/1.5 References: <200403021119.06516.cmcmanis@mcmanis.com> <4045247E.2050100@mindcore.net> In-Reply-To: <4045247E.2050100@mindcore.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403021843.19858.cmcmanis@mcmanis.com> cc: freebsd-questions@freebsd.org Subject: Re: Can one compile khello.cc ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2004 02:40:03 -0000 Thanks Scott for some patient steps toward getting things going. It took many additional steps, but I think I've finally got it going ... to wit: On Tuesday 02 March 2004 16:19, Scott W wrote: > If you have a pointer to the KDE tutorial/code you're using, may be of > more help, but here's a quick 'khello' program, step by step: On this page: Is a link to the "Khello" tutorial. Your source code was : > [wegster@db KDETutorial]$ cat main.cc > #include > #include > > int main(int argc, > char **argv) > { > QApplication app( argc, argv ); > > QPushButton *hello=new QPushButton( "Hello world!", 0 ); > hello->resize(200, 30 ); > > QObject::connect(hello, > SIGNAL(clicked()), > &app, > SLOT(quit()) ); > > app.setMainWidget(hello); > hello->show(); > > return app.exec(); > } This is the khello.cc source code: #include #include int main( int argc, char **argv ) { KApplication a( argc, argv, "khello" ); KMainWindow *w = new KMainWindow(); w->setGeometry(100,100,200,100); a.setMainWidget( w ); w->show(); return a.exec(); } It is similar to yours, while yours is nominally a "Qt" application, KHello is a "KDE" application and uses the KDE libraries. However, using your example code instead ... > wegster@db KDETutorial]$ g++ main.cc This behaves the same, and adding -I/usr/X11R6/include allows it to find the qt header files. > Yep, that works. But to get a running executable, you need to resolve > library dependencies, in this case likely the QT library...let's find it > first: And on FBSD there is no libqt, instead you get libqt-mt. I don't know why, but it just is. The port directory is /usr/ports/x11-toolkits/qt31 and the resulting package only has libqt-mt. > [wegster@db KDETutorial]$ g++ main.cc -I /usr/lib/qt-3.1/include > -L/usr/lib/qt-3.1/lib/ -lqt On your RHES system that just returns to the prompt, on a FBSD 4.8 system it gives you this: ddp% g++ main.cc -I/usr/X11R6/include -L/usr/X11R6/lib -lqt-mt /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libGL.so.1, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libXmu.so.6, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libXrender.so.1, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libXft.so.2, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libXext.so.6, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libX11.so.6, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libSM.so.6, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libICE.so.6, needed by /usr/X11R6/lib/libqt-mt.so, not found (try using -rpath or -rpath-link) /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libstdc++.so.3, needed by /usr/X11R6/lib/libqt-mt.so, may conflict with libstdc++.so.5 /var/tmp//cchuRUZV.o(.text+0x23): In function `main': : undefined reference to `QApplication::QApplication[in-charge](int&, char**)' /var/tmp//cchuRUZV.o(.text+0x52): In function `main': : undefined reference to `QString::QString[in-charge](char const*)' /var/tmp//cchuRUZV.o(.text+0x61): In function `main': : undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)' /var/tmp//cchuRUZV.o(.text+0x12c): In function `main': : undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*)' /var/tmp//cchuRUZV.o(.text+0x13e): In function `main': : undefined reference to `QApplication::setMainWidget(QWidget*)' /var/tmp//cchuRUZV.o(.text+0x164): In function `main': : undefined reference to `QApplication::exec()' /var/tmp//cchuRUZV.o(.text+0x175): In function `main': : undefined reference to `QApplication::~QApplication [in-charge]()' /var/tmp//cchuRUZV.o(.text+0x195): In function `main': : undefined reference to `QApplication::~QApplication [in-charge]()' /var/tmp//cchuRUZV.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x21): In function `QString::~QString [in-charge]()': : undefined reference to `QString::shared_null' /var/tmp//cchuRUZV.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x30): In function `QString::~QString [in-charge]()': : undefined reference to `QStringData::deleteSelf()' /usr/X11R6/lib/libqt-mt.so: undefined reference to `XFreePixmap' /usr/X11R6/lib/libqt-mt.so: undefined reference to `XSetInputFocus' /usr/X11R6/lib/libqt-mt.so: undefined reference to `pthread_cleanup_pop' /usr/X11R6/lib/libqt-mt.so: undefined reference to `glXQueryServerString' ... snip LOTS of undefined references ... /usr/X11R6/lib/libqt-mt.so: undefined reference to `XOpenDisplay' /usr/X11R6/lib/libqt-mt.so: undefined reference to `FcFontSetDestroy' /usr/X11R6/lib/libqt-mt.so: undefined reference to `XDrawImageString16' /usr/X11R6/lib/libqt-mt.so: undefined reference to `glXCreateGLXPixmap' /usr/X11R6/lib/libqt-mt.so: undefined reference to `XftDrawPicture' collect2: ld returned 1 exit status ddp% > [wegster@db KDETutorial]$ ./a.out > > Works ;-) > > NOTE: This was done on a RHES system, because I've got the KDE > development headers and libs installed. For FreeBSD, you'll need the qt > sources or a KDE development package, although I'm not entirely sure > which offhand... Of course following in your excellent footsteps of doing this one step at a time, if I change the compile line to include -R/usr/X11R6/lib and -pthread because threading is required on FBSD apparently, I'm left with this: ddp% g++ main.cc -I/usr/X11R6/include -L/usr/X11R6/lib -R/usr/X11R6/lib -lqt-mt -pthread /usr/local/gnu/lib/gcc-lib/i386-unknown-freebsd4.8/3.2.3/../../../../i386-unknown-freebsd4.8/bin/ld: warning: libstdc++.so.3, needed by /usr/X11R6/lib/libqt-mt.so, may conflict with libstdc++.so.5 /usr/lib/libc.so.4: WARNING! setkey(3) not present in the system! /usr/lib/libc.so.4: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so.4: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so.4: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so.4: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so.4: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so.4: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so.4: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so.4: warning: tempnam() possibly used unsafely; consider using mkstemp() /var/tmp//ccDbWE2R.o(.text+0x23): In function `main': : undefined reference to `QApplication::QApplication[in-charge](int&, char**)' /var/tmp//ccDbWE2R.o(.text+0x52): In function `main': : undefined reference to `QString::QString[in-charge](char const*)' /var/tmp//ccDbWE2R.o(.text+0x61): In function `main': : undefined reference to `QPushButton::QPushButton[in-charge](QString const&, QWidget*, char const*)' /var/tmp//ccDbWE2R.o(.text+0x12c): In function `main': : undefined reference to `QObject::connect(QObject const*, char const*, QObject const*, char const*)' /var/tmp//ccDbWE2R.o(.text+0x13e): In function `main': : undefined reference to `QApplication::setMainWidget(QWidget*)' /var/tmp//ccDbWE2R.o(.text+0x164): In function `main': : undefined reference to `QApplication::exec()' /var/tmp//ccDbWE2R.o(.text+0x175): In function `main': : undefined reference to `QApplication::~QApplication [in-charge]()' /var/tmp//ccDbWE2R.o(.text+0x195): In function `main': : undefined reference to `QApplication::~QApplication [in-charge]()' /var/tmp//ccDbWE2R.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x21): In function `QString::~QString [in-charge]()': : undefined reference to `QString::shared_null' /var/tmp//ccDbWE2R.o(.gnu.linkonce.t._ZN7QStringD1Ev+0x30): In function `QString::~QString [in-charge]()': : undefined reference to `QStringData::deleteSelf()' collect2: ld returned 1 exit status ddp% Now being really confused I tracked down part of the problem to that message about std++0.5.0 and realized I had a newer g++ in my path (ahh the joys of an rdisted /usr/local/bin) So I fixed up my path to force the one from /usr/bin to be used and now with minor annoyances your simple program works. (annoyances in the form of some complaint about GLX on the :0 display) However, when I go back to my KDE application whch is using KApplication and KWindow, so my final link line is something like: ddp% make g++ -o khello -R/usr/X11R6/lib -L/usr/local/lib/kde3/ -L/usr/local/lib -L/usr/X11R6/lib -lqt-mt -pthread -lkdecore -lkdeui khello.o /usr/lib/libc.so.4: WARNING! setkey(3) not present in the system! /usr/lib/libc.so.4: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so.4: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so.4: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so.4: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so.4: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so.4: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so.4: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so.4: warning: tempnam() possibly used unsafely; consider using mkstemp() ddp% ./khello Xlib: extension "GLX" missing on display ":0.0". Xlib: extension "GLX" missing on display ":0.0". ddp% Not sure if I can squelch the libc warnings but at least I've got a simple program compiled. --Chuck