6
votes

I am trying to compile Qt (Windows 7, mingw32-g++ 32-bit under msys) and ld is running out of memory. Does anyone know why? Or perhaps a workaround? Thanks!

$ g++ -mthreads -shared -Wl,--out-implib,i:/Programs/Qt/lib/libQtGuid4.a -o ../
../lib/QtGuid4.dll object_script.QtGuid.Debug  -L'i:/Programs/Qt/lib' -L'i:/Pro
grams/Qt/lib' -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lws2_32
 -lole32 -luuid -luser32 -ladvapi32 tmp/obj/debug_shared/QtGuid_resource_res.o
-lmsimg32 -lshell32 -lQtCored4 -lz

i:/programs/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: o
ut of memory allocating 133614056 bytes
collect2.exe: error: ld returned 1 exit status

3
Do you have enough memory in the first place? 130 MB isn't really a lot...Mysticial
Sounds like the compiler is running in 32-bit mode. That'll cap it at 2GB on Windows. Have you tried 64-bit?Mysticial
mingw-w64 has a 64-bit toolchain.ephemient
If you're adventurous, you might try making ld.exe large address aware using editbin /largeaddressaware ld.exe - editbin comes with the Microsoft C/C++ toolchain, maybe it's in the SDK as well. This will make 4GB available to the process, but if the program has bugs dealing with pointers that have the high bit set (a common problem, which is why there's a special bit in the image's header to enable the feature) you might just run into other problems. So make a backup copy of ld.exe to revert to if necessary.Michael Burr
sourceforge.net/mailarchive/message.php?msg_id=28485608 there are a couple of suggestions here.user827992

3 Answers

5
votes

Thanks to all the commenters who helped me figure out a solution to this problem. What I did was replace ld with a large address aware version. I downloaded it from this MinGW build inside the bin folder. The post with the person linking that distribution is here. I hope this helps other people who run into this problem.

2
votes

If you install the current version of MinGW 4.6 or newer, then compile QT should specify the flag:

configure -platform win32-g++-4.6

In "mkspecs" for win32-g++4.6 already defined flag -fno-keep-inline-dllexport which resolves your problem.

1
votes

I tried to download ld.exe from somewhere else, but it was not fitting into my toolkit (TDM-GCC). Some plugin was not able to load. Hopefully, making ld.exe LAA was not that hard. I have opened ld.exe in a hex editor and patched at offset 0x96 "0f 03" to "2f 03". That did the trick for me.