compiling under Linux w/ emacs and gcc (g++?)

Wanna understand E=mc2, English grammer, or maybe just build a computer? We can help!

Moderator: Moderators

Post Reply
BlackRider
Inmate
Posts: 966
Joined: Thu Jan 17, 2002 5:26 pm

compiling under Linux w/ emacs and gcc (g++?)

Post by BlackRider »

HELP!!! <!--EZCODE EMOTICON START :) --><img src=http://www.ezboard.com/images/emoticons/smile.gif ALT=":)"><!--EZCODE EMOTICON END--> <br><br>I've got a simple file, test.c:<br><!--EZCODE CODE START--><pre> #include <iostream>int main(){ std::cout << "Hello World\n"; return 1;}</pre><!--EZCODE CODE END--><br>and my makefile, makefile:<br><!--EZCODE CODE START--><pre> test.exe : gcc test.c -o test.exe</pre><!--EZCODE CODE END--><br>I've tried interchanging ".c" w/ ".cpp" (c vs c++, does it really make a difference?) and "gcc" w/ "g++"<br><br>With this makefile I get no errors and it even runs... just no output. (oh, and I'm running cygwin... not real linux, could that make a difference?)<br><br>All this is for school, so I'm pretty sure that it all must compilie w/ g++ (I have to turn in all source and header files and my makefile). I'm pretty clueless when it comes to all this linux stuff... ergo I seek understanding. <!--EZCODE EMOTICON START :) --><img src=http://www.ezboard.com/images/emoticons/smile.gif ALT=":)"><!--EZCODE EMOTICON END--> <br><br>So.... HELP!!! <p><!--EZCODE FONT START--><span style="color:red;font-size:large;">C</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:orange;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:green;font-size:large;">L</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:blue;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:indigo;font-size:large;">R</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:violet;font-size:large;">S</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:pink;font-size:xx-large;">!</span><!--EZCODE FONT END--></p><i>Edited by: <A HREF=http://pub141.ezboard.com/bxmenclan.sho ... ckRider</A> at: 4/6/03 8:24:53 pm<br></i>
User avatar
XMEN Gambit
Site Admin
Posts: 4122
Joined: Thu Nov 18, 1999 12:00 am

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Gambit »

Um, I think the return 1 is an error, isn't it? Isn't a 0 an error-free result?<br><br>Other than that, your cout may be routing the output somewhere else that you don't expect. I never used cout/cin much except for a couple chapters in class, so I'm not sure. But if gcc compiles it, and it runs, then your problem isn't with gcc.<br><br>I'm not sure what cygwin does with cout either, though in general it seems pretty reliable. <p><!--EZCODE IMAGE START--><img src="http://www.xmenclan.org/xmengambit.gif"/><!--EZCODE IMAGE END--><br>XMEN member<br>Card-carrying DTM<br>OKL Fish-napper<br><br>Though a program be but three lines long, someday it will have to be maintained.<br><!--EZCODE ITALIC START--><em> The Tao of Programming</em><!--EZCODE ITALIC END--></p><i></i>
Image
BlackRider
Inmate
Posts: 966
Joined: Thu Jan 17, 2002 5:26 pm

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by BlackRider »

hrmm...<br><br>Changing the return value didn't change anything... I don't even see why it would as it happens after the cout should have written to the screen. (that's why I put the "endl" in there... it flushes the couts to the screen, cout actually doesn't write anything until it comes across an "endl", "cin", or some other flush command)<br><br>I don't know, I'm going to have to get this working before the end of the week. (first program is due fri by 5pm EST)<br><br>maybe a reinstall would help... *shrug* HELP! <!--EZCODE EMOTICON START :p --><img src=http://www.ezboard.com/images/emoticons/tongue.gif ALT=":p"><!--EZCODE EMOTICON END--> <p><!--EZCODE FONT START--><span style="color:red;font-size:large;">C</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:orange;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:green;font-size:large;">L</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:blue;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:indigo;font-size:large;">R</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:violet;font-size:large;">S</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:pink;font-size:xx-large;">!</span><!--EZCODE FONT END--></p><i></i>
XMEN Ashaman DTM
Inmate
Posts: 2369
Joined: Mon Oct 02, 2000 12:09 am
Location: Silverdale, WA

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Ashaman DTM »

instead of cout, try an <!--EZCODE ITALIC START--><em>printf</em><!--EZCODE ITALIC END--> statement.<br><br>That should solve any problems with a bad <!--EZCODE ITALIC START--><em>cout</em><!--EZCODE ITALIC END--> implementation. To be honest, I only used cout/cin four times in my whole life.<br><br> <p><br><img src=http://www.xmenclan.org/avatars/ashaman2.jpg width=150 align=left><br><left><a href=http://www.dragontalonmercs.com>Dragon Talon Mercenary</a><br><a href=http://www.xmenclan.org>Member of the XMEN</a><br>Have a Nice Day!<br><br></left></p><i></i>
XMEN Ashaman DTM
Inmate
Posts: 2369
Joined: Mon Oct 02, 2000 12:09 am
Location: Silverdale, WA

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Ashaman DTM »

