HISE Logo Forum
    • Categories
    • Register
    • Login

    Issue creating a c++ script fx node with multiples .h files

    Scheduled Pinned Locked Moved Scripting
    15 Posts 3 Posters 111 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Papours
      last edited by

      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 ^^

      HISEnbergH 1 Reply Last reply Reply Quote 0
      • HISEnbergH
        HISEnberg @Papours
        last edited by HISEnberg

        @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.cpp that is included in your C++ node header (let's call it filters.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.

        Sonic Architect && Software Mercenary

        P 1 Reply Last reply Reply Quote 0
        • P
          Papours @HISEnberg
          last edited by

          @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 and TestFilter::Test t(0.5); in prepare

          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

          P 1 Reply Last reply Reply Quote 0
          • P
            Papours @Papours
            last edited by

            @Papours If needed, here is a youtube video illustrating my issue.

            In other words, my question is : how can I tell hise to include external c++ files to the generated visual studio project ?

            ustkU P 3 Replies Last reply Reply Quote 0
            • ustkU
              ustk @Papours
              last edited by

              @Papours would it make a difference if you use

              #include <test_filter.h>
              

              in the cpp instead of

              #include "test_filter.h"
              

              Hise made me an F5 dude, browser just suffers...

              1 Reply Last reply Reply Quote 0
              • ustkU
                ustk @Papours
                last edited by ustk

                @Papours You might also need to set the search path for src in your VS project so it knows where to look for dependencies. I know it's the case in XCode but I don't know VS...

                Hise made me an F5 dude, browser just suffers...

                1 Reply Last reply Reply Quote 0
                • P
                  Papours @Papours
                  last edited by

                  @ustk Hi, thanks for the reply !
                  I tried a lot of different ways to import my file. I tried to change the quotes to "<" ">", I tried to add a "./" at the beginning and a mix of the two. Nothing changed my issue. I don't think the issue is with the way I include my file, since the c++ linter has no issues finding my file.

                  I'm not sure what the equivalent of "search path" is for visual studio, but I tried to dig into the project settings and add the global path to my src folder everywhere I tought could be the equivalent.
                  So I added the path to my src in :

                  • executable directory
                  • Include directory
                  • External include directory
                  • Reference directory
                  • Library directory
                  • Win RT directory
                  • Source directory

                  After adding my path everywere (but not adding the external file directly as i did in the video), I still had the linker error.

                  That being said, I don't think not having the error would have solver my issue, because I think the root of my problem is that hise is re-generating the visual studio project every time I trie to compile a dll, vst or standalone app, so I'm not sure if the solution is inside visual studio.

                  P 1 Reply Last reply Reply Quote 0
                  • P
                    Papours @Papours
                    last edited by

                    @Papours Another frustrating thing is that if I manually add my external dependency in vscode, then build as release, then open hise, in tool > Show DSP network DLL info, it says that my DLL is working fine alt text.

                    However, when exporting my hise project, it tried to re-build everything and fail :(

                    HISEnbergH P 2 Replies Last reply Reply Quote 0
                    • HISEnbergH
                      HISEnberg @Papours
                      last edited by

                      @Papours Sorry I missed your reply.

                      Have you tried using an absolute instead of a relative path here:

                      #include "src/test_filter.h"

                      I've noticed that VS can be kind of finicky about paths sometimes. So in this case for windows it will look like:

                      ("C:\\path\\to\\file\\src\test_filter.h")

                      This isn't an ideal solution but it might help solving if the compiler is failing to find the file or not....

                      Sonic Architect && Software Mercenary

                      1 Reply Last reply Reply Quote 0
                      • P
                        Papours @Papours
                        last edited by

                        @HISEnberg Hey, it's ok, you're answering pretty fast even when missing my reply ^^

                        I did try to use an absolute path, I still had the same issue : I can build the project inside visual studio after adding the .h and .cpp files manually, but can't export my project from hise
                        alt text

                        I don't think the issue is with the #include since I can build my project from visual studio code

                        HISEnbergH 1 Reply Last reply Reply Quote 0
                        • HISEnbergH
                          HISEnberg @Papours
                          last edited by

                          @Papours Hmm maybe try running the HISE project directly in VS.

                          So go through this whole procedure, but instead of compiling the Standalone in HISE, go to Project Name/Binaries/Builds/VisualSudio2022 and launch the project directly from there.

                          You can get a lot more useful information from the compiler that way.

                          Sonic Architect && Software Mercenary

                          P 1 Reply Last reply Reply Quote 0
                          • P
                            Papours @HISEnberg
                            last edited by

                            @HISEnberg

                            When launching the project directly from there, I get the same linker 2019 error as from when launching from dspNetwork.

                            alt text

                            If I add my external dependency directly (right click on the project > add > existing element), I can generate a standalone app from there

                            alt text

                            But then if I reopen hise and try to export my project as a vst (which is my final goal), I get the same linker error.

                            P 1 Reply Last reply Reply Quote 0
                            • P
                              Papours @Papours
                              last edited by

                              @Papours OH

                              However, if before opening the visual studio project in "project name/binaries/build" I try in hise to make a VST, the project there is trying to make a VST.

                              Doing the same dance of adding my external files and building from there do generate my VST.

                              So that solves my issue, thanks !

                              P 1 Reply Last reply Reply Quote 0
                              • P
                                Papours @Papours
                                last edited by

                                @Papours alt text

                                And I was able to import it into lmms !

                                Many thanks !

                                HISEnbergH 1 Reply Last reply Reply Quote 0
                                • HISEnbergH
                                  HISEnberg @Papours
                                  last edited by

                                  @Papours Nice glad you solved this!

                                  Sonic Architect && Software Mercenary

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post

                                  32

                                  Online

                                  2.0k

                                  Users

                                  12.9k

                                  Topics

                                  111.5k

                                  Posts