Solved

linking, compiling (g++)

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setting nameservers after res_init fails doing res_query 2 118
FMX TCameraComponent Problem 2 92
What is sub-make ? 2 87
I could not set window to top 4 40
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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

685 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