Solved Windows build nmake paths too long
-
I'm attempting to build Qt 5.9.1 from source using the Visual Studio 2017 x86 tool chain. I'm using a separate build directory and the issue is that the compiler command generated for nmake are exceeding the limit allowed for command line.
My configure command is:
..\qt-src-5.9.1\configure -prefix ./vc-141-x86 -debug-and-release -opensource -confirm-license -platform win32-msvc -static -no-static-runtime -mp -dbus-runtime -no-harfbuzz -no-egl -no-eglfs -no-freetype -no-gif -no-glib -no-gstreamer -no-icu -no-kms -no-libudev -no-mtdev -no-reduce-relocations -no-qml-debug -no-sql-db2 -no-sql-ibase -no-sql-oci -no-sql-tds -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-use-gold-linker -nomake examples -nomake tests -openssl-linked -opengl desktop -optimized-qmake -pch -qt-libpng -qt-libjpeg -qt-pcre -qt-zlib -silent -verbose -no-feature-printer -no-feature-printdialog -I "f:/deps/openssl/1.1.0/vc141-x86/include" -L "f:/deps/openssl/1.1.0/vc141-x86/lib" -skip qt3d -skip qtdoc -skip qtwayland -skip qtwebview -skip qtwebengine -skip qtwebchannel -skip qtscript
And then when executing nmake the error I get is shown below. I've attempted to shorten the paths to the various source files and dependencies but I doubt I'd be able to get them short enough to get under the limit given the number of path being passed to the compiler.
NMAKE : fatal error U1095: expanded command line 'echo compiling F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qarraydata.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qbitarray.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qbytearray.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qbytearraylist.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qbytearraymatcher.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcollator.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcryptographichash.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qdatetime.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qdatetimeparser.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qeasingcurve.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qfreelist.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qhash.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qline.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qlinkedlist.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qlist.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qlocale.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qlocale_tools.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qpoint.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qmap.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qmargins.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qmessageauthenticationcode.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcontiguouscache.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qrect.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qregexp.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qrefcount.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qringbuffer.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qshareddata.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qsharedpointer.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qsimd.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qsize.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qstring.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qstringbuilder.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qstringlist.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qtextboundaryfinder.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qtimeline.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qunicodetools.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qvsnprintf.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qversionnumber.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qlocale_win.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcollator_win.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qtimezone.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qtimezoneprivate.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qtimezoneprivate_win.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qregularexpression.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcommandlineoption.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qcommandlineparser.cpp F:\deps\qt-src-5.9.1\qtbase\src\corelib\tools\qharfbuzz.cpp && cl -c -FIqt_pch.h -Yuqt_pch.h -Fp.pch\debug\Qt5Cored_pch.pch -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zi -MDd -utf-8 -EHsc -MP -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /Fd....\lib\Qt5Cored.pdb -DUNICODE -DWIN32 -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DPCRE2_CODE_UNIT_WIDTH=16 -DPCRE2_STATIC -IF:\deps\qt-src-5.9.1\qtbase\src\corelib -I. -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\zlib -Iglobal -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\harfbuzz\src -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\md5 -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\md4 -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\sha3 -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\double-conversion\include -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\double-conversion\include\double-conversion -IF:\deps\qt-src-5.9.1\qtbase\include -IF:\deps\qt-src-5.9.1\qtbase\include\QtCore -I....\include -I....\include\QtCore -IF:\deps\qt-src-5.9.1\qtbase\include\QtCore\5.9.1 -IF:\deps\qt-src-5.9.1\qtbase\include\QtCore\5.9.1\QtCore -I....\include\QtCore\5.9.1 -I....\include\QtCore\5.9.1\QtCore -Itmp -I.moc\debug -IF:\deps\qt-src-5.9.1\qtbase\src\3rdparty\pcre2\src -If:\deps\openssl\1.1.0\vc141-x86\include -IF:\deps\qt-src-5.9.1\qtbase\mkspecs\win32-msvc -Fo.obj\debug\
@C:\Users\User\AppData\Local\Temp\nm9613.tmp' too long
Stop.
NMAKE : fatal error U1077: '"f:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop. -
Are you able to alias some paths? I'm not really across nmake but I know when System PATH environment variables reach the max limit bad things happen.
SQL was the worst offender when I had 3 VS environments and god knows how many SQL engines/tools...
I would use new sys env vars (something like):
%SQL86% == C:\Program Files (x86)\Microsoft SQL Server\ %SQL% == C:\Program Files\Microsoft SQL Server\
Then inside System PATH, I'd replace the string literals with the variables, so entries like this
C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\ C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\ C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\
end up looking like this:
%SQL86%Client SDK\ODBC\130\Tools\Binn\ %SQL86%130\DTS\Binn\ %SQL86%130\Tools\Binn\ManagementStudio\
There's many many more entries in the case of just one SQL install... but even this example of 3 path entries, the math is:
44 * 3 = 132 original chars in PATH
8 * 3 = 24 same effect with alias'sAnyhow, I might be way off... if I am I apologise.
-
Yes those SQL Server paths are annoying. In my case I've long since removed them. I'm pretty sure that the environment variables are expanded when the command is executed so making that switch won't help in this case.
-
@azaclauson
Looking at your error, I don't see where environment variables are particularly making it too long, it's mostly the length of all the filenames?Also, the command is
echo
, not run the compiler, which is maybenmake
's way of telling you what it's about to do`? Then it's just possible that it might put the filenames into a file and then call the compiler with no command line length problem? (Or, maybe it would actually compile them one at a time --- is this command line just doing compiles or does it link too?)See https://msdn.microsoft.com/en-us/library/dt309377.aspx, https://stackoverflow.com/questions/9344489/expanded-command-line-too-long for some possible ideas....
What is strange is that you would have thought this would affect other peoples' Windows builds. I don't suppose you can
SUBST Z: F:\deps\qt-src-5.9.1\qtbase\src
, or similar, and get it to work, can you? -
Using a build directory underneath the root of the source directory rather than next to it solves the issue. When it's underneath the build scripts use ".." to locate source files, when it's beside they put in the full path.
-
This post is deleted!