Problem with makefile, how to use the -lm oh this?

This is a discussion on Problem with makefile, how to use the -lm oh this? within the C Programming forums, part of the General Programming Boards category; Hi, My current makefile is like this: Code: npn-paint : npn-paint.o func.o draw.o gcc -o npn-paint npn-paint.o func.o draw.o npn-paint.o ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    158

    Problem with makefile, how to use the -lm oh this?

    Hi,
    My current makefile is like this:
    Code:
    npn-paint : npn-paint.o func.o draw.o
    	gcc -o npn-paint npn-paint.o func.o draw.o
    
    npn-paint.o : npn-paint.c func.h draw.h
    	gcc -O2 -c npn-paint.c
    
    func.o : func.c func.h
    	gcc -O2 -c func.c
    
    draw.o : draw.c draw.h
    	gcc -O2 -c draw.c
    but if I "make" it like this, I'll get a bunch of errors cause I use functions like pow(), sqrt(), floor(), etc... I know I need to add the -lm switch but I don't know where... I tried to add them before the -O2 switch, ie: "gcc -lm -O2 -c draw.c" but I keep getting this annoying error: "gcc: -lm: linker input file unused because linking not done".

    The files draw.c, func.c and npn-paint.c all have "#include <math.h>", just so you know...

    Can you help me finish this makefile? Please... This is a school project and I need to have it uploaded until monday but I haven't yet finished coding all the stuff, but I need to have this working first...

    Hope someone can help me out as soon as possible. Thanks for your time reading this...

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    158
    Sorry people, my bad... I just added the -lm to the first gcc instruction and I was missing #include "func.h" on draw.c.

    Working now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with Makefile separator
    By luca in forum Tech Board
    Replies: 6
    Last Post: 01-15-2007, 10:20 AM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21