Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have got below error message when I tried running a program.

undefined reference to `fftw_malloc'
f11.c:(.text+0x24d): undefined reference to `fftw_malloc'
f11.c:(.text+0x260): undefined reference to `fftw_malloc'
f11.c:(.text+0x273): undefined reference to `fftw_malloc'
f11.c:(.text+0x286): undefined reference to `fftw_malloc' 

and so on.

what is the problem exactly? It is running fine with 11.04 version, please help!


i reinstalled the gcc, but problem still exist i used a command like this: g++ -lfftw3 -lcpgplot -lpgplot f11.c. the out puts are: undefined reference tofftw_malloc' f11.c:(.text+0x260): undefined reference to fftw_malloc' f11.c:(.text+0x273): undefined reference tofftw_malloc' f11.c:(.text+0x286): undefined reference to `fftw_malloc

undefined reference to cpgbeg' f11.c:(.text+0x2d3c): undefined reference tocpgpage' f11.c:(.text+0x2d49): undefined reference to cpgsch' f11.c:(.text+0x2d71): undefined reference tocpgsvp' please give me suggestion.

share|improve this question
    
What are you trying to compile, How are you trying to compile, did you followed the always included instructions?, do you have instructions?, need more info. –  Uri Herrera Sep 24 '12 at 5:06
    
the basic compiling commands are ./configure then make and then sudo make install that last command requiers you to typ in your password! –  blade19899 Sep 24 '12 at 7:58
    
What package are you trying to install? –  blade19899 Sep 25 '12 at 8:07
add comment

2 Answers

up vote 2 down vote accepted

Ok, so Ubuntu package libfftw3-dev is installed, which is obvious as you would get an error message

/usr/bin/ld: cannot find -lfftw3

instead if the library was not found by the linker.

There is a hint in the gcc linker documentation saying that the order of files given to the linker is important. Citing from the documentation

It makes a difference where in the command you write this option [-l library]; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.

In your case, no functions referenced by f11.c are being loaded from the specified library, since they are listed before f11.c. This is somewhat counterintuitive, but I am pretty sure that compiling with

g++ f11.c -lfftw3 -lcpgplot -lpgplot

will be the solution to your problem. You may need to check the order of the libraries though, in case they depend on each other. In general, if (file or library) x depends on (file or library) y, make sure that x is listed before y on the command line given to the linker.

share|improve this answer
    
yes, i installed that package. –  user92371 Sep 26 '12 at 1:58
    
@msPeachy - I have edited my post so that now it can be regarded a valid answer. Your comment is contradictory though: You suggested that I better used a comment on the authors post, but noted that it was impossible for me to do so, given my reputation. Huh? –  Martin Dirichs Sep 28 '12 at 8:28
    
@MartinDirichs my comment said once you have sufficient reputation. Anyway, since you've modified your answer, I would now delete my previous comment. Thank you. –  Peachy Sep 28 '12 at 9:57
    
thank you very much, it gets work, you teach me a lot.. –  user92371 Sep 28 '12 at 12:31
    
@user92371 I am glad my answer was helpful. Please consider making it the accepted solution. –  Martin Dirichs Sep 28 '12 at 13:17
add comment

it seems that you are missing dynamic libraries of some kind. probably standard C libs and fast fourier transform. Try to reinstall your compiler - it might help. and the second thing to do it to create once more your fast fourier lib that you are trying to link.

share|improve this answer
    
thank you, let me try. but actually it is run well in ubuntu 11.04 –  user92371 Sep 25 '12 at 7:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.