顯示具有 Qt 標籤的文章。 顯示所有文章
顯示具有 Qt 標籤的文章。 顯示所有文章

2019年7月10日 星期三

Cross-Compile the Qt Libraries for Nvidia® Jetson TX2 and Set the QtCreator Environment

   

※ 2021, 5, 28, update to Qt version 5.15.2.
  
     For some high-end use cases, like car self-driving, medical devices, telemetry equipments and so forth, the specifications for the devices are usually peculiar.Nvidia® Jetson series are for filling the requirements : the embedded systems integrated with the CUDA function : a special system, with the special peripherals and sensors, with the special computation ability for the special purpose.
 
    However, the Nvidia® Jetson documents for building the Qt Libraries are limited. So, I write this post to show how to cross-compile shared libraries, and set the environment and set the QtCreator for Jetson TX2 Qt applications. The same procedures also works for TX1.

   Due to the application on an embedded system is only for a specific purpose, the GUI system is not necessary to be window form : the whole system is for an application only. Therefore, maybe it is necessary to build the Qt libraries supporting with the full-screen form.


零. Download Jetpack and use it to flash the TX2.
    The Jetpacks is here, you need to register a Nvidia account for the downloading. I use v. 3.3.
    There are some detail tutorials and videos for the Jetpack setting, like this or this or this.  I denote 2 precautions here:

   甲. Your host Linux must be installed with xterm, or the Jetpack will be hanging while it should start downloading (after Network layout page).

  乙. You could not run the Jetpack on LXDE environment, or the Jetpack program would be hanging in the component manager page.


After the flashing has been done, make sure your host is able to connect to the TX2. You could use ssh command in your host, to check is the connection workable or not.

ssh nvidia@your_tx2_ip
the password is also nvidia in default.

※ How to set TX2 UART could be found here.


一. Prepare the necessary libraries and headers on TX2.
   ※The works are all in the TX2.

  甲. install some packets to support the Qt build.
sudo apt-get install '.*libxcb.*' libxrender-dev libxi-dev libfontconfig1-dev
libudev-dev libxkbcommon-dev libxkbcommon-x11-dev

   乙. Extract the GLES and EGL headers, and put them under /usr/include.
  The commands are :
mkdir /home/nvidia/GLES
cd /home/nvidia/GLES
apt-get download libgles2-mesa-dev
ar x libgles2*.deb
tar -xvf data.tar.xz
mkdir /home/nvidia/EGL
cd /home/nvidia/EGL
apt-get download libegl1-mesa-dev
ar x libegl1*.deb
tar -xvf data.tar.xz
cd /home/nvidia/GLES/usr/include
sudo cp -r GLES2 GLES3 /usr/include
cd /home/nvidia/EGL/usr/include
sudo cp -r EGL KHR /usr/include

   丙. Create a symbolic link libGLESv2.so  :
sudo ln -s /usr/lib/aarch64-linux-gnu/tegra-egl/libGLESv2.so.2 \
 /usr/lib/aarch64-linux-gnu/libGLESv2.so

  丁. To leave the Nvidia-built Qt librares intact, we prepare a new directory to content the new build :
mkdir /usr/local/qt5
sudo chown nvidia /usr/local/qt5

install some packets to support the Qt build
sudo apt-get install '.*libxcb.*' \
 libx11-xcb-dev libxrender-dev libxi-dev \
 libfontconfig1-dev libudev-dev \
 libxkbcommon-dev libxkbcommon-x11-dev \
 libgles2-mesa-dev libegl1-mesa libegl1-mesa-dev \
 libglu1-mesa-dev libxrender-dev libxi-dev \
 libinput*  \
 mesa-utils  mesa-utils-extra libgles2-mesa-dev
 To here, the work on TX2 comes a stop.


二. Prepare the cross-compilation environment in the host.
       ※ The works are in the host machine.
   甲. Create a directory as the TX2's rootfs , and change your current directory to that, then copy the necessary folders from the TX2:
