Solved

What's wrong with my makefile?

Posted on 2007-11-15
4
640 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

914 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

14 Experts available now in Live!

Get 1:1 Help Now