Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Interpreting Makefile to build library

Posted on 2004-08-16
2
Medium Priority
?
295 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 86

Accepted Solution

by:
jkr earned 2000 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

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

885 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