Jean-Marc Lasgouttes wrote:
>>>  Did you succeed with static linking?
> 
> Angus> Nope. Haven't tried.
> 
> Angus> Do I need to re-compile (witness the QT_DIR,
> Angus> __declspec(dllimport) discussion) or can I just redo the
> Angus> linking step? If the latter, what flags should I pass to the
> Angus> compiler to link against libqt.a rather than qt3.dll?
> 
> Do Michael's explanation there help?
> http://www.mail-archive.com/lyx-devel AT lists.lyx.org/msg76978.html

In a moment of clear thinking, I tried to force the linker to load the qt
libraries statically.

$ time i386-mingw32-g++ -g -O -W -Wall -mms-bitfields
-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,--export-all-symbols -o
lyx.exe BufferView.o BufferView_pimpl.o
<more object files>
trans.o trans_mgr.o undo.o undo_funcs.o vc-backend.o version.o vspace.o
mathed/.libs/libmathed.a insets/.libs/libinsets.a
frontends/.libs/libfrontends.a -L/home/angus/mingw-xcompile/qt3//lib
-Bstatic -lqtmain -lqt -Bdynamic graphics/.libs/libgraphics.a
support/.libs/libsupport.a ../boost/libs/regex/src/.libs/libboostregex.a 
./boost/libs/signals/src/.libs/libboostsignals.a ../intl/libintl.a -lm

real    14m2.239s
user    11m51.847s
sys     0m8.961s

Ie, I changed the original "-lqt3" to "-Bstatic -lqtmain -lqt -Bdynamic".

However, this doesn't look very promising (identical size of the nominally
statically linked and dynamic executables):

$ cp lyx.exe /mnt/windowsJ/Programs/LyX/bin/lyx-static.exe
$ ls -l /mnt/windowsJ/Programs/LyX/bin
total 40944
-rwxr-xr-x  1 angus angus 11475968 Apr 22 08:51 lyx.exe
-rwxr-xr-x  1 angus angus 11475968 Apr 22 14:17 lyx-static.exe
-rwxr-xr-x  1 angus angus     3945 Apr 22 08:51 noweb2lyx
-rwxr-xr-x  1 angus angus  6437888 Apr 22 11:23 qt3.dll
-rwxr-xr-x  1 angus angus  6437888 Apr 22 10:48 qt3-native.dll
-rwxr-xr-x  1 angus angus  6077440 Apr 22 11:19 qt3-xcompile.dll
-rwxr-xr-x  1 angus angus     2660 Apr 22 08:51 reLyX

-rwxr-xr-x  1 angus angus 11475968 Apr 22 08:51 lyx.exe
-rwxr-xr-x  1 angus angus 11475968 Apr 22 14:17 lyx-static.exe

Sure enough, reboot under Windows and
$ cd J:/Programs/LyX/bin
$ mkdir static
$ mv lyx-static.exe static
$ cd static
$ ./lyx-static

results in the dreaded dialog:

lyx-static.exe - Unable to Locate Component
This application has failed to start because qt3.dll was not found.
Reinstalling the application may fix the problem.

Grrrrrrrr.

Try two. Same thing but replace the original "-lqt3" with
"/home/angus/mingw-xcompile/qt3/lib/libqtmain.a
 /home/angus/mingw-xcompile/qt3/lib/libqt.a"

$ time i386-mingw32-g++ -g -O -W -Wall -mms-bitfields -o lyx.exe
BufferView.o BufferView_pimpl.o Bullet.o Chktex.o CutAndPaste.o DepTable.o
FloatList.o Floating.o FuncStatus.o InsetList.o LColor.o LaTeX.o
LaTeXFeatures.o LyXAction.o MenuBackend.o paragraph_funcs.o
ParagraphList.o ParagraphParameters.oSpacing.o TextCache.o Thesaurus.o
ToolbarDefaults.o boost.o boost-inst.o box.o buffer.o bufferlist.o
bufferparams.o bufferview_funcs.o chset.o converter.o counters.o debug.o
encoding.o exporter.o gettext.o factory.o funcrequest.o importer.o intl.o
iterators.o kbmap.o kbsequence.o language.o lastfiles.o lengthcommon.o
lyx_cb.o lyx_main.o lyx_sty.o lyxcursor.o lyxfont.o lyxfind.o lyxfunc.o
lyxgluelength.o lyxlayout.o lyxlength.o lyxlex.o lyxlex_pimpl.o lyxrc.o
lyxrow.o lyxserver.o lyxtextclass.o lyxtextclasslist.o lyxvc.o main.o
paragraph.o paragraph_pimpl.o ispell.o pspell.o sgml.o tabular.o
tabular-old.o tabular_funcs.o tex-accent.o tex-strings.o texrow.o text.o
text2.o text3.o toc.o trans.o trans_mgr.o undo.oundo_funcs.o vc-backend.o
version.o vspace.o mathed/.libs/libmathed.a insets/.libs/libinsets.a
frontends/.libs/libfrontends.a 
/home/angus/mingw-xcompile/qt3/lib/libqtmain.a 
/home/angus/mingw-xcompile/qt3/lib/libqt.a 
graphics/.libs/libgraphics.a support/.libs/libsupport.a 
../boost/libs/regex/src/.libs/libboostregex.a 
../boost/libs/signals/src/.libs/libboostsignals.a 
../intl/libintl.a -lm

real    10m1.570s
user    6m23.170s
sys     0m7.731s

Hmmm. Interesting. Quicker to link. Of course, I also removed the "-Wl,s"
option from the command line, so comparison of sizes is meaningless unless
I strip the executable myself.

$ cp lyx.exe lyx1.exe
$ i386-mingw32-strip lyx.exe
$ ls -l lyx*.exe
-rwxrwxr-x  1 angus angus 163730444 Apr 22 14:52 lyx1.exe
-rwxrwxr-x  1 angus angus   9978880 Apr 22 14:53 lyx.exe

Wooooo. It's a different size! I guess I should reboot again and try it
out...

... back again. The bloody error dialog popped up again, warning me that it
couldn't find qt3.dll.

I have NO idea where the linker is getting info about qt3.dll. Frankly, I
no longer care. Windows is just evil.


-- 
Angus

Reply via email to