• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Seperate implementation/header files

Hi,
I'm using g++ and can't find the right flags/procedure to compile/use a class I wrote with seperate header and implementation files.
0
bod_1
Asked:
bod_1
  • 2
  • 2
1 Solution
 
sosedadaCommented:
Is this a template class?
0
 
nbellCommented:
The following is a make file which can be used on a UNIX system to compile with g++ (you can of course issue the same commands from the command line):

# make file comment

executablefilename: source1.o source2.o cpstring.o
      g++ -o executablefilename source1.o source2.o cpstring.o
source2.o: source2.cpp
      g++ -c source2.cpp
source1.o: source1.cpp
      g++ -c source1.cpp
cpstring.o: cpstring.cpp
      g++ -c cpstring.cpp


as far as the header files go, you will have them #included in your .cpp files.
0
 
nbellCommented:
As an addendum to my answer, if you decide to use a make file they must follow a strict format which includes tabs which did not show up in my copy/paste.
0
 
sosedadaCommented:
The above makefile is very limited.  It doesn't handle include files in different directories, libraries, templates, or any compiler options.
0
 
bod_1Author Commented:
Ah, that's perfect.
Thanks nbell.
sosedada, no, it's just a regular class.  Before I asked the question I waded through a few of the previous ones and it saw something about template classes being some sort of a special exception but nope, just a plain old class.
Thanks guys.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now