Solved

Interpreting Makefile to build library

Posted on 2004-08-16
2
286 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 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

15 Experts available now in Live!

Get 1:1 Help Now