Solved

What's wrong with my makefile?

Posted on 2007-11-15
4
650 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
ID: 20291392
Where are vector, free_vector and nrerror defined ?
0
 
LVL 1

Author Comment

by:meow00
ID: 20291426
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
ID: 20291470
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
ID: 20291689
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.

830 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