0

I am making a c++ shared library to include in an IDL program on linux. I'm using call_external and that is all working fine. However I am used to dynamically linking fftw in the code I wish to include in the library. The code compiles into a library file fine but when I try to run it the idl program crashes with the error 'symbol lookup error.. undefined symbol: fftw_plan...'

I suspect it is due to the dynamic link not working in the shared library but am not sure how to deal with that. I've looked at the fftw documentation and IDL help. I've tried googling the subject but it is a little niche.

So in my makefile I'm linking the shared library using 'FFTWFLAG=-lfftw3 -lm' And making the library file with

OneTurn.so: $(OBJECTS)    
$(CC) $(INCFLAGS) $(LDFLAGS) $(FFTWFLAG) -o OneTurn.so     $(OBJECTS)"

I'm then calling the c++ library from idl with

IDL> a=double(1)                                                             
IDL> t=call_external('OneTurn.so', 'OneTurn', a, a, /D_VALUE, /UNLOAD,/CDECL)    
Making bunch
/usr/local/harris/idl87/bin/bin.linux.x86_64/idl: symbol lookup error: ./OneTurn.so: undefined symbol: fftw_plan_r2r_2d    

If I don't include the fftw stuff everything works as expected.

Update
I had to pass the fftw linker arguments through to the shared library with -Wl,-lfftw3,lm.
This now compiles and runs however the fftw code still does not work! Working on it...
Thanks for your answers and suggestions so far! Update 2 I was being a muppet: hadn't included a bit of code for one function, that was the undefined symbol... I didn't recognise it as it had a pre- and post-fix. Thanks for your help!

1 Answers1

0

I haven't done this with C++ recently. Could there be a name mangling problem? Look at the .so file with nm to see make sure you have the right symbols and to check their names.

mgalloy
  • 2,356
  • 1
  • 12
  • 10