Solved

Interpreting Makefile to build library

Posted on 2004-08-16
2
289 Views
Last Modified: 2008-03-10
Hello all;

I am curious if could give me pointers on how to use a makefile to interpret what components need to be included in a project in order to build a dll or exe.

The code is C code and I would like to build it into Windows dll.

This is from the Mpg123 source code.

Thanks in advance
RJ


CC=gcc
CFLAGS=-Wall -g -DLAYER1 -DLAYER2 -DLAYER3

all: mpglib


*.o: mpg123.h mpglib.h

mpglib: layer1.o layer2.o common.o dct64_i386.o decode_i386.o layer3.o tabinit.o interface.o main.o
      $(CC) -o mpglib \
            common.o dct64_i386.o decode_i386.o layer3.o \
            tabinit.o interface.o main.o layer2.o layer1.o -lm

clean:
      rm *.o mpglib


0
Comment
Question by:RJSoft
2 Comments
 
LVL 11

Expert Comment

by:avizit
ID: 11816549
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 11816731
In

*.o: mpg123.h mpglib.h

mpglib: layer1.o layer2.o common.o dct64_i386.o decode_i386.o layer3.o tabinit.o interface.o main.o
    $(CC) -o mpglib \
         common.o dct64_i386.o decode_i386.o layer3.o \
         tabinit.o interface.o main.o layer2.o layer1.o -lm

clean:
    rm *.o mpglib

The rule for building mpglib is made dependant on the object files, which suggest that there are layer1.cpp layer2.cpp common.cpp dct64_i386.cpp decode_i386.cpp layer3.cpp tabinit.cpp interface.cpp and main.cpp (the extensions might be .cc, .C or .cxx though). I think you left out the rule that builds these .o files from the source files.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

860 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