LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-30-2008, 07:39 PM   #1
orfiyus
Member
 
Registered: May 2006
Posts: 42

Rep: Reputation: 15
Need c++ compiling help


Hows it goin?

Im doing a c++ tutorial. I am using g++ on a command line and vim as my text editor. Anyway I am up to the chapter with headers implementation of the headers and driver programs. What is the command that I type so that I can get all 3 files compiled all at once (linking?) ?

Thanks
 
Old 07-30-2008, 09:03 PM   #2
orfiyus
Member
 
Registered: May 2006
Posts: 42

Original Poster
Rep: Reputation: 15
nm found it.

Quote:
g++ file1.cpp file2.cpp -o executable_file
 
Old 07-31-2008, 09:00 AM   #3
Nauntilus
Member
 
Registered: Oct 2005
Distribution: All of them
Posts: 140

Rep: Reputation: 18
You know, it would actually be easier with a makefile. I am not sure how you create the file in vim, but just call it "makefile" it doesn't need an extension and this would be what it would look like.

Date: DateTest.o CDate.o
g++ DateTest.cpp CDate.cpp -o Date
DateTest.o: DateTest.cpp CDate.cpp
g++ -c DateTest.cpp
CDate.o: CDate.cpp CDate.h
g++ -c CDate.cpp

Where DateTest is your test file, or main program file, and CDate is your class definition file and CDate.h is your class header file. The Date: in the top left is the name of the executable file that will be left over. Then what you do after you have modified this file to match your files, the command you use is
Quote:
make -f makefile
and it will create a file with the name that you put in the top left corner. And to run your program you would type ./Date unless linux is automatically set up to look in the file you are coding in.
 
Old 07-31-2008, 12:04 PM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Nauntilus View Post
You know, it would actually be easier with a makefile.
It could be even easier with scons.
 
  


Reply



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
Compiling QT eqxro Linux - Software 2 11-08-2004 01:51 PM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM
Compiling in ACPI support on Compaq 2135CA (system crashes while compiling) Dag Linux - Laptop and Netbook 20 07-30-2004 07:56 PM
need help compiling bboy_au Programming 1 10-24-2003 08:33 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration