티스토리 뷰
Writing Open Source Programs on Windows with Qt/MinGW
Table Of Contents
- Writing Open Source Programs on Windows with Qt/MinGW
- What is this for?
- What is Unix, MinGW, Open Source...?
- What is the MinGW shell?
- So what programs should be installed?
- What other recommended programs?
- What other optional programs?
- Installing
- Quick start
- Step 0 Know MinGW Quirks
- How does this affect me?
- Step 1 Set Up
- Step 2 MinGW Installer
- Step 2 Alternative - Manually Download and Install MingW
- Step 3 Gnu Debugger
- Step 4 Optional- MinGW Shell
- Step 5 Optional - SQLite
- Step 6 Qt 4 from Trolltech
- Step 7 Optional - Dev Toolkit
- Step 8 Recommended - Eclipse and CDT
- What is this for?
What is this for?
If you want to write Open Source computer programs under a Unix-like environment on Windows using Qt 4.0 from Trolltech, and MinGW toolchain.
Optionally you may want to have an Integrated Development Environment - installing Eclipse is discussed below
What is Unix, MinGW, Open Source...?
When Unix is written here, really it means one of Linux, or FreeBSD, or any of the other BSDs, or even Solaris, or Darwin. Unix has come to mean any of a number of operating systems which work like the old Unix used to. In Unix when you want a listing of the files, you type ls at a terminal window (instead of dir like in windows).
The Gnu project has written a lot of software which works like Unix, and which gives much of its power. In particular they've written a good compiler called GCC.
MinGW is a minimalist Gnu toolchain (including the GCC compiler and associated bits and pieces) built for Windows desktops. Qt now supports MinGW and comes with MinGW build files.
You use the MinGW toolchain to take computer program source files that you write with an editor, and turn them into binary computer programs such as games that you can run.
Open Source is when your source files (and usually downloadable compiled binaries of your programs as well) are made available so that others can use them as they wish. Open Source programs are made available under licenses such as the Gnu Public License - read that license to understand what rights and conditions the GPL imposes.
The opposite of Open Source is when programs are proprietary and the source files are not made available. This means the users of the programs cannot make changes to the program (or at least not legally).
When using the Qt Open Source edition, any software you write must also be Open Source, and must be released under the GPL (or an equivalent license).
What is the MinGW shell?
The MinGW folks have also forked a minimal environment from the Cygwin project to get a Unix-like environment. This is handy for getting access to CVS (for downloading stuff from source control when jointly working on programming projects) and other powerful unix tools.
This environment is the MinGW shell, also called "Minimal System".
So what programs should be installed?
- MinGW toolchain - for compiling programs
- Gnu Win32 programs - full Unix tools for w32
- Qt for Windows - open source version
What other recommended programs?
- Eclipse & CDT - integrated development environment for C++
What other optional programs?
- MinGW shell - for running Unix commands
- MinGW dev toolkit - for perl scripting
- SQLite - embedded database - very handy
If you have the time and the disk space I recommend installing all of these.
In any case, follow the order below, and skip the optional steps if you want to save time and space.
Installing
Quick start
- If you're not interested in customizing or understanding the MinGW install...
-
Download and install the Qt 4.0 Open Source package installer
- Check the option to download and install MinGW
- Check the option to install the MinGW sources
-
Now Steps 2 below can be omitted
- You still need to follow through Step 6 from the line Compile Qt
Step 0 Know MinGW Quirks
- Very important MinGW programs have some special magic to map windows onto the unix-style paths
-
for example msys shell converts C:\temp\ to /c/temp/
- back-slashes are converted to forward slashes
- drives are "mounted" at the root directory "/"
- other directories are also mounted under the "/" heierarchy
-
mingw special binaries are in C:\msys\1.0\bin
- this directory is mapped to /bin and /usr/bin (type "mount" to see this)
- only binaries created especially for mingw should be placed here
-
when you see a path like /mingw/bin/mingw32-make it only works under the msys shell
- this path will not work under the Windows cmd.exe shell
So the directory layout is:
- Gnu Win32 programs (like tar) are installed
C:\Program Files\GnuWin32\bin
- Non-special mingw programs are under
C:\mingw\bin\
- Programs especially for MinGW are under
C:\msys\1.0\bin
How does this affect me?
- Follow this How To carefully to avoid problems with paths
- If you see errors like somePathsomeFile where the slashes are missing from the path and file name, and its all concatenated together, its probably due to MinGW
- Provide full path names in configs
- Remove cygpath if its installed
- If all else fails try removing C:\msys\1.0\bin\sh.exe (this may kill msys for you)
Step 1 Set Up
-
Log out of your normal user account, and into your Windows box Administrator account
- If you do your development as an Administrator you deserve everything you get - most likely total destruction of your machine
- Once this setup is complete, you'll return to using the normal user account for development
- Under Visual Studio this often does not work, so many folks develop with Admin privileges - arent you glad you're not using VS?
-
Install some handy Gnu Win32 tools - use the Binaries "Setup" link for both of these
-
Point your Windows path to include these tools
- Right click "My Computer" on the desktop, and click "System Properties"
- From the dialog that opens, select the "Advanced" tab, and click the "Environment Variables" button
- In the lower "System Variables" frame select "path" and click edit
- Add to the end of the path in the text box ";C:\Program Files\GnuWin32\bin"
-
Test you can access them
- Start a windows shell - eg Start->run->cmd.exe
- Type "tar --version" - you should see
tar (GNU tar) 1.13
followed by some other info - If you dont get this, and tar installed OK, check the path (previous step) and check that some other "tar" program is not higher in your path
- Its not recommended at all to try to use GUI windows decompressors and archive managers like WinRAR or Winzip. That way lies only pain and anguish. It is far too easy to install MinGW into the wrong directory using those.
Step 2 MinGW Installer
- Use the latest version available - at this time MinGW-5.0.0.exe
- Double-click the installer to start, and accept the license
- Select "download and install"
- Choose your closest mirror, and choose "current"
- Select GCC core, G++ and make (the others are not required)
- Optional (useful for debugging) check the option to install sources
- Allow the installer to complete before continuing
Step 2 Alternative - Manually Download and Install MingW
-
If you dont want to use the MinGW-5.0 installer for some reason, you can get the components and install them manually
- If you know a particular package is broken or incompatible you might do this
- Otherwise use the automatic installer, that is what its there for.
-
Download and install mingw32-make
- Select MinGW's latest stable Make - mingw32-make - I used mingw32-make-3.80.0-3
-
Download it to the desktop and double-click to install
- accept the default install location of C:\mingw
- click "OK" when prompted to create C:\mingw
-
- Select the MinGW components you need
-
- binutils-2.15.91-20040904-1.tar.gz
- gcc-core-3.4.2-20040916-1.tar.gz
- gcc-g++-3.4.2-20040916-1.tar.gz
- mingw-runtime-3.9.tar.gz
- mingw-utils-0.3.tar.gz
- w32api-3.5.tar.gz
-
- The source files are also handy when debugging
-
- mingw-runtime-src-3.9.tar.gz
- w32api-src-3.5.tar.gz
-
Download the Current versions of these from the MinGW site
- Current versions may have later numbers than I have listed above.
- Make sure you get versions which are binary and current
- Once all are downloaded, copy them to the C:\MinGW\ folder
-
Install the toolchain components using tar and gunzip
- Open a windows command shell - eg Start->run: cmd.exe
cd C:\MinGW\
gunzip *.gz
FOR %f IN (*.tar.gz) DO tar xf %f
-
- If you downloaded the source tar files as well, rename their dirs
-
mv w32api-3.5 w32api
mv runtime-3.9 runtime
- Note that the "fork" command and "gunzip -c foo.tar.gz | tar xf -" do not work on windows
Step 3 Gnu Debugger
- Select the latest GDB - I used gdb-6.3.2.exe
-
Download it to the desktop and double-click to install
- type an install location of
C:\MinGW
- type an install location of
Step 4 Optional- MinGW Shell
- Select MinGW's latest stable Minimal System - MSYS - I used MSYS-1.0.10 from the Australian mirror
- Download to the desktop, and install by double clicking on the and running through the normal windows install
-
When the post install script runs
- proceed with the script by answering to the first question "y"
- answer "y" to if you have MinGW installed
- type C:/MinGW/ to the question of where MinGW is installed
- press enter to the remaining prompts to finish the script
- Once the script has finished, place a shortcut to the msys shell in the quicklaunch bar (just to the right of the "start" menu) by dragging the desktop icon there. The shell is used a lot and this allows quick and easy starting of new shells.
- Now run the msys shell clicking the "M" quicklaunch icon (you can also select it from start->programs->mingw->Msys->msys)
-
When the post install script ran it should have set up a mount point for mingw on <pre>/mingw</pre>
- check by typing "mount" and look for a line like:
C:\MinGW on /mingw type user (binmode)
- if the line is not there, that means the post install script is (still) broken
- fix it by copying the sample fstab into place:
- check by typing "mount" and look for a line like:
Administrator@WINBOX ~ $ cp /etc/fstab.sample /etc/fstab
Step 5 Optional - SQLite
- SQLite is a powerful embedded database. It cuts lots of corners so as to make it quick and simple to develop standalone apps with a database backend
-
Download the Version 3 .tar.gz Source Code package from SQLite.org
- I used sqlite-3.2.8.tar.gz
- Save the package to C:\MinGW
- Open the MinGW shell
- Do the following (substitute in the version for whatever package you downloaded):
cd /mingw gunzip sqlite-3.2.8.tar.gz tar xf sqlite-3.2.8.tar cd sqlite-3.2.8 configure --prefix=/mingw make make install
Step 6 Qt 4 from Trolltech
- In the following substitute for qt-win-opensource-src-4.1.0 whatever package name you download
- Download the Qt 4.x Open Source package
-
Unzip it to C:\Qt
- When you use winzip you'll wind up with a sub-folder qt-win-opensource-src-4.1.0
-
Rename the Qt folder to 4.1.0
- Open a command shell: Start->run:
cmd
- Do:
- Open a command shell: Start->run:
cd C:\Qt rename qt-win-opensource-src-4.1.0 4.1.0
- Compile Qt (only include the -qt-sql-sqlite on the configure line if you installed SQLite above):
set QTDIR=C:\Qt\4.1.0 set PATH=%QTDIR%\bin;C:\MinGW\bin;%PATH% set QMAKESPEC=win32-g++ configure -qt-gif -qt-libpng -qt-sql-sqlite -dont-process cd src qmake -makefile src.pro mingw32-make cd ..\tools qmake -makefile tools.pro mingw32-make
- Note - the
-dont-process
was necessary for me. Letting qmake go through and build the entire tree resulted in it consuming all memory and grinding to a halt (Athlon 1400, 128MB RAM). - Fix the CompletelyEvilWinMain issue
-
- Add Qt to the system path
-
- Right click "My Computer" on the desktop, and click "System Properties"
- From the dialog that opens, select the "Advanced" tab, and click the "Environment Variables" button
- In the lower "System Variables" frame select "path" and click edit
- Add to the end of the path in the text box ";C:\Qt\4.1.0\bin"
-
Create two new Qt environment variables
- In the lower "System Variables" frame click the "New..." button
- Enter: varable name QTDIR, variable value "C:\Qt\4.1.0\bin"
- Click OK
- In the lower "System Variables" frame click the "New..." button
- Enter: varable name QMAKESPEC, variable value win32-g++
- Click OK
-
Create a link to the Qt executables
- Navigate to \C:\Qt\qt-win-opensource-src-4.1.0\bin via "My Computer"
- Right click on first designer.exe and select create shortcut
- Right click on first assistant.exe and select create shortcut
- From a cmd.exe window type
mkdir "C:\Documents and Settings\All Users\Start Menu\Programs\Qt" copy "C:\Qt\qt-win-opensource-src-4.1.0\bin\*.lnk C:\Documents and Settings\All Users\Qt"
Step 7 Optional - Dev Toolkit
- Select MinGW's latest stable Dev Toolkit - msysDTK - I used msysDTK-1.0.1 from the Australian mirror
-
Download to the desktop, and install by double clicking on the and running through the normal windows install,
- accept the default install location of <pre>C:\msys\1.0</pre>
Step 8 Recommended - Eclipse and CDT
-
Download all the required software
-
- You might already have a JRE installed
- In a cmd shell type
javaw foo
and if there is a message "could not load class" or similar, JRE is installed. - Use the Sun one if possible
- Download eclipse from the eclipse website
- Download the C/C++ Development Toolkit
-
- Install Java first by double-clicking the installer package
-
Install Eclipse by unzipping the (eg) eclipse-SDK-3.1.1-win32.zip files into C:\
- This should create a directory C:\eclipse
- Navigate to that directory in File Manager
- Right click on C:\eclipse\eclipse.exe and choose "create shortcut"
- Copy the shortcut to
C:\Documents and Settings\All Users\Start Menu\Program Files
- Change the name of the shortcut to "eclipse"
-
- Right click the shortcut and edit its properties
-
- Start in:
C:\eclipse
- Target:
C:\eclipse\eclipse.exe -data "%HOMEDRIVE%%HOMEPATH%\eclipse_work" -vm "C:\Program Files\Java\j2re1.4.2_10\bin\javaw" -vmargs -Xmx256M
- Make sure the path to javaw in the Target above matches your java install
- Start in:
-
Install CDT by unzipping the (eg) org.eclipse.cdt.sdk-3.0.1-win32.x86.zip file to C:\
- This should create a collection of "org.eclipse.cdt..." directories underneath C:\eclipse\plugins
- Check that you can start Eclipse by Start->Program Files->eclipse
-
Check that CDT is correctly installed by
- Eclipse "window" menu
- "Open Perspective" -> "Other" -> "C++"
- If C++ does not appear recheck the above steps
-
Note - you should run Eclipse using a normal user account, not the Administrator account
- Check that the C:\eclipse folder is not writeable by "Everyone" - the Everyone group should only have read/execute
- Setting up the shortcut as described above will ensure a seperate eclipse workspace will be created under your normal user account
- If the user account you normally use to do your work has Administrator privileges, remove those privileges now
- If you're quite happy to destroy your computer, then keep running your normal user account with Admin privileges (or worse, do your development as Admin) - dont complain when you have to reinstall from original media, you've been warned
- Now move on to EclipseCDT developing under Qt Ming
PHP Warning
lib/plugin/CreateToc.php (In template 'body' < 'html'):91: Warning: preg_match(): Unknown modifier 'M' (...repeated 24 times)
lib/plugin/CreateToc.php (In template 'body' < 'html'):116: Notice: Heading <h2> Writing Open Source Programs on Windows with Qt/MinGW </h2> not found
'IT > 프로그래밍' 카테고리의 다른 글
커버리티, 삼성전자 C/C++, Java 소스 분석툴로 선정 (0) | 2007.07.06 |
---|---|
[QT/Win32] QDevelop 윈도우용 설치 (0) | 2007.07.06 |
Modal, Modaless 간략한 댓글 발췌 (0) | 2007.07.06 |
Framework?? (0) | 2007.07.06 |
fread,frwire,fseek,ftell 정리 (0) | 2007.07.06 |
- Total
- Today
- Yesterday
- 지루박멸연구센타
- 열정의 힘을 믿는다
- Le4rN TO Cr4cK
- 디버깅에관한모든것(DebugLab)
- sysinternals
- FoundStone
- hashtab
- 보안-coderant
- 디바이스드라이버 개발자 포럼
- dualpage.muz.ro
- osronline.com - 드라이버 관련 정보 사이트
- NtInternals - NativeAPI Refere…
- pcthreat - spyware 정보 제공
- rootkit.com - 루트킷 관련 정보
- www.ntinternals.net
- WINE CrossRef. - source.winehq…
- tuts4you
- hex-rays
- idapalace
- idefense
- immunityinc
- threatexpert
- hdp.null2root.org
- www.crackstore.com
- crackmes.de
- www.who.is
- www.cracklab.ru
- community.reverse-engineering.…
- video.reverse-engineering.net
- SnD
- 클레이 키위
- reversengineering.wordpress.co…
- www.openrce.org
- www.woodmann.com
- PEID.Plusins.BobSoft
- roxik.com/pictaps/
- regexlib.com
- spyware-browser.com
- www.usboffice.kr
- regulator
- www.txt2re.com
- ietab.mozdev.org
- zesrever.xstone.org
- www.heaventools.com/PE-file-he…
- www.heaventools.com
- www.innomp3.com
- 울지않는벌새
- exetools.com-forum
- exetools.com
- utf8 conv
- robtex - IP trace
- onsamehost - same IP sites
- JpopSuki
- jsunpack.jeek.org
- wepawet.iseclab.org
- www.jswiff.com
- www.hackeroo.com
- winesearcher.co.kr
- khpga.org
- malwareurl.com
- anubis.iseclab.org
- www.crummy.com-eautifulSoup
- malwarebytes.org/forums
- bbs.janmeng.com
- blackip.ustc.edu.cn
- eureka.cyber-ta.org
- exploit-db.com
- PIR
- SBI저축은행
- 시스템트래이딩
- 자동트래이딩
- 공공인프라
- 주식트래이딩
- 전세매매지수
- CriticalSection
- 주택구매력지수
- systemd
- 실시간트래이딩
- 미국주식
- 주식
- hai
- ROA
- 신한저축은행
- 매매가격지수
- O365
- 레고랜드
- 사회간접자본
- 군함도
- Pivot
- logrotate
- INVOICE
- ChatGPT
- ubuntu
- 다올저축은행
- 피봇
- ElasticSearch
- 맥쿼리인프라
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |