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

From Bitpost wiki
Line 59: Line 59:
* Muck with C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release\mkspecs\win32-msvc2010\qmake.conf, setting groovy compiler options
* Muck with C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release\mkspecs\win32-msvc2010\qmake.conf, setting groovy compiler options
** Make sure you set QMAKE_CFLAGS_RELEASE to use [-MT] - why does EVERYONE ELSE GET THIS WRONG?  DO NOT USE [-MD]!  DAMMIT!  What a colossal waste of time.  I used [-O2 -MT -GL].
** Make sure you set QMAKE_CFLAGS_RELEASE to use [-MT] - why does EVERYONE ELSE GET THIS WRONG?  DO NOT USE [-MD]!  DAMMIT!  What a colossal waste of time.  I used [-O2 -MT -GL].
<pre>cd C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release
* Compile:<pre>cd C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release
nmake confclean
nmake confclean
nmake clean
nmake clean

Revision as of 01:43, 28 September 2011

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...

  • download the Mac Qt environment, including Qt Creator
  • install git and pull down the code
  • run Qt Creator and compile and run

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)..

  • install Visual Studio 2010
  • install the Qt Visual Studio Add-in from here
  • set up git option 1: use eclipse + egit (easy but no scripting, ugg)
    • install eclipse CDT and egit
    • 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.
    • repeat for other needed projects (Reusable, etc)
  • set up git option 2: the nightmare that is msysgit (pain to set up, but scriptable and worth it)
    • install the "official" Git for Windows
      • tie it to plink, not openssl, so you can use putty's pageant.exe to serve up your ssh key
      • make it accessible from the Windows command prompt
    • set up the notepad++ editor to work with git
      • set up a batch file to run notepad++; see hangthedj/windows_scripts/npp.bat; it needs to be in a path without spaces
      • 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:\)
    • configure git with your u/p: git config --global user.name "Your Name" && git config --global user.email you@example.com
    • 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
  • now we have to build Qt libraries since for some reason they haven't released a 2010 build yet (wtf!)
  • 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!
  • Install Visual Studio 2010.
  • Install this patch to fix support for 64-bit apps.
  • Install the DirectX SDK
  • Install OpenSSL
    • prebuilt Windows binaries are here; Note that the "light" installer doesn't have the include files you'll need - get the full version. You can ignore the installer's VS2008 redistributable warnings.
    • 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.
  • Download and unzip the 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, you MUST compile Qt as shared not static; see hangthedj\windows_scripts\mdm_build.bat.
nmake confclean
nmake clean
echo yes >yes.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 <yes.txt
nmake
  • 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. See hangthedj/windows_scripts/
  • Install the 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!
  • And now I'm going to attempt a static build with this...
  • Drop in a new copy of the Qt source, say in C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release
  • Muck with C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release\mkspecs\win32-msvc2010\qmake.conf, setting groovy compiler options
    • Make sure you set QMAKE_CFLAGS_RELEASE to use [-MT] - why does EVERYONE ELSE GET THIS WRONG? DO NOT USE [-MD]! DAMMIT! What a colossal waste of time. I used [-O2 -MT -GL].
  • Compile:
    cd C:\Qt\qt-everywhere-opensource-src-4.7.4-static-release

nmake confclean nmake clean echo yes >yes.txt configure -release -opensource -static -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 <yes.txt nmake sub-src

  • Set up the project as static
    • Project->Properties->C++->Code Generation->Runtime Library->Pick non-dll libs (/MT and /MTd)
    • Project->Properties->Linker->Input->Ignore All Default Libraries-> Yes
	------------------------------------
	TO REGENERATE VISUAL STUDIO SOLUTION
	------------------------------------
	This must be done when the project changes (files added etc)
	Run Visual Studio, but CLOSE THE CURRENT SOLUTION FIRST
	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
	------------------------------------