Solved

What's wrong with my makefile?

Posted on 2007-11-15
4
637 Views
Last Modified: 2008-02-01
Hi experts,

I am trying to compile some codes, and the following is the makefile:
--------------------------------------
all: waveletTrans.exe

waveletTrans.exe: main.o wt1.o daub4.o pwt.o pwtset.o
        g++ -O3 main.o wt1.o daub4.o pwt.o pwtset.o -o waveletTrans.exe -lm

main.o: main.cpp
        g++ -c main.cpp

nrutil.o: nrutil.c nrutil.h
        g++ -c nrutil.c

wt1.o: wt1.c
        g++ -c wt1.c

daub4.o: daub4.c
        g++ -c daub4.c

pwt.o: pwt.c
        g++ -c pwt.c

pwtset.o: pwtset.c
        g++ -c pwtset.c

daub4.o pwt.o pwtset.o: nrutil.h

clean:
        rm -rf *o waveletTrans.exe
-----------------------------------------------
when I "make" it, I got the following errors:

g++ -c main.cpp
g++ -c wt1.c
g++ -c daub4.c
g++ -c pwt.c
g++ -c pwtset.c
g++ -O3 main.o wt1.o daub4.o pwt.o pwtset.o -o waveletTrans.exe -lm
daub4.o(.text+0x29): In function `daub4(float*, unsigned long, int)':
: undefined reference to `vector(long, long)'
daub4.o(.text+0x651): In function `daub4(float*, unsigned long, int)':
: undefined reference to `free_vector(float*, long, long)'
pwt.o(.text+0x29): In function `pwt(float*, unsigned long, int)':
: undefined reference to `vector(long, long)'
pwt.o(.text+0x3d8): In function `pwt(float*, unsigned long, int)':
: undefined reference to `free_vector(float*, long, long)'
pwtset.o(.text+0x7c): In function `pwtset(int)':
: undefined reference to `nrerror(char*)'
collect2: ld returned 1 exit status
make: *** [waveletTrans.exe] Error 1

---------------------------------------------
Does anyone know what I did wrong in the make file? (nrutil, daub4, wt1, pwt and pwtset are standard numerical recipes subroutines)

Thanks very much!
0
Comment
Question by:meow00
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
Where are vector, free_vector and nrerror defined ?
0
 
LVL 1

Author Comment

by:meow00
Comment Utility
They are in the nrutil.h and nrutil.c, and I put all these files in the same directory.
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 250 total points
Comment Utility
You forgot the nrutil.o file in the link step :

waveletTrans.exe: main.o wt1.o daub4.o pwt.o pwtset.o
        g++ -O3 main.o wt1.o daub4.o pwt.o pwtset.o -o waveletTrans.exe -lm

should be :

waveletTrans.exe: main.o nrutil.o wt1.o daub4.o pwt.o pwtset.o
        g++ -O3 main.o nrutil.o wt1.o daub4.o pwt.o pwtset.o -o waveletTrans.exe -lm
0
 
LVL 40

Expert Comment

by:evilrix
Comment Utility
Also, the order you link is important, you list dependers before dependees. So, if A depends on B you must link to A before B so that the linker knows what symbols to pull our of B for A.

It's counter intuitive and catches out a lot of noob g++ers :)

-Rx.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 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

11 Experts available now in Live!

Get 1:1 Help Now