Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 23, 2007, 06:23 AM   #1
emil.s
macrumors newbie
 
Join Date: Feb 2007
Location: Sweden
Send a message via MSN to emil.s
QT4 in Leopard: error: QApplication: No such file or directory

I'm trying to learn QT4. But it seems as i can't compile any program...
I'm following this very basic guide:
http://doc.trolltech.com/4.0/tutorial-t1.html

But when i try to compile it i get:
Code:
emil@MacBooken.local: ~/Desktop $ g++ QT-hello.cpp 
QT-hello.cpp:1:24: error: QApplication: No such file or directory
QT-hello.cpp:2:23: error: QPushButton: No such file or directory
QT-hello.cpp: In function 'int main(int, char**)':
QT-hello.cpp:6: error: 'QApplication' was not declared in this scope
QT-hello.cpp:6: error: expected `;' before 'app'
QT-hello.cpp:8: error: 'QPushButton' was not declared in this scope
QT-hello.cpp:8: error: expected `;' before 'hello'
QT-hello.cpp:9: error: 'hello' was not declared in this scope
QT-hello.cpp:12: error: 'app' was not declared in this scope
I know i got these errors in GNU/Linux when i tried to compile some programs some time ago, but the errors where gone after i installed some dev-libs.

Now, in OS X i have installed "qt-mac-opensource-4.3.2.dmg" from:
http://trolltech.com/developer/downloads/qt/mac

But i still get these errors! How do i get rid off them?
emil.s is offline   0 Reply With Quote
Old Nov 23, 2007, 07:06 AM   #2
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Are the headers / libraries in the correct place? Are you using the correct compiler options?
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Nov 23, 2007, 10:52 AM   #3
emil.s
Thread Starter
macrumors newbie
 
Join Date: Feb 2007
Location: Sweden
Send a message via MSN to emil.s
Quote:
Originally Posted by Cromulent View Post
Are the headers / libraries in the correct place? Are you using the correct compiler options?
Hi! This is what "locate" fount when searching for "QApplication"

/Library/Frameworks/QtGui.framework/Versions/4/Headers/QApplication

And i'm trying to compile it with just "g++ ./file-name.cpp".
I think i should use the "-l" or "-L" option, but with what parameters?
emil.s is offline   0 Reply With Quote
Old Nov 25, 2007, 11:16 PM   #4
simon-says
macrumors regular
 
Join Date: May 2005
Location: Shreveport, LA
The problem here is that you are just trying to straight compile with gcc. If you read further down in the article you will see that you need to run qmake to build a project file first.

In the directory you created your .cpp file, run the command 'qmake -project' to generate a .pro project file. After that run 'qmake', this will generate a Makefile. Then just run 'make'. Your program will then be built and you can run it.

After you create your Qt project file, you can use 'qmake -spec macx-xcode', this will create you an xcode project for you. This is handy so you don't have to stay in the command line.
simon-says is offline   0 Reply With Quote
Old Nov 27, 2007, 11:02 AM   #5
emil.s
Thread Starter
macrumors newbie
 
Join Date: Feb 2007
Location: Sweden
Send a message via MSN to emil.s
Quote:
Originally Posted by simon-says View Post
The problem here is that you are just trying to straight compile with gcc. If you read further down in the article you will see that you need to run qmake to build a project file first.

In the directory you created your .cpp file, run the command 'qmake -project' to generate a .pro project file. After that run 'qmake', this will generate a Makefile. Then just run 'make'. Your program will then be built and you can run it.

After you create your Qt project file, you can use 'qmake -spec macx-xcode', this will create you an xcode project for you. This is handy so you don't have to stay in the command line.
Hi! Worked fine, until i tried with "make". And of course it doesn't work, there is no makefile...

Code:
emil@MacBooken.local: ~/Desktop/QT-test $ ls
Info.plist		QT-hello.cpp		QT-test.pro		QT-test.xcodeproj
I have tried with both "qmake -project" and "qmake -project ./QT-hello.cpp".
The "qmake" command gives nothing.

