Running c++ programs

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
TheMadScientist_2053
Posts: 8
Joined: Tue 18 Jun 2013, 02:30

Running c++ programs

#1 Post 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.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post 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]

TheMadScientist_2053
Posts: 8
Joined: Tue 18 Jun 2013, 02:30

#3 Post 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?

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#4 Post 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

User avatar
6502coder
Posts: 677
Joined: Mon 23 Mar 2009, 18:07
Location: Western United States

how to make it executable

#5 Post 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?

TheMadScientist_2053
Posts: 8
Joined: Tue 18 Jun 2013, 02:30

Re: how to make it executable

#6 Post 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.

ericsond
Posts: 5
Joined: Sat 13 Apr 2013, 14:54

#7 Post 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.

Post Reply