-
problem with the library
I need to use the FFTW to generate fourier transforms.
The "fftw-3.1.1 " has been installed already and it is in the location "/compiler/ fftw/fftw-3.1.1"..the "fftw3.h" is in this directory.
In my program I have # included the exact path to the ".h" file.
Still none of l the FFTW related commands in my c program,are being recognised. errors point to each of them after compilation.Can anyone help.I am sure, there is no problem with the fftw3 compiler or the commands that i have used.
I am using GCC...
-
What errors are you getting exactly? Are you getting compilation errors, or linker errors? (Sounds like probably the latter.) Are you linking with fftw?
-
This problem was with my comp at work, so dont clearly remember the exact words.
It was mostly like "cannot find FFTW_DOUBLE " ,i think.I will confirm it in about 8hrs from now..sorry about that.
Do I need to link it also?i mean even after # including the location that contains the .h file.
if i have to link it, what exactly shud i do? I dont have the permissions to transfer the file in "/compiler/fftw " to "/usr/local/include" ..that's where all my standartd lib files are stored.
the problem shud be linker errors..I have used the sample prog given in the FFTW homepage itself.They shud not be causing any problem.
-
Unfortunately, this computer doesn't have WinZIP so I can't tell what files are part of the distribution.
Add the path to the lib files with -L, add the lib files with -l, and add the include directory with -I:
Code:
gcc -o file file.c -L ~/libraries/fftw/lib -lfftw -I ~/libraries/fftw/include
[edit] For every lib*.a in fftw/lib, add a -l*. [/edit]
-
OK, will try that ..
this was one of the errors I got after i compiled :
Code:
prog6.o(.text+0x70): In function `main':
: undefined reference to `fftw_malloc'
the rest of the errors are also similar..All of them point to the various FFTW commands i have used in my program
And can u please elaborate on that part within the " edit " in ur post..
-
Actually,I am supposed to use FFTW in a parallel environment..I am using a hpc cluster to run my progs. I am using fftw-3.1.1 that has already ben installed. Will this work even for my parallel progs? Is there any version of FFTW that is meant particularly for parallel environment?
And, if i have understood ur suggestion correctly is this right :
1. the path to the lib files is
Code:
/compiler/fftw-3.1.1/lib
This dir again contains three files :
Code:
libfftw3.a libfftw3.la pkgconfig
so, does it suffice if the path to the lib points to this dir alone ?
2. the path to my include files is :
Code:
/compiler/fftw-3.1.1/include
this dir again contains fftw3.f and fftw3.h
I did that and this is what i got afte r compilation :
Code:
/usr/bin/ld: cannot find -lfftw
collect2: ld returned 1 exit status
And if i removed "-lfftw" I got the same set of messages that i was getting initially..
please help
-
Try passing "-L /compiler/fftw-3.1.1/lib -lfftw3" when you link.
Read/Search for a bit on compiling/linking, the difference between the two, and how libraries come into play.
For gcc, -lmyfile translates to libmyfile.a. So, libfftw3.a would be -lfftw3. -L [somedirectory] specifies an additional location to look for library files.
-
OK, I will look it up.
I tried this :
mpicc prog6.c -L ~/compiler/fftw-3.1.1/lib -lfftw3 -I ~/compiler/fftw-3.1.1/include/
and i still got
/usr/bin/ld: cannot find -lfftw3
collect2: ld returned 1 exit status
-
As, i had mentioned earlier.. i am working on the cluster
I tried downloading the fftw on my machine.. and it worked ..
the lib and include files are present in /usr/local/lib and /usr/local/include
and the command at the prompt was :
gcc test.c -L ~/usr/local/lib -lfftw3 -I ~/usr/local/include
..
Is it necessary that the lib and include have to be present in "/usr/local"
as i said earlier , on the hpc ,it is saved in the location " /compiler/fftw3-1.1."
does the problem lie with the location of thse files ??
-
well, I had the fftw copied to /usr/include on hte cluster.. it still does not help my cause.. iget the same message : " cannot find -lfftw3 "
somebody please help
-
Could you paste (in code tags) what you get when you do
gcc -v test.c -L ~/usr/local/lib -lfftw3 -I ~/usr/local/include
The -v option shows verbosely what the compiler actually tried to do.
-
this is what happened on the hpc:
Code:
mpicc -v prog6.c -L ~/compiler/fftw-3.1.1/lib -lfftw3 -I ~/compiler/fftw-3.1.1/include
Reading specs from /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=x86_64-unknown-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/cc1 -lang-c -v -I /home/krisc86/compiler/fftw-3.1.1/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=x86_64 -Amachine=x86_64 -D__x86_64 -D__x86_64__ -D__SIZE_TYPE__=unsigned long int -D__PTRDIFF_TYPE__=long int -D__tune_athlon__ -D__tune_athlon_sse__ -D__LONG_MAX__=9223372036854775807L -D__LP64__ -D_LP64 prog6.c -quiet -dumpbase prog6.c -version -o /tmp/ccVO2XCC.s
ignoring nonexistent directory "/home/krisc86/compiler/fftw-3.1.1/include"
GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (cpplib) (x86-64 Linux/ELF)
GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (x86_64-unknown-linux)
compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-42).
ignoring nonexistent directory "/usr/x86_64-unknown-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/include
/usr/include
End of search list.
prog6.c: In function `main':
prog6.c:92: warning: assignment makes pointer from integer without a cast
as -V -Qy -o /tmp/ccc4P9F7.o /tmp/ccVO2XCC.s
GNU assembler version 2.14.90.0.4 (x86_64-unknown-linux) using BFD version 2.14.90.0.4 20030523
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/collect2 --eh-frame-hdr -m elf_x86_64 -Y P,/usr/lib64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crt1.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crti.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/crtbegin.o -L /home/krisc86/compiler/fftw-3.1.1/lib -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3 -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64 -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/ccc4P9F7.o -lfftw3 -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/crtend.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crtn.o
/usr/bin/ld: cannot find -lfftw3
collect2: ld returned 1 exit status
I could not decipher much of this though..where can hte problem be?
And this is what i got on my machine..Its working well on my machine:
Code:
gcc -v test.c -L/usr/local/lib -I/usr/local/include -lfftw3
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/cc1 -lang-c -v -I/usr/local/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ test.c -quiet -dumpbase test.c -version -o /tmp/cc8L0Oae.s
GNU CPP version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (cpplib) (i386 Linux/ELF)
GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (i386-redhat-linux)
compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
ignoring duplicate directory "/usr/local/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include
/usr/include
End of search list.
test.c: In function `main':
test.c:33: warning: assignment from incompatible pointer type
test.c:44: warning: passing arg 1 of `fftw_execute' from incompatible pointer type
test.c:52: warning: passing arg 1 of `fftw_destroy_plan' from incompatible pointer type
as -V -Qy -o /tmp/ccfOSymn.o /tmp/cc8L0Oae.s
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD version 2.13.90.0.18 20030206
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtbegin.o -L/usr/local/lib -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2 -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. /tmp/ccfOSymn.o -lfftw3 -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crtn.o
-
> -L /home/krisc86/compiler/fftw-3.1.1/lib
I notice this has a space between the -L and the path.
None of the compiler-generated -L options have a space
The same goes for your -I options as well.
> -I ~/compiler/fftw-3.1.1/include
You might want to put this before the source files
Some options are order sensitive, so I go with
gcc -I/path/to/inc foo.c bar.c baz.c -L/path/to/lib -lfoo
-
well, that doesnt change much though :
Code:
mpicc -v -I/compiler/fftw-3.1.1/include prog6.c -L/compiler/fftw-3.1./lib -lfftw3
mpicc for 1.2.6 (release) of : 2004/08/04 11:10:38
Reading specs from /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=x86_64-unknown-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/cc1 -lang-c -v -I/compiler/fftw-3.1.1/include -I///usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=x86_64 -Amachine=x86_64 -D__x86_64 -D__x86_64__ -D__SIZE_TYPE__=unsigned long int -D__PTRDIFF_TYPE__=long int -D__tune_athlon__ -D__tune_athlon_sse__ -D__LONG_MAX__=9223372036854775807L -D__LP64__ -D_LP64 -DUSE_STDARG -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDARG_H=1 -DUSE_STDARG=1 -DMALLOC_RET_VOID=1 prog6.c -quiet -dumpbase prog6.c -version -o /tmp/ccMW9uJC.s
GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (cpplib) (x86-64 Linux/ELF)
GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-42) (x86_64-unknown-linux)
compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-42).
ignoring nonexistent directory "/usr/x86_64-unknown-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/compiler/fftw-3.1.1/include
/usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/include
/usr/local/include
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/include
/usr/include
End of search list.
prog6.c: In function `main':
prog6.c:92: warning: assignment makes pointer from integer without a cast
as -V -Qy -o prog6.o /tmp/ccMW9uJC.s
GNU assembler version 2.14.90.0.4 (x86_64-unknown-linux) using BFD version 2.14.90.0.4 20030523
Reading specs from /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=x86_64-unknown-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-42)
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/collect2 --eh-frame-hdr -m elf_x86_64 -Y P,/usr/lib64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crt1.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crti.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/crtbegin.o -L///usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/lib/shared -L///usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/lib -L/compiler/fftw-3.1./lib -L//usr/local/ibgd/driver/infinihost/lib64 -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3 -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64 -L/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 -rpath-link ///usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/lib/shared prog6.o -lfftw -lmpich -lmtl_common -lvapi -lmosal -lmpga -lpthread -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/crtend.o /usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/../../../../lib64/crtn.o
/usr/bin/ld: cannot find -lfftw3
collect2: ld returned 1 exit status
if there's something wrong ,its got to do with this part of hte message right??
Code:
ignoring nonexistent directory "/usr/x86_64-unknown-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/compiler/fftw-3.1.1/include
/usr/local/ibgd/mpi/gcc/mvapich-0.9.5-mlx1.0.2/include
/usr/local/include
/usr/lib/gcc-lib/x86_64-unknown-linux/3.2.3/include
/usr/include
End of search list.
-
> -L/compiler/fftw-3.1./lib
I see this has acquired an extra dot over your last attempt.
And lost the /home/krisc86