I'm currently learning Qt by working through examples in the ebook "C+ GUI Programming with Qt 4, Second Edition".
The first example is a "Hello World" application. Following the steps in the example I've been able to create the following files:
hello.cpp, by typing out the provided code.
hello.pro, by using OS X Terminal command "qmake -project".
hello.xcodeproj and info.plist by using command "qmake hello.pro"
However, I am unable to create "hello.app"
The command "make" yields:
"make: *** No targets specified and no makefile found. Stop."
The command "make hello" yields:
g++ hello.cpp -o hello
hello.cpp:1:24: error: QApplication: No such file or directory
hello.cpp:2:18: error: QLabel: No such file or directory
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected `;' before ‘app’
hello.cpp:7: error: ‘QLabel’ was not declared in this scope
hello.cpp:7: error: ‘label’ was not declared in this scope
hello.cpp:7: error: expected type-specifier before ‘QLabel’
hello.cpp:7: error: expected `;' before ‘QLabel’
hello.cpp:9: error: ‘app’ was not declared in this scope
make: *** [hello] Error 1
While I can't create "hello.app" from the terminal with these two commands, I can create it by simply opening Xcode and pressing the button "Build and Go".
Can someone tell me why in the world these two commands don't work? And how I can make the "hello.app" from the terminal?
Thanks!
I see that qmake has generated an *.xcodeproj-file for you. Try running xcodebuild instead of make :)
It looks like you didn't include the directories from the Qt SDK in your makefile paths. Did you also remember to run QMake?
I would suggest you download and install Qt SDK. Then familiar yourself with Qt Creator, the IDE for Qt. It's much easier that way since all the frameworks and docs are installed and configured for you.
Related
I am trying to compile the project present at Link
While compiling from the main folder I am getting the error:
:-1: error: Project ERROR: qtspeech/examples/speech/qmlspeech/qmlspeech.pro is lacking an install target.
I tried adding following text in the qmlspeech.pro file:
target.path += /home/harshmittal/build
INSTALLS += target
I got the following error:
:-1: error: Project ERROR: /qtspeech/examples/speech/qmlspeech/qmlspeech.pro installs target to unexpected location.
If I try to open the project Individually and try to compile it, I receive the following error:
:-1: error: Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build.
I want to compile this project, original youtube link: Video
Qt Version: 5.15
OS: Linux
I am trying to run and debug Qt6 widget application in clion.
I tried the things that u would get when do a simple search but no success.
Recently my friend told my to do this :
Add "C:\Qt\Tools\mingw810_64" to toolchain environment like this :
now when I create a Qt widget project like this :
I get these error :
Problems were encountered while collecting compiler information:
g++.exe: error: unrecognized command line option '-Zc:__cplusplus'
g++.exe: error: unrecognized command line option '-permissive-'; did you mean '-fpermissive'?
What should I do now ?
Why doesn't it recognize these options ?
I cannot change g++.exe file (or can I?) What can do about it?
I have been struggling to manage to run and debugg Qt6 project on clion the past few weeks.
God bless anyone who help me to do this.
Please Help!
The problem is that you use MSVC-build of Qt and not the MinGW one. Update your CMakeLists.txt file:
set(CMAKE_PREFIX_PATH $ENV{QTDIR})
the environment variable QTDIR is set to Qt MinGW path (e.g. D:\Qt\6.2.3\mingw_64).
Don't forget to add the corresponding directory bin (%QTDIR%\bin) to the path environment variable.
I am trying to compile an existing qt application's code using mingw compiler.
During compilation I am getting an error "*** internal error: unable to open jobserver semaphore '3,4': (Error 2: The system cannot find the file specified. ). Stop".
My current project is a makefile based project. Here I have one make file (parent.mk) that compiles all primary modules and then
parent.mk
compilation steps
.
.
.
make $QT_CODE_DIR
Here in this QT code directory I have another makefile (child.mk) which has following content:
child.mk
cd "qtcode_compilation_out_dir"
qmake.exe "product.pro" -r -spec win32-g++
CONFIG+=release
mingw32-make -w
If I try to run the make command manually for QT code then it works fine.
#Alexander: Thanks for the suggestion.
Please suggest if anyone has any idea about it.
Thanks.
Finally, I found out the exact reason of the problem and solution as well.
Reason for failure:
The compilation command that I am using is "make" which is been aliased to "make -j2"and along with "mingw32-make -w" it was producing the error because mingw32-make is an obsolete make command and it doesn't support multi threaded compilation.
Solution:
I just replaced the mingw32-make with make.
I run some downloaded code using hash_map.h. But when I compile it using g++, it gives error message:
fatal error: 'hash_map.h' file not found
I search on google, some one suggests to replace 'hash_map.h' by 'ext/hash_map.h' and add 'using namespace __gnu_cxx;'. But still I get the error message 'fatal error: 'ext/hash_map.h' file not found'.
I type "sudo find / -name hash_map.h" in the terminal of my Mac, and get the following results.
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/debug/hash_map.h
How to link hash_map.h to the downloaded code?
I add the path to the hash_map.h to the Makefile as follows.
g++ -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/ -c target.cpp
And I replace 'hash_map.h' by 'debug/hash_map.h', and add 'using namespace __gnu_cxx;'.
It works for me.
I'm getting a strange problem with my C/C++ dev environment. I had installed gcc, g++ on my linux box(ubuntu 14.04).
With the hello world program being built on my system I'm getting this error:
make all
/bin/sh: 1: Syntax error: Unterminated quoted string
make: *** [src/Banker's.o] Error 2
has anyone encountered to this problem before could help me with this?
It looks like your problem is in the name of the file you're trying to compile: Banker's.c. Rename the source to Bankers.c without the single quote in it.
mv src/"Banker's.c" src/"Bankers.c"