problem with the library

This is a discussion on problem with the library within the C Programming forums, part of the General Programming Boards category; I need to use the FFTW to generate fourier transforms. The "fftw-3.1.1 " has been installed already and it is ...

  1. #1
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342

    Question 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...
    Last edited by kris.c; 07-03-2006 at 01:00 PM.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    What errors are you getting exactly? Are you getting compilation errors, or linker errors? (Sounds like probably the latter.) Are you linking with fftw?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    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]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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..
    Last edited by kris.c; 07-03-2006 at 11:33 PM.

  6. #6
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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
    Last edited by kris.c; 07-03-2006 at 11:46 PM.

  7. #7
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    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.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  8. #8
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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

  9. #9
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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 ??

  10. #10
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  12. #12
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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
    Last edited by kris.c; 07-05-2006 at 11:12 PM.

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    > -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
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    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.

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    > -L/compiler/fftw-3.1./lib
    I see this has acquired an extra dot over your last attempt.
    And lost the /home/krisc86
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined Reference when linking a library
    By steve1_rm in forum C Programming
    Replies: 7
    Last Post: 03-12-2008, 06:34 PM
  2. Templates from DLL or static library problem
    By mikahell in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2008, 01:49 AM
  3. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  4. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 06:20 AM
  5. Problem With WinPcap library
    By DrMario in forum C Programming
    Replies: 0
    Last Post: 03-26-2005, 11:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21