5

I am trying to compile a program with Netbeans (g++) that inlcudes Aquila, an open source libary. I followed the installation instructions.

But when trying to compile a small test program, I get this error

In function `Aquila::OouraFft::fft(double const*)':OouraFft.cpp:(.text+0x24f):
undefined reference to `cdft'

OouraFft.h:

#include "Fft.h"

extern "C" {
    void cdft(int, int, double *, int *, double *); //prototypes of offending function
    void rdft(int, int, double *, int *, double *); //second one.
}

The C file in the libs folder contains the definition of the functions.

The line that cause the actual error in OouraFft.cpp:

// let's call the C function from Ooura's package
    cdft(2*N, -1, a, ip, w);

So I am thinking the external C file is not being linked with the project but included all the directories in the project directory. I have been googling for hours and can't figure it out.

donquixote
  • 411
  • 2
  • 16
  • have header file for that C file? yes then try with `extern "C" { #include "MyCHeader.h" }` – Jayesh Bhoi Feb 26 '14 at 07:03
  • 3
    Actually this looks like a link error not a compile error. Have you remembered to add a link option for your library? EG if it's called `libfft` you will want to add `-lfft` to the link line. Even if you have a single source file and think you are just compiling, you will be linking (perhaps as part of the compile step) and need to specify which libraries to link to. – abligh Feb 26 '14 at 07:35

2 Answers2

5

Up to git version 6f5d6b, Aquila's CMake config will generate static library by default. You should copy /path-to-your-build-tree/lib/libOoura_fft.a to /path-to-your-install-dir/lib/, and link it to your test program.

Answeror
  • 430
  • 3
  • 13
  • 2
    You'll also have to make sure ooura_fft is linked within your library...I ran into the same problem and thought the ooura_fft stuff would be included within libAquila.a. So copy libOoura_fft.a to your lib directory, and include -looura_fft in your makefile. – Chris Vandevelde Jun 18 '14 at 19:27
1

As Answeror said you need to put libOoura_fft.a in the right place (/usr/local/lib is the default for libAquila.a).

You also need to link to it as Chris Vandevelde said, but you should link to -lOoura_fft (first "O" capital). You should be linking with -lAquila as well

Just wanted to clarify.