#cd your_tx2_rootfs_in_your_host
rsync -avz -e ssh nvidia@your_tx2_ip:/lib/aarch64-linux-gnu lib
rsync -avz -e ssh nvidia@your_tx2_ip:/usr/include usr
rsync -avz -e ssh nvidia@your_tx2_ip:/usr/lib usr
rsync -avz -e ssh nvidia@your_tx2_ip:/usr/aarch64-linux-gnu usr

   乙. Fix the necessary symbolic links :
ln -sf $PWD/lib/aarch64-linux-gnu/libz.so.1  $PWD/usr/lib/aarch64-linux-gnu/libz.so
ln -sf $PWD/lib/aarch64-linux-gnu/libm.so.6  $PWD/usr/lib/aarch64-linux-gnu/libm.so
ln -sf $PWD/lib/aarch64-linux-gnu/libdl.so.2 $PWD/usr/lib/aarch64-linux-gnu/libdl.so
ln -sf $PWD/lib/aarch64-linux-gnu/libpng12.so.0.54.0  $PWD/usr/lib/aarch64-linux-gnu/libpng.so
※ The libpng version or location may be changed with the Jetpack version, you should use find -name libpng* under folder TX2_rootfs_in_the_host_path to find out where it is by checking what soft-links to TX2_rootfs_in_the_host_path/usr/lib/aarch64-linux-gnu/libpng.so

  丙. Install the prerequisite packages.
sudo apt-get install -y 'libxcb.*' \
    libx11-xcb-dev libglu1-mesa-dev \
    libxrender-dev libxi-dev libinput* \
    mtdev* mesa-utils \
    mesa-utils-extra libgles2-mesa-dev
※ Some packets may be not necessary.

  丁. Prepare the toolchain:
sudo apt-get install g++-aarch64-linux-gnu
  and use aarch64-linux-gnu-g++ -v  to check the version, I use g++ 7.X;   
Linaro GCC 5.5 is here,  please download  the gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu.tar.xz file, and move it to an appropriate location, then extract it.
tar -xvf gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu.tar.xz
  I strongly recommend you should NOT use the aarch64-linux-gnu-g++ from apt-get, it will make the toolchain path setting complicated.

   
 戊. Download Qt everywhere.
    Qt everywhere is here. download a qt-everywhere tar ball, (I download qt-everywhere-src-5.13.0.tar.xz  qt-everywhere-src-5.15.2.tar.xz) and extract it.


三. Compilation Qt for TX2.

 甲.  There is no mkspecs file for TX2, we use the TX1's. But the TX1's mkspecs needs to be modified,  to avoid the compilation error.
※ The modification is necessary even your build is for TX1, as it is a bug of include path duplicate.

Comment out the line 29, in file where_the_qt_everywhere_extracted/qtbase/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf.
include(../common/linux_device_pre.conf)

QMAKE_INCDIR_POST += \
#    $$[QT_SYSROOT]/usr/include \
    $$[QT_SYSROOT]/usr/include/aarch64-linux-gnu

QMAKE_LIBDIR_POST += \

 乙 Configuration for build.

 Move your directory to the root of where_the_qt_everywhere_extracted, and configurate Qt as below :
./configure -shared -c++std c++14 \
 -opensource -release --confirm-license -no-pkg-config \
 -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=linaro_toolchain_folder_path/gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
 -sysroot TX2_rootfs_in_the_host_path \
 -nomake examples -nomake tests \
 -prefix /usr/local/qt5 \
 -extprefix qt_everywhere_path/JetsonTX2/qt5 \
 -hostprefix qt_everywhere_path/JetsonTX2/qt5-host \
 -skip webview -skip qtwebengine \ -opengl es2  


