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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-18-2010, 04:48 PM
|
#1
|
|
LQ Newbie
Registered: May 2010
Posts: 6
Rep:
|
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
|
|
|
|
05-18-2010, 05:13 PM
|
#2
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by elsparko
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) ?
|
|
|
|
05-18-2010, 06:21 PM
|
#4
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by elsparko
|
What about the second part of my question, i.e. what command lines did you use ?
|
|
|
|
05-18-2010, 06:41 PM
|
#5
|
|
LQ Newbie
Registered: May 2010
Posts: 6
Original Poster
Rep:
|
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...
|
|
|
|
05-18-2010, 06:44 PM
|
#6
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by elsparko
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 ?
|
|
|
|
05-18-2010, 06:48 PM
|
#7
|
|
LQ Newbie
Registered: May 2010
Posts: 6
Original Poster
Rep:
|
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?
|
|
|
|
05-18-2010, 06:51 PM
|
#8
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by elsparko
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".
|
|
|
|
05-18-2010, 07:01 PM
|
#9
|
|
LQ Newbie
Registered: May 2010
Posts: 6
Original Poster
Rep:
|
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
|
|
|
|
05-18-2010, 07:26 PM
|
#10
|
|
Member
Registered: Jul 2008
Posts: 270
Rep:
|
Quote:
Originally Posted by elsparko
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....
|
|
|
|
05-18-2010, 07:34 PM
|
#11
|
|
Senior Member
Registered: May 2007
Distribution: RHEL, CentOS
Posts: 1,232
Rep:
|
Quote:
Originally Posted by Sergei Steshenko
Russian saying: "Bring me something I don't know what, process that something I don't know how".
|
Nice... 
|
|
|
|
05-18-2010, 08:46 PM
|
#12
|
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 2,967
Rep: 
|
Quote:
Originally Posted by elsparko
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
|
|
|
|
05-18-2010, 09:16 PM
|
#13
|
|
LQ Newbie
Registered: May 2010
Posts: 6
Original Poster
Rep:
|
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
|
|
|
|
05-18-2010, 09:31 PM
|
#14
|
|
Senior Member
Registered: Nov 2005
Distribution: Debian
Posts: 2,023
|
Quote:
Originally Posted by elsparko
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:55 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|