Solved

linking, compiling (g++)

Posted on 1998-04-30
2
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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.

739 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