LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Qt application wont run in terminal "Permision denied" even as root user (noob @ qt) (http://www.linuxquestions.org/questions/programming-9/qt-application-wont-run-in-terminal-permision-denied-even-as-root-user-noob-%40-qt-4175439167/)

EpicViTTo 11-28-2012 01:02 PM

Qt application wont run in terminal "Permision denied" even as root user (noob @ qt)
 
Hello all, it has been a while since i last used this forum...
i am currently running the latest Mint distro and i am very interested in the QT dev kit that i have recently just discovered. I have decent skill with c++ and i have programmed in the terminal before and i really enjoy it. however with my freshly installed Linux Mint i can't get c++ projects to compile. The behavior i get is that the compiler isn't reading my #include lines correctly. it always crashes and reports that all my objects in main are unidefined references. I have looked but i can't find anything that solves this. Is there something about Mint thats different from other distros when it comes to compiling code?

oops... i'm the OP and im already of topic lol I was trying to compile an extremly basic qt example from a book but everytime i try i get "permision denied" i have tried running it from root and i reinstalled qt on as both my standard account and as the root user and i always get the same thing..

here is the code example i am using..
Code:

#include <QApplication>
#include <QLabel>

int main( int argc, char *argv[] )
{
    QApplication app( argc, argv );
    QLabel *label = new QLabel( "Hello World with QT!" );
    label->show( );
    delete label;
    return app.exec( );
}

as i said its a really basic example... these are the commands i'm using to compile and run the program:

qmake -project // because the book told me to.
qmake HelloWorld.pro // because apparently the .pro file was made by the previous //command.
./HelloWorld // the book doesn't explain this part for linux so i tried this &&
./HelloWorld.pro //&&
./HelloWorld.cpp

but they all return the permission denied thing... i consider myself a decent c++ programmer but this enviorment is still fairly new to me and i am very lost... i hope my rambling makes sense to more than just me i have been awake far to long lol any help or tips would be really apreciated thanks :)

gnashley 11-28-2012 01:09 PM

Have you tried `chmod 755 HelloWorld.cpp`?

EpicViTTo 11-28-2012 01:21 PM

i tried that it got rid of the permission thing but now it says:

./HelloWorld.cpp: line 4: syntax error near unexpected token '('
./HelloWorld.cpp line 4: int main(int argc, char *argv[])'

not sure what that means since im sure that "(" needs to be there and there are no errors that i can see around that area...

what does the chmod 755 command do exactly?

knudfl 11-28-2012 02:05 PM

The "qmake procedure" is :

1) qmake -project ( Creates <Folder-name>.pro )
2) qmake ( Creates a Makefile )
3) make ( Creates the executable e.g. HelloWorld )
4) ./HelloWorld : Runs the applications.



.

EpicViTTo 11-28-2012 02:12 PM

Thank you for writting that out for me the book does a terrible job of explaining things so far. i followed that order and the terminal says:

HelloWorld: cannot connect to X server

im not at all familiar with what this means but it seems like im getting closer to getting this thing working ( finally )

is X server reffering to the GUI part of Linux Mint?

I did some research and found this link:

http://stackoverflow.com/questions/6...qt-application

it explains that the most common reason for the X server error is that the display is not set to the current enviorment. the best wa to fix this according to the link is to type this command,

export DISPLAY=:0.0

before the

./HelloWorld

command :)

hopefully this question can help someone else as well now.

Thanks soooo much to everyone who helped sove this problem :)


All times are GMT -5. The time now is 08:54 PM.