Thanks for helping!
emil.s is offline   0 Reply With Quote
Old Nov 27, 2007, 01:49 PM   #6
simon-says
macrumors regular
 
Join Date: May 2005
Location: Shreveport, LA
Ah, the Qt-Test.xcodeproj is an XCode project you can use. Your default for qmake must be for it to build an XCode project. I always build Qt from source and the default is makefiles. If after you create the Qt project file with 'qmake -project' you run 'qmake -makefile' this will generate you a makefile that you can run make with.
simon-says is offline   0 Reply With Quote
Old Nov 27, 2007, 02:38 PM   #7
emil.s
Thread Starter
macrumors newbie
 
Join Date: Feb 2007
Location: Sweden
Send a message via MSN to emil.s
Quote:
Originally Posted by simon-says View Post
Ah, the Qt-Test.xcodeproj is an XCode project you can use. Your default for qmake must be for it to build an XCode project. I always build Qt from source and the default is makefiles. If after you create the Qt project file with 'qmake -project' you run 'qmake -makefile' this will generate you a makefile that you can run make with.
Unfortunately not:
Code:
emil@MacBooken.local: ~/Desktop/QT-test $ qmake -project
emil@MacBooken.local: ~/Desktop/QT-test $ qmake -makefile
emil@MacBooken.local: ~/Desktop/QT-test $ ls
Info.plist		QT-hello.cpp		QT-test.pro		QT-test.xcodeproj
But the Xcode project worked fine. "Hello World!"
But i prefer the commandline when i edit the code with "vim" anyway...

Anymore proposals?
emil.s is offline   0 Reply With Quote
Old Nov 27, 2007, 02:55 PM   #8
simon-says
macrumors regular
 
Join Date: May 2005
Location: Shreveport, LA
Hmm that is interesting that it generate a makefile for you, normally if qmake is called and does nothing it will display the help if anything. You might be able to try 'qmake -spec macx-g++'. I hear you about Vim, though most of the time I prefer the nice interface of XCode. Especially when dealing with projects that have 80+ source files.
simon-says is offline   0 Reply With Quote
Old Nov 27, 2007, 03:04 PM   #9
emil.s
Thread Starter
macrumors newbie
 
Join Date: Feb 2007
Location: Sweden
Send a message via MSN to emil.s
Quote:
Originally Posted by simon-says View Post
Hmm that is interesting that it generate a makefile for you, normally if qmake is called and does nothing it will display the help if anything. You might be able to try 'qmake -spec macx-g++'. I hear you about Vim, though most of the time I prefer the nice interface of XCode. Especially when dealing with projects that have 80+ source files.
Yes! Worked great, thanks!

And of course an IDE is better with such large projects. But vim is perfect for just edit some single files.
emil.s is offline   0 Reply With Quote
Old Nov 27, 2007, 03:12 PM   #10
simon-says
macrumors regular
 
Join Date: May 2005
Location: Shreveport, LA
Cool. No problem for the help. I work with Qt daily, I know it's good and bad things. If you want to pick up a book relating to Qt Programming, I can recommend one.

C++ GUI Programming with Qt 4
Jasmin Blanchette and Mark Summerfield
ISBN: 0131872494

I have looked at a few, and that was the most helpful to start out with. There are a few other new ones I need to check out.

- Brent Nycum
simon-says is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
copy a directory using bash - how to do it? error: is a directory (not copied). cupboy1 OS X 10.8 Mountain Lion 0 Mar 23, 2014 09:50 PM
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory xpmrz Mac Basics and Help 0 Dec 31, 2013 02:59 PM
iPhone: Which file and directory is it to change a slider? bobright Jailbreaks and iOS Hacks 3 Apr 14, 2013 02:56 AM
File and directory comparison tool UNCMo96 OS X 2 Mar 21, 2013 11:29 AM
-Bash No such file or directory os ck Mac Basics and Help 0 Jan 14, 2013 09:21 AM

Forum Jump

All times are GMT -5. The time now is 11:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC