ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
upon reading your output ...you specify for g++ to output 'helloworld' via the '-o helloworld'...but you do not specify the source files... ie `g++ -o helloworld helloworld.cc ...`
your code could be god sent....but if the compiler doesn't know what to compile your program from ...it won't work too well.. :)...
this code is from the KDE/Qt,
it is a example!
my some code is that wrong,but I can't understand what is wrong
one:qmake make the makefile
two:make
I don't understand what I am wrong,help me!
there is no information about the Qt,
introduce some information to me!
thanks !
there is no source file listed there to compile...
you ran this from a pre-made makefile ? if so ..post the make file..
irregardless ...go to the directory where this 'makefile' is and check to see if there is a file called 'helloworld.cc' or 'helloworld.cpp' ...etc then run this ::
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
/* helloworld.cpp */
#include <qapplication.h>
#include <qlabel.h>
#include <qstring.h>
int main( int argc, char **argv)
{
QApplication app(argc,argv);
QLable *label = new QLabel(NULL);
QString string ("Hello, world");
label->setText(string);
label->setAlignment( Qt:AlignVCenter | Qt::AlignHCenter);
label->setGeometry(0,0,180,75);
label->show();
app.setMainWidget(label);
return (app.exec());
}
I am first use the qt programming
thank you jhorvath!
..first off , there are 2 syntax errors in your code ...
Code:
/* helloworld.cpp */
#include <qapplication.h>
#include <qlabel.h>
#include <qstring.h>
int main( int argc, char **argv)
{
QApplication app(argc,argv);
QLabel *label = new QLabel(NULL); // this was wrong, it is correct now
QString string ("Hello, world");
label->setText(string);
label->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter); // this was wrong, it is correct now
label->setGeometry(0,0,180,75);
label->show();
app.setMainWidget(label);
return (app.exec());
}
...let's go and try to build this and see if that is better , k
..don't forget to tell the compiler what source to build ...on my system ...i did this
[saved the code you see above as 'helloworld.cc']
[and i compiled with] `g++ -Wall -o helloworld helloworld.cc -L/usr/lib/qt/lib -lqt`
thanks!
I first creat a new helloworld.pro
and creat a helloworld.ui.h.
add the code putin the helloworld.ui.h
then use the command qmake -o makefile helloworld.pro to
creat the makefile,and use the command make,
and occure the top wrong,I have revised my code,but the wrong is all the stay!Under the qt I havn't see the postfix .cc,so^
it is me so foolish,my some code occure the same wrong,
underfine the "main",
First of, lets forget about any possible errors in your code, cover them if you get a compiler error which indicates that there is a problem in your source code (notice, no reference to your source file in the error message generated, ie your source file will be something like helloworld.cpp.)
Next, this is the build line that qmake generated automatically for you from your .pro file:
If you run the live above, it will most probably compile your code (since now it knows what the source file is)
So I guess that in your .pro file there is a mistake or missing option, one which specifies which .cpp files are to be included in your build.
Ok, so I quickly googled for 'qmake .pro' and the fourth hit down will give you the answer.
I think the line :
SOURCES = helloworld.cpp
should be added to your .pro
And if you have a helloworld.h header also add
HEADERS = helloworld.h
That line is for dependancy checking, used to determine if it needs to compile this unit (ie if either source or header is changed). This is not used to build the code, instead it is used by make to fire a rule cause it to rebuild your code.
I dont not have experience with qmake, so I could be wrong, but that is how it looks to me.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.