Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-28-2005, 09:30 PM   #1
Registered: Jan 2002
Location: NY
Posts: 42

Rep: Reputation: 15
gcc header files and cpp files?

ive been looking and cant find any way to compile and link header files with its counterpart cpp file.

IE: i have Date.h used in Date.cpp, and cant seem to link them together, let alone compile them, how can i go about doing this?
Old 02-28-2005, 09:45 PM   #2
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ok, first thing you should do, use g++ instead of gcc.

#include "Date.h" in your Date.cpp file.

g++ -Wall -o Date Date.cpp
Old 02-28-2005, 11:14 PM   #3
Registered: Jan 2002
Location: NY
Posts: 42

Original Poster
Rep: Reputation: 15
ah you rock, totally worked, thanks alot
Old 03-01-2005, 01:14 AM   #4
Registered: Jan 2002
Location: NY
Posts: 42

Original Poster
Rep: Reputation: 15
one more question i hope to get answered, what flag(s) other than -Wall and -o do i need if the cpp file in question doesnt have a main? when using -Wall and -o i got errors about main, threw one in there and it worked like a charm, but what if i dont want to use main? the program originally didnt have one, and since it was given to me by a professor i know it works and what not. any clues to have it not complain about a missing main() ?



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
Including header files and source files for classes Feenix Programming 8 09-28-2005 10:53 AM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 02:24 AM
compiling .h and .cpp files with g++ arnab_be Linux - Newbie 2 03-03-2004 02:23 PM
gcc won't recognise local header files surio Linux - Software 0 09-10-2003 05:02 PM
Problems when trying to compile cpp files using qt headers siphiuel Linux - Software 2 08-10-2003 07:10 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:29 PM.

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