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-08-2004, 04:47 PM   #1
crisponions
LQ Newbie
 
Registered: Feb 2002
Distribution: RedHat (currently 9.0)
Posts: 29

Rep: Reputation: 15
GCC newbie compile question


This is probably a really easy question , but for the life of me I cannot find the answer. I am in the process of teaching myself c++ and I have reached the point in my book where we are creating custom header files etc. How do I compile these? e.g I have sales1.h, sales1.cpp and myProgram.cpp what is the syntax to compile this from the command line. Thanks
 
Old 07-08-2004, 05:00 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
g++ sales1.cpp myProgram.cpp -o runme

One or both of sales1.cpp or myProgram.cpp should have: #include "sales1.h".

'runme' can be called whatever. It's the finished, linked binary that will be produced.
 
Old 07-08-2004, 07:16 PM   #3
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
You don't compile the header files (I'm sure you knew that) and if sales.cpp is supposed to be a library that you could use with multiple programs you can compile it to object:
gcc -c sales.cc -o sales.o

and then do

gcc sales.o myprogram.cc -o myprogram

but what the guy above said is fine also.
 
  


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
gcc- newbie question babambar Linspire/Freespire 3 11-09-2005 05:31 PM
Compile with GCC occ Solaris / OpenSolaris 6 10-29-2004 10:19 AM
gcc 3.4.1 want not to compile, but 3.2.2 does BorisB Linux - Software 3 07-27-2004 06:53 PM
How to compile GCC if you don't have GCC? khermans Linux - Software 13 05-12-2004 06:42 PM
mkinitrd doesnt exist in slackware? Newbie kernel compile question! nmoog Slackware 3 01-08-2004 06:22 PM

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

All times are GMT -5. The time now is 08:22 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