oh and what syntax are you using when you are at the command line?<br><br> <p><br><img src=http://www.xmenclan.org/avatars/ashaman2.jpg width=150 align=left><br><left><a href=http://www.dragontalonmercs.com>Dragon Talon Mercenary</a><br><a href=http://www.xmenclan.org>Member of the XMEN</a><br>Have a Nice Day!<br><br></left></p><i></i>
XMEN Ashaman DTM
Inmate
Posts: 2369
Joined: Mon Oct 02, 2000 12:09 am
Location: Silverdale, WA

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Ashaman DTM »

To check if it's really your gcc (or your implementation of it), try this code for your test.c:<br><br><!--EZCODE CODE START--><pre> #include <stdio.h>int main(){ printf("Hello World\n&quot<!--EZCODE EMOTICON START ;) --><img src=http://www.ezboard.com/images/emoticons/wink.gif ALT=";)"><!--EZCODE EMOTICON END--> ; return();}</pre><!--EZCODE CODE END--><br><br><br>(I think... heh, been learning FORTRAN so I'm a bit rusty. But just go with some simple C code instead of CPP so that you know it's either your makefile or your compiler, or your syntax when you call it.)<br> <p><br><img src=http://www.xmenclan.org/avatars/ashaman2.jpg width=150 align=left><br><left><a href=http://www.dragontalonmercs.com>Dragon Talon Mercenary</a><br><a href=http://www.xmenclan.org>Member of the XMEN</a><br>Have a Nice Day!<br><br></left></p><i></i>
BlackRider
Inmate
Posts: 966
Joined: Thu Jan 17, 2002 5:26 pm

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by BlackRider »

I use: make -k *shrug* <p><!--EZCODE FONT START--><span style="color:red;font-size:large;">C</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:orange;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:green;font-size:large;">L</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:blue;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:indigo;font-size:large;">R</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:violet;font-size:large;">S</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:pink;font-size:xx-large;">!</span><!--EZCODE FONT END--></p><i></i>
XMEN Ashaman DTM
Inmate
Posts: 2369
Joined: Mon Oct 02, 2000 12:09 am
Location: Silverdale, WA

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Ashaman DTM »

I think that's all you need...<br><br>for some reason, I keep thinking you need another switch in there... Hmm.<br><br>Don't you need something like:<br><br>make -k test.exe ??'<br><br><br>I know that the destination filename for the .exe is already stated in the makefile. I still seem to remember that you needed to put it on the command line as well.<br><br><br> <p><br><img src=http://www.xmenclan.org/avatars/ashaman2.jpg width=150 align=left><br><left><a href=http://www.dragontalonmercs.com>Dragon Talon Mercenary</a><br><a href=http://www.xmenclan.org>Member of the XMEN</a><br>Have a Nice Day!<br><br></left></p><i>Edited by: <A HREF=http://pub141.ezboard.com/bxmenclan.sho ... andtm>XMEN Ashaman DTM</A>&nbsp; <IMG SRC="http://theta_mercenaries.homestead.com/files/xmen.gif" BORDER=0> at: 4/6/03 9:30:05 pm<br></i>
BlackRider
Inmate
Posts: 966
Joined: Thu Jan 17, 2002 5:26 pm

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by BlackRider »

I found out what I was doing wrong... I had to run my program via: ./test intead of: test <!--EZCODE EMOTICON START :) --><img src=http://www.ezboard.com/images/emoticons/smile.gif ALT=":)"><!--EZCODE EMOTICON END--> <p><!--EZCODE FONT START--><span style="color:red;font-size:large;">C</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:orange;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:green;font-size:large;">L</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:blue;font-size:large;">O</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:indigo;font-size:large;">R</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:violet;font-size:large;">S</span><!--EZCODE FONT END--><!--EZCODE FONT START--><span style="color:pink;font-size:xx-large;">!</span><!--EZCODE FONT END--></p><i></i>
XMEN Ashaman DTM
Inmate
Posts: 2369
Joined: Mon Oct 02, 2000 12:09 am
Location: Silverdale, WA

Re: compiling under Linux w/ emacs and gcc (g++?)

Post by XMEN Ashaman DTM »

Aha!<br><br>Dork. <!--EZCODE EMOTICON START :p --><img src=http://www.ezboard.com/images/emoticons/tongue.gif ALT=":p"><!--EZCODE EMOTICON END--> <br> <p><br><img src=http://www.xmenclan.org/avatars/ashaman2.jpg width=150 align=left><br><left><a href=http://www.dragontalonmercs.com>Dragon Talon Mercenary</a><br><a href=http://www.xmenclan.org>Member of the XMEN</a><br>Have a Nice Day!<br><br></left></p><i></i>
Post Reply