Issue creating a c++ script fx node with multiples .h files
-
Hi everyone !
This week I tried to make my first c++ node for script fx following this tutorial.
The main difference between the final script in the tutorial and mine is that my filter is in another c++ file.
In visual studio (in \DspNetworks\Binaries\Builds\VisualStudio2022), I added an external dependency to my file and it worked great !
I managed to make my node and to use it inside hise.I made a small hise app using my node and first tried to export it as a standalone app : I had a linker error saying that my external file was not found.
I later found that there is another visual studio project file in \Binaries\Builds\VisualStudio2022. I added my dependency to that project and I managed to build the standalone app by generating it from visual studio.
Next I wanted to export it as a VST, so I did the same thing, had the same linker issue and resolved it the same way. However, when I tried to generate the VST from visual studio, it only re-generated the standalone app (I think ?).
I searched if there was a folder dedicated to external cpp files but I couldn't find any answer.
So, how can I create my VST ?
Am I missing something with the external dependencies ?Thanks ^^
-
@Papours If I am following you correctly, the Binaries folder is the wrong place to store any of your external C++ code. The binary gets rewritten often (each time you compile the FX within HISE), so this is going to lead to issues down the line.
So let's say you have a dependency file
filters.cppthat is included in your C++ node header (let's call itfilters.h). You can either create a a new folder or location for the filters.cpp, or even simpler is to place it in:ProjectName\DspNetworks\ThirdParty\src.After you do that delete the Binaries folder and recompile your FX nodes.
-
@HISEnberg Hi, thanks for the quick response !
My filter was indeed inside ProjectName\DspNetworks\ThirdParty\src and I had a reference to it in my node header.
I'm not sure if my first post was clear so here is a step by step to reproduce my issue :- Create a new hise project
- Create c++ third party node template
- Compile DPS node as dll
- Create a src folder in thirdParty
- Create test_filter.cpp and test_filter.h
// .cpp #include "test_filter.h" namespace TestFilter { Test::Test(float param){ test_float = param; } }/// .h namespace TestFilter { class Test { public: float test_float; Test(float param); }; }- Inside the template, add
#include "src/test_filter.h"at the beginning andTestFilter::Test t(0.5);inprepare
Now if I try to build inside visual studio code I get a linker error saying that it can't find the definition of my constructor.
If I add the dependency to test.h and test.cpp, it works, but only once, and if I retry to compile the dps network as dll I have to re-add the filters to my dependencies.And if I go back to hise and try to export as a standalone app, I have the linker error again.
I hope this make my issue more clear and sorry if it wasn't on my first message