From 9a30d3ac6f6255c70a0d23583b88b070394d4f4e Mon Sep 17 00:00:00 2001 From: ptahmose Date: Fri, 18 Oct 2024 06:52:57 +0200 Subject: [PATCH] try to fix things --- .github/workflows/build.yml | 4 ++-- OctaveMex/octavelibczi.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93c2392..b2dff10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,7 @@ jobs: if: runner.os == 'Linux' shell: bash run: | - sudo apt install octave + sudo apt install octave liboctave-dev - name: build Octave mex-file (Windows) if: runner.os == 'Windows' shell: cmd @@ -96,7 +96,7 @@ jobs: shell: bash run: | cd OctaveMex - octave --cli "mkoctfile --mex octavelibczi.c" + octave --evalsu "mkoctfile --mex octavelibczi.c" cp build/MEXlibCZI/Release/libmexlibczi.so . ls - name: Prepare MATLAB-mex artifact (Windows) diff --git a/OctaveMex/octavelibczi.c b/OctaveMex/octavelibczi.c index 55295a8..6b884a5 100644 --- a/OctaveMex/octavelibczi.c +++ b/OctaveMex/octavelibczi.c @@ -299,8 +299,6 @@ static void(*pfn_OnShutdown)(void); static void(*pfn_OnInitialize)(void); static void(*pfn_mexFunction)(int nlhs, Parameter plhs[], int nrhs, const Parameter prhs[], struct IAppExtensionFunctions* app_functions); -static const WCHAR DllName[] = L"libmexlibczi.dll"; - static void Initialize() { // we try to load the dynamic library containg the mex function here @@ -308,6 +306,8 @@ static void Initialize() // * therefore, we first get the handle of the module of this mex file, use this handle to get the path of the mex file // * and then, we replace the file name with the name of the dynamic library #ifdef _WIN32 + static const WCHAR DllName[] = L"libmexlibczi.dll"; + HMODULE hModuleOfMexFile; BOOL B = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)&Initialize, &hModuleOfMexFile); if (!B) @@ -345,6 +345,8 @@ static void Initialize() pfn_OnShutdown = (void(*)())GetProcAddress(hModule, "OnShutdown"); pfn_mexFunction = (void(*)(int, Parameter[], int, const Parameter[], struct IAppExtensionFunctions*))GetProcAddress(hModule, "mexFunction"); #else + static const WCHAR DllName[] = "libmexlibczi.so"; + Dl_info dl_info; if (dladdr((void*)&Initialize, &dl_info) == 0) {