Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET 7 paths and add error reporting #5627

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions core/nativeaot/NativeLibrary/LoadLibrary.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

//Set this value accordingly to your workspace settings
#if defined(_WIN32)
#define PathToLibrary "bin\\Debug\\net6.0\\win-x64\\native\\NativeLibrary.dll"
#define PathToLibrary "bin\\Debug\\net7.0\\win-x64\\native\\NativeLibrary.dll"
#elif defined(__APPLE__)
#define PathToLibrary "./bin/Debug/net6.0/osx-x64/native/NativeLibrary.dylib"
#define PathToLibrary "./bin/Debug/net7.0/osx-x64/native/NativeLibrary.dylib"
#else
#define PathToLibrary "./bin/Debug/net6.0/linux-x64/native/NativeLibrary.so"
#define PathToLibrary "./bin/Debug/net7.0/linux-x64/native/NativeLibrary.so"
#endif

#ifdef _WIN32
Expand Down Expand Up @@ -60,6 +60,16 @@ int callSumFunc(char *path, char *funcName, int firstInt, int secondInt)
#else
void *handle = dlopen(path, RTLD_LAZY);
#endif
if (!handle)
gewarren marked this conversation as resolved.
Show resolved Hide resolved
{
#ifdef _WIN32
int errorCode = GetLastError();
printf("Failed to load library at specified path. Error code: %d\n", errorCode);
#else
puts("Failed to load library at specified path");
gewarren marked this conversation as resolved.
Show resolved Hide resolved
#endif
return -1;
}

typedef int(*myFunc)(int,int);
myFunc MyImport = (myFunc)symLoad(handle, funcName);
Expand All @@ -79,6 +89,16 @@ char *callSumStringFunc(char *path, char *funcName, char *firstString, char *sec
#else
void *handle = dlopen(path, RTLD_LAZY);
#endif
if (!handle)
{
#ifdef _WIN32
int errorCode = GetLastError();
printf("Failed to load library at specified path. Error code: %d\n", errorCode);
#else
puts("Failed to load library at specified path");
#endif
return nullptr;
}

// Declare a typedef
typedef char *(*myFunc)(char*,char*);
Expand Down