Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How do I run a C++ console app on its own?

How do I run a C++ console app on its own?
Thread Tools
Forum Regular
Join Date: Apr 2001
Location: St. Louis
Status: Offline
Reply With Quote
Sep 8, 2001, 09:34 PM
 
I have created a small C++ program in Project Builder, How do I compile it so that it runs independently from PB? Is this possible--I know it was in Code Warrior Pro 3--but I would like to be able to do this in OS X without expelling $$$$$$$$$$ .

Thanks,

JARinteractive

[ 09-08-2001: Message edited by: jarinteractive ]
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Sep 8, 2001, 10:01 PM
 
If you have installed the dev tools, it comes with c++. It'll do the thang

[localhost:~] fahrenba% pic program.c
.lf 1 program.c
#include <iostream.h>

int main()
{
cout << "Welcome";
return 0;
}
[localhost:~] fahrenba% c++ program.c
[localhost:~] fahrenba% ./a.out
Welcome[localhost:~] fahrenba%
HTH,
F-bacher
     
Forum Regular
Join Date: Apr 2001
Location: St. Louis
Status: Offline
Reply With Quote
Sep 9, 2001, 12:01 AM
 
could you explain this in more detail, please. Sorry for my ignorance!

JARinteractive
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Sep 9, 2001, 12:35 AM
 
What he means is that there is a command-line program installed by the dev tools installer called "c++".

It is a c++ compiler. By typing "c++ program.c" you compile the program.c file into an "a.out" binary. When you type "./a.out" it will execute this binary.

I think that there is a "-o <name>" option that lets you specify the name of the finished binary but I am not sure.

Does that answer your question?
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Sep 9, 2001, 04:36 AM
 
I think he might want a SIOUX-like app (double-click, it launches and you get a window which you can use to manipulate stdin/stdout). There are no SIOUX libraries under OS X, if you want a commandline app you must use the, uh, commandline

I think that CW Pro 6 does have SIOUX libraries, so if you *REALLY* need to you can buy that, but you'd be better off writing a GUI
     
Forum Regular
Join Date: Apr 2001
Location: St. Louis
Status: Offline
Reply With Quote
Sep 9, 2001, 08:10 AM
 
thank-you guys! I have it running in the terminal.

JARinteractive
     
Forum Regular
Join Date: Apr 2001
Location: St. Louis
Status: Offline
Reply With Quote
Sep 9, 2001, 09:38 AM
 
It would be nice if someone would create program that would run command-line programs in a window . I'm sure this would be very useful to other students working with C++, too. I would create it, but I don't have experience programming in Objective-C, cocoa, etc. Only C++, REALbasic, PHP, and Javascript. (I would like to learn to write Cocoa apps, though.)

JARinteractive
     
Grizzled Veteran
Join Date: Apr 2001
Status: Offline
Reply With Quote
Sep 13, 2001, 08:59 PM
 
It would be nice if someone would create program that would run command-line programs in a window . I'm sure this would be very useful to other students working with C++, too.
Um, no offense, but why would someone create a program to run command-line programs in a window when all you have to do is open a terminal and run the program?

Wade
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Sep 13, 2001, 09:35 PM
 
He's thinking of how CodeWarrior does it - when you run your command line programs, it spawns a window with the output. It's really silly, but I guess it could be kind of reassuring to a novi programmer.

F-bacher
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Sep 14, 2001, 03:47 PM
 
Originally posted by Ghoser777:
<STRONG>He's thinking of how CodeWarrior does it - when you run your command line programs, it spawns a window with the output. It's really silly, but I guess it could be kind of reassuring to a novi programmer.</STRONG>
It's not silly when you consider that otherwise there would be no way of getting access to stdin/stdout on Classic (apart from using files, I guess).
     
Junior Member
Join Date: Mar 2001
Location: Park Ridge, NJ, USA
Status: Offline
Reply With Quote
Sep 14, 2001, 06:50 PM
 
I think I'm having a problem with missing header files...

Here's what happened when I tried to compile my program with "c++ virtfunc.cpp":


In file included from /usr/include/gcc/darwin/2.95.2/g++/libio.h:30,
from /usr/include/gcc/darwin/2.95.2/g++/streambuf.h:36,
from /usr/include/gcc/darwin/2.95.2/g++/iostream.h:31,
from virtfunc.cpp:1:
/usr/include/gcc/darwin/2.95.2/g++/_G_config.h:4: sys/types.h: No such file or directory
/usr/include/gcc/darwin/2.95.2/g++/_G_config.h:85: stddef.h: No such file or directory
In file included from /usr/include/gcc/darwin/2.95.2/g++/streambuf.h:36,
from /usr/include/gcc/darwin/2.95.2/g++/iostream.h:31,
from virtfunc.cpp:1:
/usr/include/gcc/darwin/2.95.2/g++/libio.h:59: sys/cdefs.h: No such file or directory
/usr/include/gcc/darwin/2.95.2/g++/libio.h:275: stdio.h: No such file or directory
Any ideas?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2