LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-18-2010, 04:48 PM   #1
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Rep: Reputation: 0
compiling using the terminal


Hi there

I'm having some trouble compileng my program in the terminal.

I read the tutorial on this site, but it didn't really help much

i have 8 files that i have written;

AIsnake.cpp
Snake.hpp
AIsnake.cpp
Snake.hpp
food.cpp
food.hpp
GameEvent.cpp
Gameevent.hpp

I use the stl list header, and several headers that are contained in a file called prg.

could someone please tell me how to compile this?

thanks

ES
 
Old 05-18-2010, 05:13 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by elsparko View Post
Hi there

I'm having some trouble compileng my program in the terminal.

I read the tutorial on this site, but it didn't really help much

i have 8 files that i have written;

AIsnake.cpp
Snake.hpp
AIsnake.cpp
Snake.hpp
food.cpp
food.hpp
GameEvent.cpp
Gameevent.hpp

I use the stl list header, and several headers that are contained in a file called prg.

could someone please tell me how to compile this?

thanks

ES
What command lines have you tried and based on which tutorial(s) ?
 
Old 05-18-2010, 05:35 PM   #3
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
http://www.linuxquestions.org/linux/...ams_on_Linux_0

i used this tutorial, but it doesn't really go into much detail
 
Old 05-18-2010, 06:21 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by elsparko View Post
http://www.linuxquestions.org/linux/...ams_on_Linux_0

i used this tutorial, but it doesn't really go into much detail
What about the second part of my question, i.e. what command lines did you use ?
 
Old 05-18-2010, 06:41 PM   #5
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
this is what i typed into the terminal

g++ -ansi -pedantic main.cpp gameevent.cpp gameevent.hpp etc etc for all the files i stated above -o snakegame

not sure if this is what your asking about though...
 
Old 05-18-2010, 06:44 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by elsparko View Post
this is what i typed into the terminal

g++ -ansi -pedantic main.cpp gameevent.cpp gameevent.hpp etc etc for all the files i stated above -o snakegame

not sure if this is what your asking about though...
So, what were the warning/error messages if any ?
 
Old 05-18-2010, 06:48 PM   #7
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
I'm sorry, I can't remember.

I had to leave the programming Lab (it's 1am here) and I'm using windows at home.

should what I typed have worked? assuming everything is write with the code?
 
Old 05-18-2010, 06:51 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by elsparko View Post
I'm sorry, I can't remember.
...
So, then don't start a thread. I.e. if you have a problem, you have to be able to exactly show what the problem is. Otherwise the thread looks like translated literally from Russian saying: "Bring me something I don't know what, process that something I don't know how".
 
Old 05-18-2010, 07:01 PM   #9
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
I was still in the lab when I started the thread, I have since left.

I'm sorry, I thought there would be a standard command for grouping all the different files I need into on

I know the g++ "-ansi -pedantic" is right and I know the "-o Snakegame" is the name of the output file. The only thing i needed to know was how I should put my file names in, whether just putting them in one big list was right, or whether there was something similar to the "-o" that needed to be added
 
Old 05-18-2010, 07:26 PM   #10
fruttenboel
Member
 
Registered: Jul 2008
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by elsparko View Post
I was still in the lab when I started the thread, I have since left.

I'm sorry, I thought there would be a standard command for grouping all the different files I need into on

I know the g++ "-ansi -pedantic" is right and I know the "-o Snakegame" is the name of the output file. The only thing i needed to know was how I should put my file names in, whether just putting them in one big list was right, or whether there was something similar to the "-o" that needed to be added
You need a MAKE file....
 
Old 05-18-2010, 07:34 PM   #11
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,266

Rep: Reputation: 99
Quote:
Originally Posted by Sergei Steshenko View Post
Russian saying: "Bring me something I don't know what, process that something I don't know how".
Nice...
 
Old 05-18-2010, 08:46 PM   #12
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by elsparko View Post
I was still in the lab when I started the thread, I have since left.

I'm sorry, I thought there would be a standard command for grouping all the different files I need into on

I know the g++ "-ansi -pedantic" is right and I know the "-o Snakegame" is the name of the output file. The only thing i needed to know was how I should put my file names in, whether just putting them in one big list was right, or whether there was something similar to the "-o" that needed to be added
-ansi -pedantic is superfluous at this point; it just makes things confusing. Leave that stuff out and use -Wall instead, which will give you a warning about everything the compiler is capable of warning about (good for mitigating bugs.) When you compile again, please post all the output and the source file(s).

In my experience, one first perfects his or her source files, then learns what's wrong with them from the compiler. If you haven't compiled your code before, despite it looking correct, in all likelihood you've messed something up. It works that way even for experienced programmers.
Kevin Barry
 
Old 05-18-2010, 09:16 PM   #13
elsparko
LQ Newbie
 
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
thanks for the tips ta0kira.

I know my source code deffinatly works as I made it in an IDE and have compiled it in there, but my assesment says i need to say

"how to compile and evoke the code on the linux command line"

Thats the only problem I'm having :-S
 
Old 05-18-2010, 09:31 PM   #14
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,455

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by elsparko View Post
this is what i typed into the terminal

g++ -ansi -pedantic main.cpp gameevent.cpp gameevent.hpp etc etc for all the files i stated above -o snakegame
You shouldn't give the .hpp files to the compiler.
Code:
g++ -Wall *.cpp -o snakegame
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
not screen-blanking in terminal - what sets the idle timeout on monitor for terminal stardotstar Linux - Hardware 2 08-14-2011 05:46 AM
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 10:34 AM
c++ vtk code compiling from terminal njac Programming 3 05-07-2008 10:11 PM
Compiling and launching java from the terminal marcoguillen Linux - Software 7 03-25-2007 03:43 AM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 02:45 PM


All times are GMT -5. The time now is 09:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration