View Full Version : How to statically link qt?
pinzmon
12-23-2001, 03:27 PM
I love v4, but all of my other apps want the old qt libs. How do I modify the make to statically link the 2.3.2 libs?
pinzmon
12-24-2001, 02:22 AM
Anyone? Zaphod?
fryfrog
12-24-2001, 04:30 AM
it is my understanding that qt-2.3.2 should be backward compatible to qt-2.3.1, so along these lines... i did an rpm -e qt-devel --nodeps and rpm -e qt --nodeps. i THEN made /usr/lib/qt-2.3.1 a symlink to /usr/lib/qt-2.3.2 and haven't really had any problems since. i did this because at SOME point, KDE barfed and spit out qt errors (this was when i had just rpm -e qt, then rm -Rf /usr/lib/qt-2.3.1 due to seq STILL trying to insist on using qt-2.3.1). also, be sure to put /usr/lib/qt-2.3.2 in your /etc/ld.so.conf and run ldconfig
ln -s /usr/lib/qt-2.3.2/ /usr/lib/qt-2.3.1
pinzmon
12-24-2001, 11:36 AM
Thanks, fry, that will probably work for me! I'll try it.
But, just for my own continuing education how do I tell something to statically link in a library? I've been looking at this for a couple of days now, and I would love to close the loop on the solution I was looking for.
pinzmon
12-24-2001, 05:10 PM
Interesting - it doesn't work. Kwrite and Knode both give errors loading shared libraries with the 2.3.2 version of qt. if I put the symbolic links back to the 2.3.1 version, they run fine.
kwrite: error while loading shared libraries: /usr/lib/libDCOP.so.1: undefined symbol: newItem__11QCollectionPv
[root@denmdk etc]# knode
knode: error while loading shared libraries: /usr/lib/libDCOP.so.1: undefined symbol: _7QString.shared_null
Any ideas? Still interested in statically linking showeq with qt2.3.2 as well.
fryfrog
12-24-2001, 10:40 PM
instead of just changing a symbolic link, try removing the qt-2.3.1 dir entirely (be sure you have the qt-rpms on hand, its easy enough to fix).
then, be SURE you put "/usr/lib/qt-2.3.2/lib" into the file /etc/ld.so.conf then re-run "ldconfig"
this is of course AFTER you have compiled qt with the ./configure -thread option (and NOT....)
doh, mid-post i realized why it probably won't work. showeq wants to be compiled with gcc3 (which meants qt has to be compiled with gcc3... which means only programs compiled WITH gcc3 can USE qt (i think?))
anyway, that is starting to make me wonder why my linux system at home is actually working... perhaps its because i'm ONLY using kde and showeq, not running any other apps that i can think of... humm, super freaky.
pinzmon
12-24-2001, 10:46 PM
I've tried it both ways - just changing the symbolic link, updating ld.so.conf, and running ldconfig, and also removing 2.3.1 altogether, updating ld.so.conf and running ldconfig.
either way, if 2.3.1 is set, then kwrite & knode work, but showeq won't or, if 2.3.2 is setup, then showeq works, but not kwrite & knode.
this bites.
Thanks for your tips, though, fry. I appreciate you taking the time.
fyodorst
12-24-2001, 11:38 PM
i assume you have set all env variable correctly
pinzmon
12-25-2001, 10:50 AM
Yep, and, if I put /usr/local/qt/lib (contains 2.3.2) in front of /usr/lib (contains 2.3.1) in the LD_LIBRARY_PATH first, then showeq works, but not kwrite. Reverse the order, and kwrite works, but not showeq. So, i can set up a script to reverse the order, export, source, and run showeq, but it sure is a kludge.
pinzmon
12-25-2001, 04:07 PM
OK, I just scripted it. Now everything is happy happy. But, the original question on this thread is "How do I compile seq with qt statically linked?
Someone has to know. Please tell me so I will learn something.
Thanks!
pinzmon
12-26-2001, 11:02 PM
No one?
KennySP
12-27-2001, 05:17 PM
Just spent a couple hours figuring it out:
You need to compile QT statically, and then compile showeq statically.
Following Zaphod's instructions at http://seq.sourceforge.net/showthread.php?s=&threadid=70 you will replace the following command:
./configure -release -shared -gif -xft -sm -system-libmng -system-zlib -system-libpng -system-jpeg -no-g++-exceptions -thread
With this command:
./configure -release -static -gif -xft -sm -system-libmng -system-zlib -system-libpng -system-jpeg -no-g++-exceptions -thread
Then recompile qt-2.3.2.
Now is qt compiled statically (You should have: libqt.a, libqt-mt.a and libqutil.a files in your /usr/lib/qt-2.3.2/lib directory)
Then goto your showeq source directory.
do:
make -f Makefile.dist
./configure --disable-shared --enable-static
make
You aren't done yet, all your .o files are made correctly, but the statically linked showeq program file is not.
You need to then run the following command:
g++3 -D_REENTRANT -O2 -Wall -g -ggdb -DDEBUG -finline-functions -DQT_THREAD_SUPPORT=1 -o showeq main.o spawn.o spawnshell.o spawnlist.o spellshell.o spelllist.o preferences.o m_preferences.o vpacket.o editor.o filter.o m_spawnshell.o m_spawnlist.o m_spellshell.o m_spelllist.o m_editor.o packet.o m_packet.o interface.o m_interface.o compass.o m_compass.o map.o m_map.o util.o experiencelog.o m_experiencelog.o msgdlg.o m_msgdlg.o player.o m_player.o decode.o m_decode.o skilllist.o m_skilllist.o statlist.o m_statlist.o filtermgr.o m_filtermgr.o mapcore.o category.o m_category.o compassframe.o m_compassframe.o group.o m_group.o itemdb.o gdbmconv.o /usr/lib/qt-2.3.2/lib/libqt.a /usr/lib/qt-2.3.2/lib/libqutil.a /usr/lib/qt-2.3.2/lib/libqt-mt.a -L/usr/lib/qt-2.3.2/lib -lqt-mt -lpthread -lEQ /usr/lib/libgdbm.so -lz -lpcap
The differance here is that you are not only compiling in all the .o files, but also compiling in the qt.a static files.
If you scroll up to the line starting like the command I just gave you you will notice that it is missing:
/usr/lib/qt-2.3.2/lib/libqt.a
/usr/lib/qt-2.3.2/lib/libqutil.a
/usr/lib/qt-2.3.2/lib/libqt-mt.a
Doing that you should be able to mv the /usr/lib/qt-2.3.2 directory and still run showeq.
Also this should make it so that you can compile on a machine with qt-2.3.2 and GCC3 and run it on a machine without those, althought I have not tested it. You *MAY* need to statically link in the GCC libs and also any glibc libs as well, which I will leave as an excercise to the user. Just follow the hints on statically compiling in the libqt.a and you should figure it out just fine.
Hope that helps,
KennySP
EDIT: Oh and for referance on why shared libraries are a *GOOD* thing overall just look at the following:
The stripped version of showeq using shared libs is:
1204820 kbytes (1.2MB)
While the statically compiled version of showeq is:
16812431 kbytes (16.8MB) -- if you need to statically compile in glibc it will add even more size.
KennySP
12-28-2001, 12:17 PM
Did this help you? Or were you looking for something more detailed?
KennySP
pinzmon
12-28-2001, 10:40 PM
KennySP, you are my god. thanks for taking the time to figure it out - it worked perfectly.
Many thanks :)
Powered by vBulletin® Version 4.1.11 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.