./configure -shared -c++std c++14 \
 -opensource -release --confirm-license \
 -no-pkg-config -device linux-jetson-tx1-g++ \
 -device-option CROSS_COMPILE=aarch64-linux-gnu- \
 -sysroot TX2_rootfs_in_the_host \
 -prefix /usr/local/qt5.15.2 \
 -extprefix TX2_qt5.15.2_libary_path_in_host \
 -hostprefix TX2_qt5.15.2_host_tool_path \
 -nomake examples -nomake tests \
 -opengl es2 -skip qtwebengine \
 -skip qtwebglplugin -skip qtwebsockets \
 -skip qtwebview -skip qtwinextras \
 -skip qtquick3d -skip qtquickcontrols \
 -skip qtquickcontrols2 -skip qtquicktimeline \
 -skip qtwayland -skip qtandroidextras \
 -skip qtdoc -skip translations \
 -skip qtdeclarative -skip qtpurchasing \
 -skip qtwebchannel -skip qtspeech \
 -skip qtlocation -skip qtremoteobjects \
 -skip qtscript -skip qtmacextras \
 -skip qtdoc -skip qtxmlpatterns
Below explain the arguments about the path.

-prefix: indicates where the built libraries will be placed in the TX2, my argument is /usr/local/qt5 /usr/local/qt5.15.2.

-extprefix :  It specifies where the built libraries will be placed in the host, I require the path is qt_everywhere_folder/JetsonTX2/qt5  /home/gaiger/JetsonTX2/qt5.15.2-device .

-hostprefix : the compilation tools path. The compilation tools would be imported into the QtCreator in the host. My argument is qt_everywhere_folder/JetsonTX2/qt5-host  /home/gaiger/JetsonTX2/qt5.15.2-host .

Denote : All the paths had better to be the absolute paths.
※ To save the TX2 disk space and build time, I skip the modules I will not use, you you check here to find out what modules are comprised of version 5.15.2.
 丙. build Qt libraries:
make -j4
make install

The build process costs a long time.
After "make install",  the Qt libraries for TX2 (qt_everywhere folder/JetsonTX2/qt5 TX2_qt5.15.2_libary_path_in_host) and the host tools(qt_everywhere folder/JetsonTX2/qt5-host TX2_qt5.15.2_host_tool_path) will be generated. Now we copy the libraries to the TX2 :
scp -r TX2_qt5.15.2_libary_folder nvidia@your_tx2_ip:/home/nvidia
# login into TX2, rename the folder as qt5.15.2
# and move it to be under /usr/local


四. Set Qt running environment on TX2.
  ※The works are all in the TX2.

The window mode, on XCB :

 Create a file /etc/profile.d/qt_xcb.sh in your TX2, the file contents :
export DISPLAY=:0.0
export QT_QPA_PLATFORM=xcb
export QT_QPA_FONTDIR=/usr/share/fonts/truetype
※ The variable DISPLAY may be :1.0

And bring the values into the current shell :
source /etc/profile.d/qt_xcb.sh

Test if the Qt application works or not :

 /usr/local/qt5/bin/qdbusviewer




The fullscreen mode,  on EGLFS:

Create a file /etc/profile.d/qt_eglfs.sh in your TX2, the file contents :
export DISPLAY=:0.0
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_PHYSICAL_WIDTH=360 export QT_QPA_EGLFS_PHYSICAL_HEIGHT=240 export QT_QPA_FONTDIR=/usr/share/fonts/truetype export XDG_RUNTIME_DIR=/tmp/runtime-nvidia 
※ The variable DISPLAY may be :1.0 
※We specify the Qt applications running on EGLFS, therefore, we need to set the EGLFS environment variables. The description of all EGLFS variables is here.

Create a file under the directory /etc/udev/rules.d to enable the access permission of /dev/input/eventX. The file name could be as your wish, mine is 00-event.rules. Its content is:
ACTION=="add", KERNEL=="event[0-8]*", MODE="0666"
Then , reboot your TX2.

/usr/local/qt5/bin/qtbusviewer would appear like below figure, that is fullscreen application.

