Skip to content

Commit

Permalink
try to fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
ptahmose committed Oct 18, 2024
1 parent 9a29331 commit 9a30d3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions OctaveMex/octavelibczi.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@ 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
// * we try to load the library from the same folder where this mex file is located
// * 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)
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 9a30d3a

Please sign in to comment.