• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Can't link against a library using Eclipse CDT (C++)... Something's wrong (Linux)

slugg

Diamond Member
Hey guys. So I'm working with some older code I wrote some time ago. I was originally going to port it to Windows, had some success, but quickly ran into other problems and decided to move back to a *nix environment. The original code compiled and ran just fine in the first try.

I'm running Ubuntu 11.10 and have chosen Eclipse as my IDE. When compiling and running the original code, everything is fine. Now I've installed the FFTW library (www.fftw.org) and can't seem to build anything.

I installed the library using aptitude in the terminal:
Code:
sudo apt-get install libfftw3-dev libfftw3-doc

The library definitely exists:
Code:
~$ g++ -lfftw3
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status

And I've added "fftw3" to my project's properties->C++ Linker->Libraries list in Eclipse.

The header file <fftw3.h> is found just fine.

When I go to compile, every single data type that is defined in the library fails to be defined, so essentially the compiler has no idea what to do.

I'm a bit stumped...

Here's one of the errors (they're all identical):
Line:
Code:
fftw_real a[M][N];
Error:
Code:
error: &#8216;fftw_real&#8217; was not declared in this scope

Here's some copy/pasta from the console in Eclipse:
Code:
**** Build of configuration Debug for project GerryIP ****

make -j all 
Building file: ../Source/ipTool.cpp
Invoking: GCC C++ Compiler
g++ -lfftw3 -I/home/gerry/Documents/_Digital_Image_Processing/gerryip_eclipse/Headers -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Source/ipTool.d" -MT"Source/ipTool.d" -o"Source/ipTool.o" "../Source/ipTool.cpp"
../Source/ipTool.cpp: In static member function &#8216;static void ipTool::transformDFT(Image&, Image&, ROI, FilterParams)&#8217;:
../Source/ipTool.cpp:42:2: error: &#8216;fftw_real&#8217; was not declared in this scope
../Source/ipTool.cpp:42:12: error: expected &#8216;;&#8217; before &#8216;a&#8217;
../Source/ipTool.cpp:43:12: error: expected &#8216;;&#8217; before &#8216;b&#8217;
../Source/ipTool.cpp:44:14: error: &#8216;result&#8217; was not declared in this scope
../Source/ipTool.cpp:46:2: error: &#8216;rfftwnd_plan&#8217; was not declared in this scope
../Source/ipTool.cpp:46:15: error: expected &#8216;;&#8217; before &#8216;pinv&#8217;
../Source/ipTool.cpp:47:15: error: expected &#8216;;&#8217; before &#8216;p&#8217;
../Source/ipTool.cpp:66:4: error: &#8216;a&#8217; was not declared in this scope
../Source/ipTool.cpp:72:3: error: &#8216;pinv&#8217; was not declared in this scope
../Source/ipTool.cpp:72:36: error: &#8216;FFTW_COMPLEX_TO_REAL&#8217; was not declared in this scope
../Source/ipTool.cpp:72:71: error: &#8216;rfftw2d_create_plan&#8217; was not declared in this scope
../Source/ipTool.cpp:73:38: error: &#8216;a&#8217; was not declared in this scope
../Source/ipTool.cpp:73:48: error: &#8216;b&#8217; was not declared in this scope
../Source/ipTool.cpp:73:55: error: &#8216;rfftwnd_one_complex_to_real&#8217; was not declared in this scope
../Source/ipTool.cpp:78:3: error: &#8216;p&#8217; was not declared in this scope
../Source/ipTool.cpp:78:32: error: &#8216;FFTW_REAL_TO_COMPLEX&#8217; was not declared in this scope
../Source/ipTool.cpp:78:70: error: &#8216;FFTW_IN_PLACE&#8217; was not declared in this scope
../Source/ipTool.cpp:78:83: error: &#8216;rfftw2d_create_plan&#8217; was not declared in this scope
../Source/ipTool.cpp:79:3: error: &#8216;a&#8217; was not declared in this scope
../Source/ipTool.cpp:79:78: error: &#8216;rfftwnd_one_real_to_complex&#8217; was not declared in this scope
../Source/ipTool.cpp:88:43: error: &#8216;a&#8217; was not declared in this scope
../Source/ipTool.cpp:103:24: error: &#8216;pinv&#8217; was not declared in this scope
../Source/ipTool.cpp:103:28: error: &#8216;rfftwnd_destroy_plan&#8217; was not declared in this scope
../Source/ipTool.cpp:105:24: error: &#8216;p&#8217; was not declared in this scope
../Source/ipTool.cpp:105:25: error: &#8216;rfftwnd_destroy_plan&#8217; was not declared in this scope
make: *** [Source/ipTool.o] Error 1

Halp 🙁
 
Last edited:
Does the fftw3 get compiled? It seems to me that settings aren't right and that it doesn't and you're just including the header.
 
Does the fftw3 get compiled? It seems to me that settings aren't right and that it doesn't and you're just including the header.

I'm not sure how to check this...

Thanks

edit: I don't see it getting compiled... should I? How can I make sure it gets compiled? It's a shared object, libfftw3.so, so why would it get compiled?
 
Last edited:
Solved... this is embarassing...

Key phrase here is older code. My code was originally written for version 2 of the library, but I installed version 3. Updated all my code to version 3 and all is good.

Lesson learned: GET SOME SLEEP!
 
Back
Top