Attention :: The application is full screen, so there is no max, min or close button.


五. Integrate the toolchain and host tools into QtCreator.
※ I assume your TX2 is online and be with your host at the same network segment.
 Open QtCreator,  go to Menu -> Tools -> Options, then the row Build and Run.

  甲. Page Qt Versions, to add the qmake file, which located in the host_tool_path/bin (qt_everywhere_folder/JetsonTX2/qt5-host TX2_qt5.15.2_host_tool_path, the argument of -hostprefix).


  乙. Page compilers, to add the linaro C++ compilers, the compiler you just use it to build the Qt libaries, aarch64-linux-gnu-g++. Besides, you might also need to add the C compiler.


  丙. Page debugger, add the linaro debugger, aarch64-linux-gnu-gdb, set Multiarch GDB as path /usr/bin/gdb-multiarch. (you may need to install it ahead via sudo apt-get install -y gdb-multiarch)



丁. In row devices, add a device for TX2, and set its ip, user id and password (default: nvidia/nvidia).


  戊. Back row Build & Run, in page Kits, add a kit for TX2, and  set the device, rootfs, compiler, Qt versions and so forth for TX2.

己. Qtcreator will overwrite the environment varibles whilt it is debugging, thus you need to set up the variable DISPLAY value at Project->Run->Run Environment, also please check the value of QT_QPA_PLATFORM.

 


