Solved

Interpreting Makefile to build library

Posted on 2004-08-16
2
292 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
[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 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

623 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