Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Problem building Qt statically in Windows



  • Hi,

    I'm trying to deploy a small project by creating an executable file that works out of the box in Windows, so I need to compile Qt sources statically. I use the following configure command:

    @
    configure -release -static -platform win32-g++ -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -no-sql-sqlite -no-declarative -qt-sql-mysql -I C:\mysql\include -L C:\mysql\lib\opt -l mysql
    @

    Then I run mingw32-make. After some time compiling (more than half an hour, just in case that's relevant) I get the following output:

    @
    [...]
    g++ -c -Os -momit-leaf-frame-pointer -fno-exceptions -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQDOC2_COMPAT -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NO_DYNAMIC_CAST -I"....\include\QtCore" -I"....\include\QtXml" -I"....\include" -I"c:\mysql\include" -I"....\include\QtDeclarative" -I"declarativeparser" -I"....\include\ActiveQt" -I"tmp\moc\release_static" -I"....\mkspecs\win32-g++" -o tmp\obj\release_static\cppcodemarker.o cppcodemarker.cpp
    cppcodemarker.cpp: In member function 'QString CppCodeMarker::addMarkUp(const QString&, const Node*, const Location&)':
    cppcodemarker.cpp:950: error: 'isalpha' was not declared in this scope
    cppcodemarker.cpp:956: error: 'isalnum' was not declared in this scope
    cppcodemarker.cpp:973: error: 'isdigit' was not declared in this scope
    cppcodemarker.cpp:977: error: 'isalnum' was not declared in this scope
    cppcodemarker.cpp: At global scope:
    cppcodemarker.cpp:879: warning: 'QString untabified(const QString&)' defined but not used
    mingw32-make[3]: *** [tmp/obj/release_static/cppcodemarker.o] Error 1
    mingw32-make[3]: Leaving directory C:/Users/Arturo/Desktop/Qt/tools/qdoc3' mingw32-make[2]: *** [release] Error 2 mingw32-make[2]: Leaving directoryC:/Users/Arturo/Desktop/Qt/tools/qdoc3'
    mingw32-make[1]: *** [sub-qdoc3-make_default-ordered] Error 2
    mingw32-make[1]: Leaving directory `C:/Users/Arturo/Desktop/Qt/tools'
    mingw32-make: *** [sub-tools-make_default-ordered] Error 2
    @

    Can anybody give me any hints about what's wrong?

    Some additional info: I work in Windows 7, and I use gcc + MinGW to compile. The Qt sources are version 4.7.4, and I include the Qt MySQL plugin and the MySQL library.



  • you should restrict the static build on the libs.
    Have a look at "this wiki page":http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc



  • Nice link, it'd have saved me a good amount of time had I seen it earlier!

    Anyway, I'm already compiling after restricting the build on the libs. It'll take some time, so I'll post the results tomorrow.

    Thanks for the quick reply!



  • Regard the changes, that the wiki article describe. without them, itv was not compilable, as some modules do not support static building by default.



  • I found your problem description via Google. Had the same error message on Mac OS but I tried to compile to a shared library. The problem in my case was related to the -no-stl option (isAlpha) seems to be an STL function). By removing -no-stl from the configure line the problem was solved for me.



  • [quote author="Gerolf" date="1316007292"]Regard the changes, that the wiki article describe. without them, itv was not compilable, as some modules do not support static building by default.[/quote]

    Yeah, I applied them, except the one related to the WebKit, which I don't use.

    [quote author="hkhauke" date="1316008090"]The problem in my case was related to the -no-stl option (isAlpha) seems to be an STL function). By removing -no-stl from the configure line the problem was solved for me.
    [/quote]

    I was a bit puzzled about that, cause I thought isAlpha was part of the standard C library, and not of STL. Maybe I got something wrong... But anyway, restricting the compilation to just the Qt libraries, as suggested by Gerolf, solved the problem for me.

    Thank you all for your replies.



  • To correct
    cppcodemarker.cpp:950: error: 'isalpha' was not declared in this scope
    cppcodemarker.cpp:956: error: 'isalnum' was not declared in this scope
    cppcodemarker.cpp:973: error: 'isdigit' was not declared in this scope
    cppcodemarker.cpp:977: error: 'isalnum' was not declared in this scope

    In tools/qdoc3/cppcodemarker.cpp
    just add
    #include "ctype.h"
    to the list of #includes at the start of the file

    This fixed it for my system


Log in to reply