Page 1 of 1

Running c++ programs

Posted: Mon 01 Jul 2013, 04:35
by TheMadScientist_2053
Okay so I just started running puppy on my tower and I am trying to figure it out. I have about 13 minutes of experience with all Linux distros, and am not very familiar with the terminal. I've downloaded the Devx.sfs and got that set up so at least I can compile whatever I write in Geany. The trick now is to actually run the darn thing. Most of the information I've found has to do with compiling and the Devx.sfs. Any and all help on the subject would be greatly appreciated.

Posted: Mon 01 Jul 2013, 10:06
by amigo
Once compiling is done, you must make sure the binary object is set 'executable'. Then, from the shell in a terminal you execute it like this:

Code: Select all

[path-to]program-name
[/quote]

Posted: Mon 01 Jul 2013, 16:10
by TheMadScientist_2053
amigo wrote:Once compiling is done, you must make sure the binary object is set 'executable'. Then, from the shell in a terminal you execute it like this:

Code: Select all

[path-to]program-name
[/quote]

How does one set the binary object to executable?

Posted: Mon 01 Jul 2013, 18:16
by amigo
From the terminal:
chmod 755 name-of-file

The linker may do this properly for you, but it doesn't hurt to run the command anyway.

If you are running a terminal in the same directory where the binary executable is located, then simply:

Code: Select all

chmod 755 file-name
./file-name
In order to run the program without specifying the path to it, you need to place it in your PATH -usually under /usr/local/bin for stuff you compile yourself. Then, it can be run from a terminal anywhere or from a script, without giving the path:

Code: Select all

file-name

how to make it executable

Posted: Mon 01 Jul 2013, 18:24
by 6502coder
cd to the place where the binary is located, then

Code: Select all

chmod  +x   program-name
BTW, if you tell us more about what you DO know, we can give you better help. You say you're not familiar with the terminal...Do you have any experience at all with using a command line, e.g. MS DOS or the command shell in Windows? Have you ever written and compiled a C++ program using either a command line or an IDE?

Re: how to make it executable

Posted: Mon 01 Jul 2013, 19:12
by TheMadScientist_2053
6502coder wrote:cd to the place where the binary is located, then

Code: Select all

chmod  +x   program-name
BTW, if you tell us more about what you DO know, we can give you better help. You say you're not familiar with the terminal...Do you have any experience at all with using a command line, e.g. MS DOS or the command shell in Windows? Have you ever written and compiled a C++ program using either a command line or an IDE?
ipconfig is about the extent of my knowledge of windows command shell. As far as C++ goes, I'm pretty familiar with it. I've done quite a bit of stuff using the MicroSoft Visual studios IDE.

Posted: Thu 25 Jul 2013, 00:30
by ericsond
If you are planning to use Geany, this is even easier...for example just type (or cut and paste) a sample program like (assuming you have devx already installed):

#include <stdio.h>
int main( void )
{

printf("Hello World!");

return 0;

}


then you can go under the 'Build' drop down menu of Geany, and select Build, and then Execute, or even easier just do F9 and F5. You can even change what these do by using the 'Set Build Commands' under the 'Build' drop down menu.