Ask A Question
 
sail4evr
Fresh Boarder
Blog Posts: 0
Forum Posts: 10
Rating: 0ApplaudCriticize
Posted 1 Year, 1 Month ago #1
Hello. I am very new to linux, so my question is probably easy.

I am trying to compile a program against a statically linked fftw library. Here is what I have: /usr/local/include/fftw.h /usr/local/lib/libfftw.a /usr/local/lib/libfftw.la

fftw_print_plan in putils.c 00000b30 T fftw_print_plan

So this means that function fftw_print_plan is exported by the library, right?

Now, here is what I am trying to compile: string.c: #include <stdio.h> #include <fftw.h>

void main(int argc, char *argv[]) { fftw_print_plan(p);

/tmp/ccGZNEb9.o(.text+0x1a): In function &#039;main&#039;: : undefined reference to &#039;fftw_print_plan&#039; collect2: ld returned 1 exit status

I also tried it this way:

&lt;string.o was successfully cello. I am very new to linux, so my question is probably easy.

I am trying to compile a program against a statically linked fftw library. Here is what I have: /usr/local/include/fftw.h /usr/local/lib/libfftw.a /usr/local/lib/libfftw.la

fftw_print_plan in putils.c 00000b30 T fftw_print_plan

So this means that function fftw_print_plan is exported by the library, right?

Now, here is what I am trying to compile: string.c: #include <stdio.h> #include <fftw.h>

void main(int argc, char *argv[]) { fftw_print_plan(p);

/tmp/ccGZNEb9.o(.text+0x1a): In function 'main': : undefined reference to 'fftw_print_plan' collect2: ld returned 1 exit status

I also tried it this way:

<string.o was successfully created>

ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074 string.o(.text+0x1a): In function 'main': : undefined reference to 'fftw_print_plan'

I noticed that function 'fftw_print_plan' is defined in fftw.h as: extern void fftw_print_plan(fftw_plan plan);

I am not sure why it is defined as extern...

I also checked that the signature of the function matches in the code (putils.c)

I have no idea why this is not working. Any help whould be greatly appreciated...
Answer
Woodstock
Fresh Boarder
Blog Posts: 0
Forum Posts: 12
Rating: 0ApplaudCriticize
Posted 1 Year, 1 Month ago #2
I found the answer, so just want to let everybody know what it is: Instead of doing: gcc -lfftw string.c

I had to do: gcc string.c -lfftw

Apparently, the story here is that dependencies must come before the resources they depend on.
Answer

Spread the Word!

Four out of five users would recommend us to a friend. Shouldn't you?
Link to Us    Tell a Friend

Related Posts:

The Content on this site is provided for general information purposes only. Your use of the Content, or any part thereof, is made solely at Your own risk and responsibility. By entering this site you declare you read and agreed to its Terms, Rules & Privacy.
Copyright © 2006 - 2010 My Linux Gang