Solved

linking, compiling (g++)

Posted on 1998-04-30
2
192 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now