Skip to content

Commit

Permalink
- fixed compilation on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Hart committed Nov 7, 2024
1 parent 8448dfb commit 081d945
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 59 deletions.
5 changes: 3 additions & 2 deletions hi_tools/hi_neural/onnx_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class ONNXLoader: public ReferenceCountedObject

template <typename Func> Func getFunction(const String& name)
{
if(auto f = static_cast<Func>(dll->getFunction(name)))

if(auto f = reinterpret_cast<Func>(dll->getFunction(name)))
return f;
else
{
Expand All @@ -80,4 +81,4 @@ class ONNXLoader: public ReferenceCountedObject
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ONNXLoader);
};

} // namespace hise
} // namespace hise
4 changes: 4 additions & 0 deletions tools/onnx_lib/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

This project will build a dynamic library that wraps the ONNX runtime and can be loaded dynamically (the official ONNX runtime release needs to be linked dynamically).

For now I won't include the compiled library so you have to build it yourself if you want to use that feature...

## Build instructions

Download the static library builds from [here](https://github.com/csukuangfj/onnxruntime-libs/releases) and move the static library files into `Source/lib/Debug/` / `Source/lib/Release/` then open the projucer project and compile the dynamic libraries.

> Note that on macOS you might have to use an older release because of some weird C++ library errors. [That](https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.3/onnxruntime-osx-universal2-static_lib-1.17.3.zip) one worked for me (Universal binary)
If all went through fine, put the `.dll` / `.dylib` file into the this directory so that will be picked up by HISE.

## Deployment
Expand Down
5 changes: 5 additions & 0 deletions tools/onnx_lib/Source/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@


#include <JuceHeader.h>




#if JUCE_WINDOWS
/** \internal */
#define DLL_EXPORT extern "C" __declspec(dllexport)
Expand Down
117 changes: 60 additions & 57 deletions tools/onnx_lib/onnx_hise_library.jucer
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="yFrxpF" name="onnx_hise_library" projectType="dll" useAppConfig="0"
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1">
<MAINGROUP id="n3p52K" name="onnx_hise_library">
<GROUP id="{9D85BAED-2378-E734-0909-070B5591C860}" name="Source">
<FILE id="HG0uXU" name="Main.cpp" compile="1" resource="0" file="Source/Main.cpp"/>
</GROUP>
</MAINGROUP>
<JUCEOPTIONS JUCE_STRICT_REFCOUNTEDPOINTER="1"/>
<EXPORTFORMATS>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../JUCE/modules"/>
</MODULEPATHS>
</LINUX_MAKE>
<VS2022 targetFolder="Builds/VisualStudio2022" externalLibraries="onnxruntime.lib">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library" libraryPath="D:\Development\HISE modules\tools\onnx_lib\Source\lib\Debug"
useRuntimeLibDLL="0"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library" libraryPath="D:\Development\HISE modules\tools\onnx_lib\Source\lib\Release"
useRuntimeLibDLL="0"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../JUCE/modules"/>
</MODULEPATHS>
</VS2022>
<XCODE_MAC targetFolder="Builds/MacOSX">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../JUCE/modules"/>
</MODULEPATHS>
</XCODE_MAC>
</EXPORTFORMATS>
<MODULES>
<MODULE id="juce_core" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_events" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
</MODULES>
</JUCERPROJECT>
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="yFrxpF" name="onnx_hise_library" projectType="dll" useAppConfig="0"
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" cppLanguageStandard="17">
<MAINGROUP id="n3p52K" name="onnx_hise_library">
<GROUP id="{9D85BAED-2378-E734-0909-070B5591C860}" name="Source">
<FILE id="HG0uXU" name="Main.cpp" compile="1" resource="0" file="Source/Main.cpp"/>
</GROUP>
</MAINGROUP>
<JUCEOPTIONS JUCE_STRICT_REFCOUNTEDPOINTER="1"/>
<EXPORTFORMATS>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../JUCE/modules"/>
</MODULEPATHS>
</LINUX_MAKE>
<VS2022 targetFolder="Builds/VisualStudio2022" externalLibraries="onnxruntime.lib">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library" libraryPath="D:\Development\HISE modules\tools\onnx_lib\Source\lib\Debug"
useRuntimeLibDLL="0"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library" libraryPath="D:\Development\HISE modules\tools\onnx_lib\Source\lib\Release"
useRuntimeLibDLL="0"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../JUCE/modules"/>
</MODULEPATHS>
</VS2022>
<XCODE_MAC targetFolder="Builds/MacOSX" externalLibraries="onnxruntime"
iosDevelopmentTeamID="PF9H8PK77F">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug" targetName="onnx_hise_library" libraryPath="/Users/christophhart/Development/HISE/tools/onnx_lib/Source/lib"
macOSDeploymentTarget="10.14" osxCompatibility="10.14 SDK"/>
<CONFIGURATION isDebug="0" name="Release" targetName="onnx_hise_library" libraryPath="/Users/christophhart/Development/HISE/tools/onnx_lib/Source/lib"
macOSDeploymentTarget="10.14" osxCompatibility="10.14 SDK"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../../JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../JUCE/modules"/>
</MODULEPATHS>
</XCODE_MAC>
</EXPORTFORMATS>
<MODULES>
<MODULE id="juce_core" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/>
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/>
<MODULE id="juce_events" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/>
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/>
</MODULES>
</JUCERPROJECT>

0 comments on commit 081d945

Please sign in to comment.