Easy C++ Compile?

Bridger

Registered
Is there an easy way with Program Builder to make a program from a .cpp file? I can compile it, but not run, and it gets saved as a document. can someone tell me how to make an application from my .cpp file?
 
yeah, new project, choose (Tool) C++ tool

You are presented with Hello World. I assume if you are talking about a single .cpp file then you are looking at command line cin cout iostream level functions.

This will make a program that can be executed as a command line tool. Welcome the CLI world. :-/

Hope that's what you were looking for.
 
I am new at C++. I can get cout<<"Hello world" but I can't figure out how to get cin to work. It appears to do nothing.

I am using Project Builder C++ tool and can't figure it out. I have also tried compiling using cc from the terminal but don't get anywhere. It appears that the iostream.h include is not getting handled correctly. I get a lot of compiler errors when I try to use an include.

Thanks
 
where do I put the header files? I have the file named utilities.h (flushes the buffer) and I don't know where to put it to utilitize it


:(
 
#include &lt;iostream&gt;

int main (int argc, const char * argv[])
{
// insert code here...
int niner = 0;
cout &lt;&lt; "enter an integer and hit return" &lt;&lt; endl;
cin &gt;&gt; niner;
cout &lt;&lt; endl &lt;&lt; niner &lt;&lt; endl;
return 0;
}


That's my main, and my whole program. It is admittedly sparse, and it has a tendency to want input before it refreshes the display... but I suppose it might help someone on this list. Also important to understanding cin and cout may be to understand what these actually mean. They're not just command line interface. Using unix redirection, you take standard output from your tool and pipe it to another tool, or vice versa. Unix is crazy.

As for your headers, put them in your project, add them to source, or make a folder called headers in your project... the project builder just needs to be able to find them. I'm sure these details are changing from one version of project builder to another, so RTFM, (read the manual)

Play around. read some pdf's. enjoy yourself.
 
can someone show me an simple example of how to precompile a simple header file in terminal?

and also what does " implicit declaration of function " {char cRet = toupper(cin.get()) }mean?


ps. I apologize if the second is not clear, basically I want to know how to precompile a header file. I tried using the helper and tried using their suggestion, but when I attempted to do it , I get alot of errors on the terminal screen.

:confused:
 
but I can help you with the implicit declaration ... it means that the compiler found that line which appears to use a function but you had not defined that function yet. Usually a lack of an include, or general syntax error.

Hope that helps. gcc has horrible error messages.
 
this is what I did

[localhost:~/desktop] mkwan% ls
Desktop (Mac OS 9) addition.h main.cpp utilities.h
[localhost:~/desktop] mkwan% cc -precomp addition.h -o addition.p
[localhost:~/desktop] mkwan% c++ main.cpp
main.cpp:1: addition.h: No such file or directory
[localhost:~/desktop] mkwan%

addition. h is shown below:

int addthenum(int, int);

and the main.cpp:

#include <addition.h>
#include <iostream.h>
#include <math.h>

int main(void)
{
int iNum;
int iNum1;
iNum = 10;
iNum1 = 25;
cout << "I am testing if I can use a precompiled header file to run\n"
"this bitch.";
addthenum();

return 0;
}
/**********************************************************************************
this is the function addthenum it will add the numbers passed down from the main
function
**********************************************************************************/
int addthenum(int iNum, int iNum1)
{
int iAnswer;
iAnswer = iNum +iNum1;
return int;
}


in the CLI, above, it appears that I have successfully precompiled the addition.h header file, but when I try to compile the cpp file the shell tells me that the addition.h does not exist. Am I missing something here? I just don't know what to do, I like to add more header files. here I have shown what I have typed up in the header and cpp file. any suggestions?
 
in the main.cpp file there supposed to be 3 include statements:

#include <iostream.h>
#include <addition.h>
#include <math.h>


sorry
 
Back
Top