* g++ compiler
@ 2010-01-29 9:23 hossein shoghian
2010-01-29 10:47 ` Axel Freyn
0 siblings, 1 reply; 4+ messages in thread
From: hossein shoghian @ 2010-01-29 9:23 UTC (permalink / raw)
To: gcc-help
hi
please help me
how to compiling this main with GCC, the GNU Compiler
i use g++ -pthread -Wall main.cpp
but don't pass argument
main.cpp
int main(int argc, char *argv[]) {
/* Verify the correct number of arguments were passed in */
if(argc != 4) {
fprintf(stderr, "USAGE:./main.out <INT> <INT> <INT>\n");
}
int mainSleepTime = atoi(argv[1]);
int numProd = atoi(argv[2]);
int numCons = atoi(argv[3]);
exit(0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: g++ compiler
2010-01-29 9:23 g++ compiler hossein shoghian
@ 2010-01-29 10:47 ` Axel Freyn
0 siblings, 0 replies; 4+ messages in thread
From: Axel Freyn @ 2010-01-29 10:47 UTC (permalink / raw)
To: gcc-help
Hi,
> please help me
> how to compiling this main with GCC, the GNU Compiler
> i use g++ -pthread -Wall main.cpp
> but don't pass argument
The compiler is right - your file is wrong;-)
>
> main.cpp
> int main(int argc, char *argv[]) {
> /* Verify the correct number of arguments were passed in */
> if(argc != 4) {
> fprintf(stderr, "USAGE:./main.out <INT> <INT> <INT>\n");
> }
> int mainSleepTime = atoi(argv[1]);
> int numProd = atoi(argv[2]);
> int numCons = atoi(argv[3]);
> exit(0);
> }
If you save the file with extension "cpp", GCC will treat it as a C++
code. However, in C++ you have to declare all functions before you use
them (e.g. atoi, exit, fprintf) and also all constants or variables
(like "stderr").
These are declared in header-files from the standard library - which you
have to include: So at the beginning of your file, you need
#include <cstdio>
#include <cstdlib>
with these two lines, the code should compile fine
HTH,
Axel
^ permalink raw reply [flat|nested] 4+ messages in thread
* g++ compiler
@ 2010-01-25 16:33 Rene-Clement Toussaint
2010-01-25 18:22 ` Axel Freyn
0 siblings, 1 reply; 4+ messages in thread
From: Rene-Clement Toussaint @ 2010-01-25 16:33 UTC (permalink / raw)
To: gcc-help
Dear GNU project:
I was trying to download the binary for Ubuntu Linux for G++ compiler via the OpenPKG link but the server could not connect to the ftp site. Is there an alternate location for me to download the g++ compiler for Ubuntu? I am running Ubuntu on my MacBook Pro via VMWare Fusion and would like to try to build the Google Gadgets. I started building them but I ran into an error saying that I was missing a component which I could get once I compiled the source code for Google Gadgets.
Sincerely,
Rene
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: g++ compiler
2010-01-25 16:33 Rene-Clement Toussaint
@ 2010-01-25 18:22 ` Axel Freyn
0 siblings, 0 replies; 4+ messages in thread
From: Axel Freyn @ 2010-01-25 18:22 UTC (permalink / raw)
To: gcc-help
Hello Rene,
> I was trying to download the binary for Ubuntu Linux for G++ compiler
> via the OpenPKG link but the server could not connect to the ftp site.
> Is there an alternate location for me to download the g++ compiler for
> Ubuntu?
I think, the easiest solution in order to get binary releases will be to
use the package manager of your distribution, e.g. on Ubuntu
sudo aptitude install g++
should be sufficient, if aptitude is correctly configured (= has access
to an Ubuntu mirror or a DVD).
HTH,
Axel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-29 10:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-29 9:23 g++ compiler hossein shoghian
2010-01-29 10:47 ` Axel Freyn
-- strict thread matches above, loose matches on Subject: below --
2010-01-25 16:33 Rene-Clement Toussaint
2010-01-25 18:22 ` Axel Freyn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).