makefile


record
03-16-2005, 02:35 PM
Hi,

although the question was asked two years ago for C (http://www.nr.com/forum/showthread.php?s=&threadid=184&highlight=makefile)
, maybe someone has now an answer:

I try to compile a simple C++ application which uses two functions of the numerical recipes (bessj0 and powell) with this command:

g++ appl.c -L. -lNR_C++ -o appl

, but the functions are not known ("undefined reference to NR: powell...")

What's the reason for that?



Thanks.

Saul Teukolsky
03-17-2005, 12:26 PM
Make sure appl.c has #include "nr.h". Also, somewhere you need to link in the recipes you're using, powell and bessj0. So the g++ line needs powell.cpp or powell.o or a library you've created of the recipes, eg -lnumrecipes.

record
03-17-2005, 07:18 PM
But that's exactly what I'm doing!

See: "-lNR_C++" in my first post.


But this is not working...

Saul Teukolsky
03-17-2005, 07:44 PM
Try to compile with
g++ appl.c powell.cpp bessj0.cpp

If this works, somehow your library hasn't been made properly.

record
03-17-2005, 08:43 PM
OK,

It's working now.
Had some other issues but after linking all necessary files (6), it seems to work.

Thanks.