Solved

linking, compiling (g++)

Posted on 1998-04-30
2
194 Views
Last Modified: 2010-04-10
I am using g++ as my compiler and I have header files associated with their respective source files. When I compile the source files do I have to throw and special flags to tell the compiler that the headers are associated witht the file.  For example, how would I compile the following files and run the program.

Mamal.h    Dog.h
Mamal.cpp  Dog.cpp
Program.cpp (has #define "Dog.h" in file)
                     



0
Comment
Question by:dkurry
2 Comments
 
LVL 2

Expert Comment

by:kellyjj
ID: 1169458
I am not sure about g++, but I would think that it should be able to compile the files.  You proboly have to first compile the dog and mamal files into Obj files then link them.
0
 

Accepted Solution

by:
shepard earned 50 total points
ID: 1169459
As long as the files have the required header files, then no special flags are needed to compile the program.  In this case, the steps to compile would be:
 g++ mamal.cpp -o mamal.o
 g++ dog.cpp -o dog.o
 g++ -o animals mamal.o dog.o

One other option is:
 g++ -o animals mamal.cpp dog.cpp
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Focus not getting shifted out of  editbox 2 63
C language IDE – Compilers installation 14 71
FMX StringGrid1->Canvas->FillRect Problem 3 153
Safe conversion? 4 68
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question