LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Program starts from command line but not from file browser (https://www.linuxquestions.org/questions/programming-9/program-starts-from-command-line-but-not-from-file-browser-209382/)

lasindi 07-25-2004 05:11 AM

Program starts from command line but not from file browser
 
I've been working on a program to solve stoichiometry problems (stoichiometry is a part of chemistry; don't worry if you don't understand it, my problem has nothing to do with it). I wrote it with the QT designer. The most glaring issue by far now is that you can start it from the command line ("./stoichiometrysolver" works) but if you try double-clicking on it in a file browser like Konqueror or Nautilus, it won't work. It will just hang as it uses up 100% CPU. :scratch: You can download the source here. (Merely clicking this link doesn't work; it will work if you click it while holding Ctrl in Mozilla/Firefox.) You'll need Qt's libraries to compile. Does anyone have any idea how to solve this?

lasindi

kilgoretrout 07-25-2004 06:14 AM

I haven't read your source code but here's a quick workaround. Create a bash script to start it:

#!/bin/bash
cd <path to directory program is in>
./stoichiometry

Make a text file, name it dostoichiometry

Open a console and navigate to the directory where the text file is and do:

# chmod a+x dostoichiometry

Then when you click dostoichiometry it should open the program. Note, you should have no space on the first line of the script before "#!" or it won't work when you click on it, i.e. "#!" must start the line.

lasindi 07-25-2004 07:03 AM

Thanks a lot, works beautifully! I should have thought of that before. I wonder, since the script has to cd to the directory, does this mean that the problem with simply double clicking from a file browser was the working directory? Does clicking on a binary in Konqueror or Nautilus mean

/dir/dir/dir/binary

or

cd /dir/dir/dir
./binary

I'm asking this because my program relies on an external data file in the same directory, and if the file isn't there, it hangs on startup, even from the console.

Whatever the case, this workaround works great. Thanks again!

lasindi

kilgoretrout 07-25-2004 07:34 AM

I'm not sure why it works but it probably has something to do with linking to the external data file. In linux, you will find many progams that actually start with a bash script; many games do and IIRC mozilla does as well. These are all programs that link to a lot of external libraries and the startup scripts set the the paths to these external files.


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