Solved

linking, compiling (g++)

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

744 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

11 Experts available now in Live!

Get 1:1 Help Now