COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 11-30-2016, 01:04 AM   #1
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default Why do I need to add fft.c to my project every time?

Hi all,

I'm using Visual Studio 2015, on Windows 10. Within the folder WDL/ I have fft.h, fft.c, ... and some other files, such as wavread.h.

When I include fft.h inside my VST plugin I've no problem:

Code:
#include "fft.h"
It finds it, as well waveread.h and such! This means that the "Additional Include Directories" (WDL) is included in the project.

But when I build, I get a LINK error when building fft:

Code:
LNK2001	unresolved external symbol _WDL_fft
I can fix it going to VST project->Add existing file-> and select fft.c from WDL/ (which include the file in the main root of my VS project).

Why I should do it every time for every project? Why it can't find that file if the folder is included?
Nowhk is offline   Reply With Quote
Old 11-30-2016, 09:41 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,652
Default

Because there are many, many C/C++ source files in WDL, and surely you don't want to include all of them in every project, right? So you have to tell VS which ones you do want to include.

In other words: Simply including the header won't add any C/C++ source files to your project.
Tale is offline   Reply With Quote
Old 11-30-2016, 10:00 AM   #3
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

Thanks for the helps man As usual!
Quote:
Originally Posted by Tale View Post
Because there are many, many C/C++ source files in WDL, and surely you don't want to include all of them in every project, right? So you have to tell VS which ones you do want to include.

In other words: Simply including the header won't add any C/C++ source files to your project.
Of course But if I include #include "fft.h", it find that header! So I guess that folder WDL (at that level) is included.
Else, how could it use fft.h at all? For the same reason, when I include fft.c, I must also include fft.h.

It seems to catch only fft.h. Maybe default settings include only fft.h (not sure where) and not fft.c? It doesn't make sense
Nowhk is offline   Reply With Quote
Old 11-30-2016, 10:04 AM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Nowhk View Post
It doesn't make sense
Different rules for header files and source files. Your "include directories" determine what header files are found. Your source files to be compiled (.c/.cpp) must be added via other means into your build process/IDE project. This may seem confusing and annoying, but that's just how C and C++ work and you have to learn to deal with it. C++ doesn't currently have a standard "modules" system where you could just say "import wdl.fft" or something and you would get both the declarations and implementations needed.

(If you think about it, this allows for example to have a header file with no corresponding source file, so the implementation code can come from some other source, such as a .lib file or function pointers provided by a host application.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 11-30-2016 at 10:15 AM.
Xenakios is offline   Reply With Quote
Old 12-01-2016, 12:50 AM   #5
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

Quote:
Originally Posted by Xenakios View Post
Different rules for header files and source files. Your "include directories" determine what header files are found. Your source files to be compiled (.c/.cpp) must be added via other means into your build process/IDE project. This may seem confusing and annoying, but that's just how C and C++ work and you have to learn to deal with it. C++ doesn't currently have a standard "modules" system where you could just say "import wdl.fft" or something and you would get both the declarations and implementations needed.

(If you think about it, this allows for example to have a header file with no corresponding source file, so the implementation code can come from some other source, such as a .lib file or function pointers provided by a host application.)
Thanks for the clarification.

Just to learn it a bit more... how would you "add" this fft.c file? Within IPlug Solution's project?



At the moment its within my VST2 Solution's project, which looks "wrong" due to the location of the imported IPlug folder.
Nowhk is offline   Reply With Quote
Old 12-01-2016, 04:25 AM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Nowhk View Post
Thanks for the clarification.

Just to learn it a bit more... how would you "add" this fft.c file? Within IPlug Solution's project?

At the moment its within my VST2 Solution's project, which looks "wrong" due to the location of the imported IPlug folder.
I suppose in a VS solution like that, I'd probably put the fft.c inside the IPlug project. (Of course you have to rebuild the IPlug project after that, so that the other projects using it can link to the fft lib.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-01-2016, 06:34 AM   #7
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

Quote:
Originally Posted by Xenakios View Post
I'd probably put the fft.c inside the IPlug project.
Do you mean move both files (fft.h and fft.c) within WDL/IPlug folder and add them on VS project or only add them in VS project?

I could also create a new project such as "WDL-AddOns", and add things like fft, cairo, and so on as IPlug support...
Nowhk is offline   Reply With Quote
Old 12-01-2016, 08:27 AM   #8
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Nowhk View Post
Do you mean move both files (fft.h and fft.c) within WDL/IPlug folder and add them on VS project or only add them in VS project?
No, not in your file system but inside the Visual Studio project in the solution. (I've occasionally myself done that kind of file moving/copying directly in the file system, but it's not that great, it's much better to leave things in their original locations and just try to make the build system work based on that.)

Whether you have the fft.h file in your VS solution tree or not doesn't matter, it will be found or not found based on if it is in your include directories or if the compiler happens to be able to find the header file otherwise. (Note that you have to ensure the include directories are correct for all projects and their build configurations, in case they happen to be missing the location where for example fft.h is.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-01-2016, 08:59 AM   #9
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

I see I'll try to make a project "AddOns" where I'll include external libraries (like cairo) and fft.h/c from WDL main folder. If I'll catch troubles I'll let you know!

Thanks for the helps!
Nowhk is offline   Reply With Quote
Old 12-05-2016, 04:26 AM   #10
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

Well, at the end I've added a new folder (filter) under the VST projects (called addons), adding existing items into here. I prefer this so I don't touch the original IPlug project (which, in fact, doesn't include fft; it's a WDL feature). Thanks anyway for the tips.

However, an additional question: when I'm in "Tracer" mode, how VS would find the IPlug folder/lib? For release and debug, under the Linker properties, I see it point to these folder:

Code:
$(WDL_PATH)\IPlug\build-win\$(Platform)\$(Configuration)\;
$(WDL_PATH)\lice\build-win\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)
but once I select Tracer configuration, there's just:

Code:
$(WDL_PATH)\lice\build-win\$(Platform)\Release\;%(AdditionalLibraryDirectories)
IPlug? It takes "release" as default? I don't think so.
Maybe am I missing another place where it would search for the build?
Nowhk is offline   Reply With Quote
Old 12-12-2016, 12:47 PM   #11
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

No one? :P Still I don't find where Visual Studio can find the IPlug lib path in Tracer mode...
Nowhk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.