Using FFTW with Visual Studio 2010

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 17484 Views - Last Post: 10 July 2012 - 11:12 PM Rate Topic: -----

#1 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 10:39 AM

I am trying to use FFTW library with Visual Studio 2010 Professional.

I downloaded the libraries and compiled them using a pre-made solution for Visual Studio.

I got a dll, an Exports Library File, Incremental Linker file, Object File Library, and Program Debug Database.

The problem is that I am unsure where to put them.

I have read that the dll is meant to go in the project directory. Okay, I did that. When I try to add it as a reference to my project, nothing shows up. I am lost on this one.

I have never tried to use a library like this before. How do I integrate it with Visual Studio?

Is This A Good Question/Topic? 0
  • +

Replies To: Using FFTW with Visual Studio 2010

#2 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 617
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 12:41 PM

You could load procedures from the DLL manually, that is, in code. See here. I am not aware of any other methods for DLL's.

This post has been edited by Aphex19: 10 July 2012 - 12:46 PM

Was This Post Helpful? 0
  • +
  • -

#3 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 12:52 PM

Okay, thanks. I will try just putting that in the beginning of my program and seeing if I can call FFTW functions once it's called that DLL.

I read somewhere also that compiling a library ought to leave me something I put in "lib." I'm used to getting a header file too, but that didn't happen with FFTW here.

I'll give it a shot.
Was This Post Helpful? 0
  • +
  • -

#4 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 617
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:01 PM

To compile a static library, the configuration type of the project should be "Static Library (.lib)". You can change the configuration type under "Project Properties/Configuration Properties/General/Configuration Type".
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5930
  • View blog
  • Posts: 20,278
  • Joined: 05-May 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:01 PM

The Exports Library is what you want to link in so that you don't have to manually LoadLibrary() and then GetProcAddress().

Shouldn't FFTW have an include directory? It's very likely that will be the same one that have the public headers.
Was This Post Helpful? 1
  • +
  • -

#6 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:22 PM

View PostAphex19, on 10 July 2012 - 01:01 PM, said:

To compile a static library, the configuration type of the project should be "Static Library (.lib)". You can change the configuration type under "Project Properties/Configuration Properties/General/Configuration Type".


I used a pre-made solution to compile the dll.

It kicked out a .lib which I assume I'm meant to put in the lib folder (\Program Files(x86)\Visual Studio 10.0\VC\lib)

This is the first time I've tried using any kind of external library and so far no luck.

Quote

Shouldn't FFTW have an include directory? It's very likely that will be the same one that have the public headers.


I am not sure what you mean. I don't see public headers anywhere. Just a dll.

You're right - apparently the program I write should #include <fftw.h> but I don't know where that is or how to make it.

The instructions given for installation on Windows were convoluted at best.

View Postnullcoding, on 10 July 2012 - 01:19 PM, said:

Quote

Shouldn't FFTW have an include directory? It's very likely that will be the same one that have the public headers.


I am not sure what you mean. I don't see public headers anywhere. Just a dll.

You're right - apparently the program I write should #include <fftw.h> but I don't know where that is or how to make it.

The instructions given for installation on Windows were convoluted at best.


belay that, I missed a directory.

Found an un-tar'd folder with precompiled 64-bit dll. README says to use lib.exe to make linked libraries. Okay, sounds promising.

The header is in there too, I'm blind.

lib.exe won't open. "mspdb100.dll is missing." From what I see on MSDN site, I need to run vcvars32.bat...this changes nothing.

I've really opened a can of worms here huh.

Should it be this hard? What am I missing?
Was This Post Helpful? 0
  • +
  • -

#7 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,424
  • Joined: 20-March 10

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:24 PM

It helps if you read the instructions,

Quote

In order to link to these .dll files from Visual C++, you need to
create .lib "import libraries" for them, and can do so with the "lib"
command that comes with VC++. In particular, run:
lib /def:libfftw3f-3.def
lib /def:libfftw3-3.def
lib /def:libfftw3l-3.def


You create the .lib files using the above method from the .def & .dll files.
Using lib.exe which can be found in VC\bin

Snoopy.

This post has been edited by snoopy11: 10 July 2012 - 01:25 PM

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5930
  • View blog
  • Posts: 20,278
  • Joined: 05-May 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:27 PM

You probably didn't get the download from the official FFTW site.

Looking at the Windows .zip files from http://www.fftw.org/...ll/windows.html, I see that there is a fftw3.h file with in the .ZIP file. The .ZIP file doesn't have the import libraries, though. If you read the README-WINDOWS file that is in the .ZIP file it tells you how you to easily generate new import libraries.
Was This Post Helpful? 0
  • +
  • -

#9 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:29 PM

It wouldn't open! At least not from VC\bin. I just ran the VC++ command prompt (after I found it) and created lib files from there.

So! now, do I just put those exports library files in the lib directory of VC and use FFTW in Visual Studio?