庚.   Create a Qt application in the QtCreator, select the kit for TX2. While the project has been generated automatically, add the 2 lines in the .pro file :
target.path = /home/nvidia
INSTALLS += target
The lines could be placed anywhere of .pro.

  辛. Press Run or Start Debugging button, the application will run in the TX2, and the debugger should work perfectly. You must login the TX2 locally (use the TX2's screen/keyboard/mouse to login), or there would be no screen to show the GUI and leads to crash.



2016年8月29日 星期一

How to build Qt 4.8 Libraries for OS X: a Rough Note


     I have done the work for a long time, this is a rough note for the purpose: build Qt libraries on/for Mac.

    零.  You need to download the Old mac SDK. however, the download location in Apple's website is difficult to be found.  In here, I give a link where is straightforward to download the OS X SDKs.:
https://github.com/phracker/MacOSX-SDKs

After download the SDKs,  I put them in the root directory (/).

   一. Download  Qt 4.8 everywhere. The latest and final 4.8 version is 4.8.7, but for my case, I used 4.8.5 and 4.8.6. I do not sure if the 4.8.7 could pass the compilation though my configuration successfully.


 二.  My configuration applying Qt 4.8 + Mac is :


 ./configure   --prefix=$PWD/built \

                -platform macx-g++ \

                -sdk /Developer/SDKs/MacOSX10.5.sdk \

                -arch x86 \

                -no-avx -no-sse4.1 -no-sse4.2 \

                -opensource  -release \

                -no-stl -no-webkit -no-qt3support -no-phonon-backend -no-phonon

The parameters are:

-arch x86: the lbraries would be built in 32 bit.

 -platform macx-g++ : use gcc for this compilation, if you adopt clang ( macx-llvm), there would occur duplicate  function body error.

                
 -sdk /Developer/SDKs/MacOSX10.5.sdk :  Set OSX 10.5 SDK as target SDK.

  
-no-avx -no-sse4.1 -no-sse4.2

      disable some cpu instructions, to avoid crash in some old machines.




-no-stl -no-webkit -no-qt3support -no-phonon-backend -no-phonon

      Disable some middleware which is not be installed in this mach machinese, those middleware are like quicktime, mysqrl driver and so forth. If you do not add those parameters, it might incur compilation error for the necessary libraries could not been found.


2015年10月15日 星期四

Build Qt 5.5 in Windows: Use VS2010


     In this article, I would record how to build Qt 5.5. I use Qt 5.5.0 as my example here, but the procession mentioned below works for building Qt 5.5.1.

Step 0:
     Download Qt 5.5.0 and decompress it, I put that in folder C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0. Then set python develop environment(you could check my previous article to set it).

Step 1:
     As my previous article, the windows linking target should be changed from MSVCRT.lib to LIBCMT.lib, that makes the built Qt libraries be more portable.

   That's, change the lines in file C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\common\msvc-desktop.conf, from line number 32 :


QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd

After Qt 5.4.2, there is no configure.exe inside the everywhere package. But the configure.bat could not executed in windows.


   Modify the file C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\qtbase\configure.bat, which would generate configure.exe (about line 34):


@echo off
set QTSRC=%~dp0
set QTDIR=%CD%
rem if not exist %QTSRC%.gitignore goto sconf
echo Please wait while bootstrapping configure ...

for %%C in (cl.exe icl.exe g++.exe perl.exe) do set %%C=%%~$PATH:C

rem if "%perl.exe%" == "" (
rem     echo Perl not found in PATH. Aborting. >&2
rem     exit /b 1
rem )
if not exist mkspecs (
    md mkspecs
    if errorlevel 1 goto exit
)
rem perl %QTSRC%bin\syncqt.pl -minimal -module QtCore -outdir "%QTDIR%" %QTSRC%
rem if errorlevel 1 goto exit

if not exist tools\configure (
    md tools\configure
    if errorlevel 1 goto exit
)

Step 2:

Open the VS2010 prompt,  and configurate qt building parameters:


configure -platform  win32-msvc2010 -opensource -opengl desktop -release -nomake examples -no-angle -no-openssl -no-icu -skip translations -skip webkit  -no-openvg  -nomake tests -prefix C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\built

That is for my buiding, you may need to modify the line.

Step 3:

  Before type "nmake", the environment variables need to be set ( temporarily):


C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0>SET VISUALDIR=C:\PROGRA~1\MICROS~1.0
C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0:>SET PATH=%VISUALDIR%\VC\bin;%PATH%
C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0:>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
 And the " NMAKE : fatal error U1077: 'cd' : return code '0x2' " would occur less frequently.

Step 4:
   Type nmake to build the qt libraries in windows via VS 2010.

   If that occurs :

nmake fatal error u1077 return code 0x2

keep to rerun nmake.

Step 5.

  After the building has been done, back to the qt root folder, type "nmake install", to organize the libraries be portable form.

2015年4月10日 星期五

Build Qt 4.8.6 or 4.8.7 in windows by VS2005

NOTE : Qt 4.8.7 would be planned to be the last version of Qt 4. If your software be required porting to mobile devices deeply, or would be maintained for very long time in the future desktop platform, Qt 5 may be a better selection.

       In this article, I will explain how to build Qt 4.8 in windows by VS 2005. I take Qt 4.8.6 or 4.8.7 as the building target.


Step 0, Download the version 4.8.6 or 4.8.7, and uncompress the package. For me, the source code of Qt is in C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6 (or ...src-4.8.7)


Step 1(skipable): modify the file, qt-everywhere-opensource-src-4.8.6\mkspecs\win32-msvc2005, line 23:


QMAKE_CFLAGS_RELEASE    = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MDd




to

QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd



Step 2: Modify the file, qt-everywhere-opensource-src-4.8.6\src\gui\kernel\qclipboard_win.cpp, line 304 as:


static bool isProcessBeingDebugged(HWND hwnd)
{
#if defined(_MSC_VER) && _MSC_VER <= 1400 
    return false;
#else
    DWORD pid = 0;
    if (!GetWindowThreadProcessId(hwnd, &pid) || !pid)
        return false;
    const HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
    if (!processHandle)
       return false;
    BOOL debugged = FALSE;
    CheckRemoteDebuggerPresent(processHandle, &debugged);
    CloseHandle(processHandle);
    return debugged != FALSE;
#endif    
}



Step 3: Modify the file, qt-everywhere-opensource-src-4.8.6\src\3rdparty\webkit\Source\WebCore\platform\DefaultLocalizationStrategy.cpp,  line 237(4.8.6)
or  line 317 (4.8.7) As:

String DefaultLocalizationStrategy::contextMenuItemTagLookUpInDictionary(const String& selectedString)
{
#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
    UNUSED_PARAM(selectedString);
    return WEB_UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
#else
#if USE(CF)
    RetainPtr<CFStringRef> selectedCFString(AdoptCF, truncatedStringForLookupMenuItem(selectedString).createCFString());
    return formatLocalizedString(WEB_UI_STRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get());
#else
#if(0)
    return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
#else    
 return WEB_UI_STRING("Look Up <selection>", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
#endif
#endif
#endif
}

4.
   - α. Create a folder, which would contain the built files, for me, it be C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built. Copy mkspecs (folder of Step 1.) folder into this folder.

  - β. (※ for 4.8.7) , add this icon :
into the folder : C:\Lib\Qt\qt-everywhere-opensource-src-4.8.7\src\3rdparty\webkit\Source\WebCore\inspector\front-end\Image. DO NOT change the file name or format, or it would cause compiling fail.


5. open a VS2005 command line prompt to configuration Qt.



The configure arguments, for me , I use

configure.exe -prefix C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built -platform win32-msvc2005 -shared -debug-and-release -nomake demos -nomake examples -fast -mp -opensource -stl 

where the path after -prefix should be the same one which be mentioned at Step 4.( the one would contain built files.) .
(for me,
C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built
for 4.8.6

C:\Lib\Qt\qt-everywhere-opensource-src-4.8.7\built
,for 4.8.7.)

Press enter key then y, then the nmake file would be generated.


6. After the gernerating has been done, type "nmake" and press enter, wait the binaries has been generated.The building of code cast long time, which depends on how much money you put in your computer.



7. type nmake install, to organize the built folder. DO NOT copy directly "include" folder which lies in the qt source root folder to your destination. The original include folder depends on source code heavily, it is not for working with built libraries.
  After nmake install finish, the librarie, include files and binaries tools are very portable, you could carry them to another windows computer for development usage, and the package would works well.

2015年3月2日 星期一

Build Qt 5.4 in Windows: Use VS2010


In this post , I note how to build qt 5.4 in windows.

I had tried lots effort to use VS 2005 as my compiler to pass the building of Qt 5.4

But I did not pass it.


In here , I used the compiler VS2010.


Step 0.

      Download Qt 5.4.0 sourcecode from here( or 5.4.1), or from the official website ( I recommend you download the .zip file, the others may be collapse in uncompression) (the uncompressed soource code would greater than 4GB, make sure your compression program support that).  Then uncompress this package. For me , the qt folder is at C:\Lib\Qt\qt-everywhere-opensource-src-5.4.0.
      Download the python from here, and install it. Set the python path in the windows environment, make sure you could call python compiler in command line.

Step 1.

   open the  file qt-everywhere-opensource-src-5.4.0\qtbase\mkspecs\win32-msvc2010\qmake.conf, change text beginning from 28th line 


QMAKE_CFLAGS_RELEASE    = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MDd

to

QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd

Step 2.

  open a  VS 2010 command prompt , it is local in programs -> VS2010-> Visual Studio Tool->

 If you use Visual Studio Command Prompt(2010), the building target is 32 bit; otherwise, Visual Studio x64 Win64 Command Prompt(2010) is for 64 bit.

For me, I set for 32 bit.

Move your working folder in the prompt  to Qt folder.


3. for my configure, i use


configure -platform  win32-msvc2010 -opensource -opengl desktop -release -nomake examples -no-angle -no-openssl -no-icu -skip webkit  -no-openvg  -nomake tests -prefix C:\Lib\Qt\qt-everywhere-opensource-src-5.4.1\built
 

(you should use configure -h at first, to check what are supported parameters. the help note is long, you could use the command "configure -h > help.txt" to save the note as a file.)
(I skip debug, test and example to fast the building)
and type nmake to build the Qt libraries.


4. if you encounter:

YarrInterpreter.obj : error LNK2019: unresolved external symbol "struct JSC::Yar
r::CharacterClass * __cdecl JSC::Yarr::newlineCreate(void)" (?newlineCreate@Yarr
@JSC@@YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Yar
r::CharacterClass * __thiscall JSC::Yarr::YarrPattern::newlineCharacterClass(voi
d)" (?newlineCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ)
YarrPattern.obj : error LNK2001: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::newlineCreate(void)" (?newlineCreate@Yarr@JSC
@@YAPAUCharacterClass@12@XZ)
YarrInterpreter.obj : error LNK2019: unresolved external symbol "struct JSC::Yar
r::CharacterClass * __cdecl JSC::Yarr::wordcharCreate(void)" (?wordcharCreate@Ya
rr@JSC@@YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Y
arr::CharacterClass * __thiscall JSC::Yarr::YarrPattern::wordcharCharacterClass(
void)" (?wordcharCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ
)
YarrPattern.obj : error LNK2001: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::wordcharCreate(void)" (?wordcharCreate@Yarr@J
SC@@YAPAUCharacterClass@12@XZ)
YarrPattern.obj : error LNK2019: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::digitsCreate(void)" (?digitsCreate@Yarr@JSC@@
YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Yarr::Cha
racterClass * __thiscall JSC::Yarr::YarrPattern::digitsCharacterClass(void)" (?d
igitsCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ)
YarrPattern.obj : error LNK2019: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::spacesCreate(void)" (?spacesCreate@Yarr@JSC@@
YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Yarr::Cha
racterClass * __thiscall JSC::Yarr::YarrPattern::spacesCharacterClass(void)" (?s
pacesCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ)
YarrPattern.obj : error LNK2019: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::nondigitsCreate(void)" (?nondigitsCreate@Yarr
@JSC@@YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Yar
r::CharacterClass * __thiscall JSC::Yarr::YarrPattern::nondigitsCharacterClass(v
oid)" (?nondigitsCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ
)
YarrPattern.obj : error LNK2019: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::nonspacesCreate(void)" (?nonspacesCreate@Yarr
@JSC@@YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC::Yar
r::CharacterClass * __thiscall JSC::Yarr::YarrPattern::nonspacesCharacterClass(v
oid)" (?nonspacesCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterClass@23@XZ
)
YarrPattern.obj : error LNK2019: unresolved external symbol "struct JSC::Yarr::C
haracterClass * __cdecl JSC::Yarr::nonwordcharCreate(void)" (?nonwordcharCreate@
Yarr@JSC@@YAPAUCharacterClass@12@XZ) referenced in function "public: struct JSC:
:Yarr::CharacterClass * __thiscall JSC::Yarr::YarrPattern::nonwordcharCharacterC
lass(void)" (?nonwordcharCharacterClass@YarrPattern@Yarr@JSC@@QAEPAUCharacterCla
ss@23@XZ)
..\..\lib\Qt5Qmld.dll : fatal error LNK1120: 7 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\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.

C:\Lib\Qt\qt-everywhere-opensource-src-5.4.0>



Check the file qt-everywhere-opensource-src-5.4.0\qtdeclarative\src\qml\RegExpJitTables.h is empty file or not. if it is empty, delete it. It is you do not installing python yet. After installing and setting python environment, re-open the VS prompt and type nmake.


5. If you encounter uic.exe crashed, you could just type nmake again and and again, until your building has been done completely.

6. After the Building has been done, you should be under the folder

qt-everywhere-opensource-src-5.4.0\qtbase. DO NOT go back qt root folder, just type "nmake install", the script would organize libraries and headers to be a portable package (for me it is under qt-everywhere-opensource-src-5.4.0\built).