Page 1 of 1

"incorrect parameter" in codeblocks mingw32 build

Posted: 15 Sep 2010, 06:30
by SpliFF

Code: Select all

Linking CXX executable ..\..\..\spring-multithreaded.exe
D:\Apps\CodeBlocks\MinGW\bin\g++.exe    -mwindows -march=i686 -msse -mfpmath=sse -mthreads -fsingle-precision-constant -frounding-math -mieee-fp -pipe -fno-strict-aliasing   -mno-tls-direct-seg-refs  -O0 -Wall -Wno-sign-compare -DDEBUG -D_DEBUG -DNO_CATCH_EXCEPTIONS -ggdb2  -Wl,--enable-auto-import CMakeFiles\spring-multithreaded.dir\__\__\Game\Action.cpp.obj CMakeFiles\spring-multithreaded.dir\__\__\Game\AviVideoCapturing.cpp.obj CMakeFiles\spring-multithreaded.dir\__\__\Game\Camera.cpp.obj CMakeFiles\spring-multithreaded.dir\__\__\Game\CameraHandler.cpp.obj 

... big list of objects ...

-o ..\..\..\spring-multithreaded.exe -Wl,--out-implib,libspring-multithreaded.dll.a -Wl,--major-image-version,0,--minor-image-version,0  ..\..\lib\gml\libgml.a -lmingw32 D:\Source\mingwlibs\lib\libSDLmain.a D:\Source\mingwlibs\dll\SDL.dll -lpthread -lopengl32 -lglu32 D:\Source\mingwlibs\dll\glew32.dll D:\Source\mingwlibs\dll\freetype6.dll ..\..\System\Sound\libsound.a D:\Source\mingwlibs\lib\libdevil.a ..\..\lib\assimp\code\libassimp.a D:\Source\mingwlibs\lib\libboost_regex-mt.a D:\Source\mingwlibs\lib\libboost_thread-mt.a D:\Source\mingwlibs\lib\libboost_program_options-mt.a D:\Source\mingwlibs\lib\libboost_system-mt.a D:\Source\mingwlibs\lib\libboost_signals-mt.a ..\..\lib\lua\liblua.a ..\..\lib\7z\lib7zip.a ..\..\lib\oscpack\liboscpack.a ..\..\lib\minizip\libminizip.a ..\..\lib\streflop\libstreflop.a ..\..\lib\lobby\liblobby.a -limagehlp -lws2_32 -lwinmm -lmingw32 D:\Source\mingwlibs\dll\OpenAL32.dll D:\Source\mingwlibs\dll\ogg.dll D:\Source\mingwlibs\dll\vorbisfile.dll D:\Source\mingwlibs\dll\vorbis.dll -lmingw32 D:\Source\mingwlibs\lib\libSDLmain.a D:\Source\mingwlibs\dll\SDL.dll -lpthread D:\Source\mingwlibs\dll\zlib1.dll D:\Source\mingwlibs\lib\libboost_thread-mt.a D:\Source\mingwlibs\lib\libboost_system-mt.a ..\..\lib\streflop\libstreflop.a -limagehlp -lws2_32 -lwinmm ..\..\lib\md5\libmd5.a 
Error running link command: The parameter is incorrect
"The parameter" ?? That's descriptive!

Can anyone tell me which parameter "the parameter" might be? Any clues to why I get this?

Makefiles generated by CMake 2.6.2 (Codeblocks Project)
Codeblocks 10.05 with included MinGW

Code: Select all

>> echo %PATH%
c:\Program Files\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\Program Files\Common Files\GTK\2.0\bin;d:\Apps\CMake2.6\bin;d:\apps\codeblocks\mingw\bin

>> mingw32-make -v
GNU Make 3.81

C:\Documents and Settings\User1>g++ -v
Using built-in specs.
Target: mingw32
Configured with: ../../gcc-4.4.1/configure --prefix=/mingw -build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-registry --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sections' --disable-werror --enable-threads --disable-symvers --enable-version-specific-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32' --enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php
Thread model: win32
gcc version 4.4.1 (TDM-2 mingw32)

>> ld -v
GNU ld (GNU Binutils) 2.19.1
EDIT: I've just noticed the notes about TDM on the compiling for windows page of the wiki. Could be related. I'll try the alternate mingwlibs download mentioned there and see if that helps. The other alternative would be to use the MingW official package rather than the CodeBlocks one.

Re: "incorrect parameter" in codeblocks mingw32 build

Posted: 15 Sep 2010, 10:10
by hoijui
it only happens when compiling spring-multithreaded? what about spring, spring-headless, spring-dedicated?
when compiling with javac, i once had the problem with "" parameters. in theory, this could be something similar, maybe.

Re: "incorrect parameter" in codeblocks mingw32 build

Posted: 16 Sep 2010, 07:34
by SpliFF
I found the problem. It's in windows itself.

Under windows there is a maximum length of about 32,000 characters that can be used as arguments to a command. That sounds like a lot but it can be exhausted pretty quickly if you're passing a lot of object files to the linker. Instead of telling you what the problem is the underlying win32 API will crap out with a generic, and incorrect message that "the parameter is incorrect".

There's no fix for this but there are potential workarounds:

1.) Reduce the number of objects being linked at once. In essence this means making Spring more modular, compiling those modules into static or dynamic libraries then linking them.

2.) Hack at mingw and/or cmake and tell it to pass object lists longer than the maximum size as a @file parameter. That means save the object list to a "filelist.txt" and pass that to ld.exe as @filelist.txt. This isn't something we can easily do ourselves but maybe a patch could be sent to those projects since it isn't something specific to Spring.

3.) Find out if msys works around this bug and if so create an msys target in cmake.

4.) Use scons?

Anyway, fuck Microsoft.

Re: "incorrect parameter" in codeblocks mingw32 build

Posted: 16 Sep 2010, 11:12
by hoijui
already told this to spliff in chat, but so that everyone knows:

1) is in the making, but it will take long (most likely years). before the split into sub-libs can be done, the internal-/code-structure has to be modular, as otherwise all the symbols had to be externalized.

i would not recommend SCons, as it is already quite outdated (some stuff not supported anymore), and will get so more and more.

5) use small paths:
eg, have spring sources at C:/spr/ instead of C:/MyProjects/OpenSource/Spring/repositories/master/; same for build dir.
i know it sounds like a joke, but it works. ;-)

Re: "incorrect parameter" in codeblocks mingw32 build

Posted: 17 Sep 2010, 11:14
by SpliFF
Problem solved.

Turns out the best option (2.) was patched into CMake some time ago. Therefore the solution in the end was as simple as upgrading to CMake 2.8.

In light of this, I'll be suggesting on mantis we move the minimum CMake version from 2.6 to 2.8 so prevent people being caught unaware by this issue.