Something tells me there's something else I'm meant to do.

It's a 64-bit dll, I have a 64-bit system, by the way.
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5930
  • View blog
  • Posts: 20,278
  • Joined: 05-May 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:39 PM

Different people have different variants on this, but most people will have setup their project directory something like this:

project_root
\src - source written specifically for the project
\bin - this is where executables of the compiled project go to be shared with others
\include - this is where headers meant to be given to others go
\lib - this is where libs meant to be given to others go
\docs - documentation about the project
\tools - tools used by the project to build, edit, etc.
\dependencies - this is where external dependencies live
   \fftw  - an example of a dependency
      \include - include files from FFTW
      \lib     - libs from FFTW
      \bin     - binaries from FFTW



And then we setup their compiler and linker option to have a relative path from their src directory to the appropriate directories under external. The use of relative paths makes it easy to move the project around either on the same machine or to other machines. It also lets us have multiple versions on a machine.

Although, right now it may seem more convenient to drop files directly into the VC include and lib directories and not deal with include and lib paths, it becomes a maintenance nightmare down the road. The next time you get a drop from FFTW, will you remember to delete all the old ones and put in new ones? If you get a brand new machine, will you remember what files to copy from the old machine? If you share your code with anybody else, will you remember what files to package along?

This post has been edited by Skydiver: 10 July 2012 - 01:43 PM

Was This Post Helpful? 0
  • +
  • -

#11 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 01:49 PM

Thanks for that, Skydiver. As I'm quite the amateur I will definitely reference that project layout for when I am sharing this project with others.

In other news, I believe I have installed FFTW correctly now. It's definitely not something I could have done on my own without the pointers in this thread. I sure am glad I found this forum. You're all a lot more tolerant of beginners like me than, well, people elsewhere.

I'll worry about re-writing my program to use FFTW for large integer operations first, then re-do the project directory. Thanks for the tip.

For what it's worth, I do have a separate Windows Library called "Code Resources" where I store full downloads of all libraries I have gotten thus far, including instructions on how to use them and examples of them, in case I forget.
Was This Post Helpful? 0
  • +
  • -

#12 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 02:04 PM

Oops, great, now I'm getting this.

1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_free referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_destroy_plan referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_execute referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_plan_dft_1d referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_malloc referenced in function _wmain
1>c:\users\USERNAME\documents\visual studio 2010\Projects\gjsFFTW_TEST_2\Debug\gjsFFTW_TEST_2.exe : fatal error LNK1120: 5 unresolved externals
1>
1>Build FAILED.


That wasn't happening before. All I did is put in example code from the tutorial to make sure it was installed correctly...after a few minutes it decided it didn't like that very much.

In Skydiver's example of a project directory, where do dll files go? I have never used them before.

Or in more general terms, how am I meant to reference FFTW libraries? They shouldn't be external, that's the odd thing.
Was This Post Helpful? 0
  • +
  • -

#13 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5930
  • View blog
  • Posts: 20,278
  • Joined: 05-May 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 02:04 PM

View Postnullcoding, on 10 July 2012 - 01:49 PM, said:

For what it's worth, I do have a separate Windows Library called "Code Resources" where I store full downloads of all libraries I have gotten thus far, including instructions on how to use them and examples of them, in case I forget.

Excellent! I wish I was smart as you when I first started programming. I had to go through those maintenance nightmares that I described earlier. :lol:
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5930
  • View blog
  • Posts: 20,278
  • Joined: 05-May 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 02:16 PM

View Postnullcoding, on 10 July 2012 - 02:04 PM, said:

Oops, great, now I'm getting this.

1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_free referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_destroy_plan referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_execute referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_plan_dft_1d referenced in function _wmain
1>gjsFFTW_TEST_2.obj : error LNK2019: unresolved external symbol __imp__fftw_malloc referenced in function _wmain
1>c:\users\USERNAME\documents\visual studio 2010\Projects\gjsFFTW_TEST_2\Debug\gjsFFTW_TEST_2.exe : fatal error LNK1120: 5 unresolved externals
1>
1>Build FAILED.


That wasn't happening before. All I did is put in example code from the tutorial to make sure it was installed correctly...after a few minutes it decided it didn't like that very much.

In Skydiver's example of a project directory, where do dll files go? I have never used them before.

Or in more general terms, how am I meant to reference FFTW libraries? They shouldn't be external, that's the odd thing.


What libraries did you add to your VS2010 link dependencies?
Was This Post Helpful? 0
  • +
  • -

#15 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: Using FFTW with Visual Studio 2010

Posted 10 July 2012 - 04:01 PM

What libraries did I add?

I assume you mean under Project Properties > Linker > General > Additional Library Directories

If not, then I don't know where...

I added the folder containing the library files (.lib) and the folder containing the dlls. Still that error.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2