Solved

What's wrong with my makefile?

Posted on 2007-11-15
4
658 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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…
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 clear a vector as well as how to detect empty vectors in C++.

690 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