Configure Qt development on Windows + Mac + linux: Difference between revisions

From Bitpost wiki
No edit summary
No edit summary
 
(47 intermediate revisions by the same user not shown)
Line 1: Line 1:
These build instructions includes support for phonon (mp3 and video playback, etc.) and opensssl (for https support etc.) - because I needed them!  And because they are a bit of a pain to set up. 
Start with Qt Creator on Mac or linux for the smoothest experience...
Start with Qt Creator on Mac or linux for the smoothest experience...


Line 9: Line 11:


== Mac OS X ==
== Mac OS X ==
To set up for Mac development...
To set up for Mac development (I'm using Lion)...
* download Xcode (the primary Apple IDE)
* in Xcode: Preferences --> Downloads With "Components" selected, you will see a list of downloadable components.  Look for Command Line Tools, and click on install. You will be prompted for your Apple Developer userid and password. After successfully authenticating, the command line tools component downloads and installs a bunch of goodness, including gcc.
* download the Mac Qt environment, including Qt Creator
* download the Mac Qt environment, including Qt Creator
* install git and pull down the code
* install git and pull down the code
Line 15: Line 19:


== Windoze ==
== Windoze ==
To set up for Windows development with Visual Studio (PAIN in the ASS, only do this once central repo and another platform are up and working)..
This gives a Windoze static build of Qt 5.3.0, yay!
* install Visual Studio + Add-in
 
* set up git option 1: use eclipse + egit (easy but no scripting, ugg)
* Get latest OpenSSL source from [http://www.openssl.org/source/ here], unzip to C:\openssl-1.0.1g.
** install eclipse CDT and egit
* Get the latest Qt source, unzip to C:\Qt\qt-everywhere-opensource-src-5.3.0.
** start eclipse and select File->Import, select Projects from Git, hit Clone, set up remote repo and hit next, CHANGE crappy default location to C:\Michael's Data\development\thedigitalage\hangthedj.
* Get jom from here if you want a faster build: [http://qt-project.org/wiki/jom jom]
** repeat for other needed projects (Reusable, etc)
* Open a VS Developer Prompt and build OpenSSL:
* set up git option 2: the nightmare that is msysgit (pain, but scriptable)
cd C:\openssl-1.0.1g
** install the "official" Git for Windows
perl Configure VC-WIN32 no-asm --prefix=C:\openssl-1.0.1g\mdm
*** tie it to plink, not openssl, so you can use putty's pageant.exe to serve up your ssl key
ms\do_ms
*** make it accessible from the Windows command prompt
nmake -f ms\nt.mak
** set up the notepad++ editor to work with git
nmake -f ms\nt.mak install
** set up a batch file to run notepad++; see hangthedj/windows_scripts/npp.bat; it needs to be in a path without spaces
rem And bc setting up paths to openssl is troublesome...
** configure git to use npp: git config --global core.editor C:/npp.bat (be careful, windows 7 may give you fits about putting stuff in root c:\)
xcopy /S C:\openssl-1.0.1g\mdm\include\openssl\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\include\openssl\
** configure git with your u/p: git config --global user.name "Your Name" && git config --global user.email you@example.com
  xcopy /S C:\openssl-1.0.1g\mdm\lib\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\lib\
** set up a script that calls git, similar to how you would do it in linux; see hangthedj/windows_scripts/hcm.bat and huc.bat
xcopy /S C:\openssl-1.0.1g\mdm\bin\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\bin\
* now we have to build Qt libraries since for some reason they haven't released a 2010 build yet (wtf!)
* Patch the VS 2013 mkspec to make it build static:
* Get a copy of the source for your cross-platform Qt app, ideally already tested and working on another platform, on your Windows box.  Use git, whee!
notepad C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\mkspecs\win32-msvc2013\qmake.conf
* Install Visual Studio 2010.
  # MDM was haere
* Install [http://support.microsoft.com/kb/2280741 this patch] to fix support for 64-bit apps.
  #QMAKE_CFLAGS_RELEASE    = -O2 -MD
* Install the DirectX SDK
#QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
* Install OpenSSL
#QMAKE_CFLAGS_DEBUG      = -Zi -MDd
** [http://www.slproweb.com/products/Win32OpenSSL.html here] is a good place to get a prebuilt binary
  QMAKE_CFLAGS_RELEASE    = -O2 -MT
** NOTE that you should first install the Visual C++ 2008 Redistributable if you want to use its installer.
  QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
** copy libeay32.dll and ssleay32.dll from the \bin folder to your project's Debug and Release directories - you will need to ship these dll's with your product.
  QMAKE_CFLAGS_DEBUG      = -Zi -MTd
* Download and unzip the [http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.2.zip Qt opensource code] to [c:\\Qt\4.7.2] (or whatever version you get).
* Open a "Visual Studio command prompt" and compile Qt as follows. Note that for phonon, <strong>you MUST compile Qt as shared not static.</strong>  You might be able to switch back to static after you build the phonon dll's, but I didn't try that.  Also, see C:\Michael's Data\development\thedigitalage\hangthedj\windows_scripts.
<pre>nmake confclean
nmake clean
echo yes &#62yes.txt
configure -debug-and-release -opensource -shared -nomake demos -nomake examples -no-qt3support -qt-sql-sqlite -phonon -phonon-backend -no-webkit -no-script -openssl -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib -platform win32-msvc2010 &#60yes.txt
nmake</pre>
* Wait a while for that to finish...  Definitely use the above settings to skip the demos and examples if you want to save time.
* Because we built shared, you should now have Qt dll's (including phonon) in [c:\\Qt\4.7.2\bin]Copy the debug versions of dll's (*d4.dll) into the directory with your debug exe, and repeat with (*4.dll) for release. Again, you will need to ship these dll's with your product.
* Install the [http://qt.nokia.com/downloads/visual-studio-add-in Qt Visual Studio Add-In] (this version works with Visual Studio 2010)
* Open Visual Studio. You should see a nice new Qt menu item sandwiched between View and Project. Select [Qt->Qt Options], hit Add, and browse to the source directory.  With any luck Qt will enable the OK button for ya...
* Select [Qt->Open Qt Project (.pro)], browse to your project, and load it up.  Visual Studio will spend a few minutes getting comfortable with all the Qt headers, and then you should have a *.sln file you can work with.
* Open the project settings and add the Reusable code path to your include paths.
* You should be able to compile and debug just like you do with all your skanky (j/k) Windoze code. Yay!


* Compile Qt statically in a VS Developer Prompt:
cd C:\Qt\qt-everywhere-opensource-src-5.3.0
set QMAKESPEC=win32-msvc2013
set PATH=%CD%\bin;%PATH%
set PATH=%CD%\qtbase\bin;%PATH%
set PATH=%CD%\qtrepotools\bin;%PATH%
set PATH=%CD%\gnuwin32\bin;%PATH%
set QTDIR=%CD%\qtbase
set QT_QPA_PLATFORM_PLUGIN_PATH=%CD%\qtbase\plugins\platforms
rem configure says "To reconfigure, run nmake confclean and configure."
rem but it seems it is [nmake clean]
rem NOTE use this for 64-bit: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64


<pre> ------------------------------------
Note that there's some weird shit going on with OpenGL vs ANGLE and two releases of Qt and it's all a big hairy fluxball... taking out [-opengl] for the moment...
TO REGENERATE VISUAL STUDIO SOLUTION
# configure -opengl desktop -confirm-license -qmake -opensource OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32" -debug-and-release -platform win32-msvc2013 -static -no-crt -nomake examples -openssl-linked -I C:\openssl-1.0.1g\mdm\include -L C:\openssl-1.0.1g\mdm\lib -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" >configure_output.txt
------------------------------------
configure -confirm-license -qmake -opensource OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32" -debug-and-release -platform win32-msvc2013 -static -no-crt -nomake examples -openssl-linked -I C:\openssl-1.0.1g\mdm\include -L C:\openssl-1.0.1g\mdm\lib -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" >configure_output.txt
This must be done when the project changes (files added etc)
# nmake or jom will do, jom is faster
Run Visual Studio, but CLOSE THE CURRENT SOLUTION FIRST
jom >jom_output.txt
select [Qt->Open Qt Project File...]
open the same project from the same location
it will ask you if you want to regenerate, say yes
it will ask a couple more times if you want to overwrite
1) [OK] to saving current changes
2) [Discard] changes and overwrite with new ones from file
------------------------------------


</pre>
* Create a new "kit" with the newly built Qt!

Latest revision as of 21:17, 3 June 2014

These build instructions includes support for phonon (mp3 and video playback, etc.) and opensssl (for https support etc.) - because I needed them! And because they are a bit of a pain to set up.

Start with Qt Creator on Mac or linux for the smoothest experience...

Linux

To set up for linux development..

  • install Qt and Qt Creator using your favorite distro's package manager
  • dump in some sample code and get it compiling and running
  • install git using your package manager
  • set up a central git repo and push your sample code to it

Mac OS X

To set up for Mac development (I'm using Lion)...

  • download Xcode (the primary Apple IDE)
  • in Xcode: Preferences --> Downloads With "Components" selected, you will see a list of downloadable components. Look for Command Line Tools, and click on install. You will be prompted for your Apple Developer userid and password. After successfully authenticating, the command line tools component downloads and installs a bunch of goodness, including gcc.
  • download the Mac Qt environment, including Qt Creator
  • install git and pull down the code
  • run Qt Creator and compile and run

Windoze

This gives a Windoze static build of Qt 5.3.0, yay!

  • Get latest OpenSSL source from here, unzip to C:\openssl-1.0.1g.
  • Get the latest Qt source, unzip to C:\Qt\qt-everywhere-opensource-src-5.3.0.
  • Get jom from here if you want a faster build: jom
  • Open a VS Developer Prompt and build OpenSSL:
cd C:\openssl-1.0.1g
perl Configure VC-WIN32 no-asm --prefix=C:\openssl-1.0.1g\mdm
ms\do_ms
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
rem And bc setting up paths to openssl is troublesome...
xcopy /S C:\openssl-1.0.1g\mdm\include\openssl\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\include\openssl\
xcopy /S C:\openssl-1.0.1g\mdm\lib\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\lib\
xcopy /S C:\openssl-1.0.1g\mdm\bin\* C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\bin\
  • Patch the VS 2013 mkspec to make it build static:
notepad C:\Qt\qt-everywhere-opensource-src-5.3.0\qtbase\mkspecs\win32-msvc2013\qmake.conf
# MDM was haere
#QMAKE_CFLAGS_RELEASE    = -O2 -MD
#QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
#QMAKE_CFLAGS_DEBUG      = -Zi -MDd
QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd
  • Compile Qt statically in a VS Developer Prompt:
cd C:\Qt\qt-everywhere-opensource-src-5.3.0
set QMAKESPEC=win32-msvc2013
set PATH=%CD%\bin;%PATH%
set PATH=%CD%\qtbase\bin;%PATH%
set PATH=%CD%\qtrepotools\bin;%PATH%
set PATH=%CD%\gnuwin32\bin;%PATH%
set QTDIR=%CD%\qtbase
set QT_QPA_PLATFORM_PLUGIN_PATH=%CD%\qtbase\plugins\platforms

rem configure says "To reconfigure, run nmake confclean and configure."
rem but it seems it is [nmake clean]

rem NOTE use this for 64-bit: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64

Note that there's some weird shit going on with OpenGL vs ANGLE and two releases of Qt and it's all a big hairy fluxball... taking out [-opengl] for the moment...

# configure -opengl desktop -confirm-license -qmake -opensource OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32" -debug-and-release -platform win32-msvc2013 -static -no-crt -nomake examples -openssl-linked -I C:\openssl-1.0.1g\mdm\include -L C:\openssl-1.0.1g\mdm\lib -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" >configure_output.txt
configure -confirm-license -qmake -opensource OPENSSL_LIBS="-llibeay32 -lssleay32 -lgdi32" -debug-and-release -platform win32-msvc2013 -static -no-crt -nomake examples -openssl-linked -I C:\openssl-1.0.1g\mdm\include -L C:\openssl-1.0.1g\mdm\lib -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" >configure_output.txt
# nmake or jom will do, jom is faster
jom >jom_output.txt
  • Create a new "kit" with the newly built Qt!