From be927988054a5daaac88542d5c5dc9be39afe746 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Fri, 13 Dec 2024 23:25:20 +0800 Subject: [PATCH] Fixed implementation of VariableDeclarationExpression::loadNativeFunction() for Windows target. --- .../ast/expression/VariableDeclarationExpression.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/n8/ast/expression/VariableDeclarationExpression.cpp b/src/n8/ast/expression/VariableDeclarationExpression.cpp index 47e1030..6b7286e 100644 --- a/src/n8/ast/expression/VariableDeclarationExpression.cpp +++ b/src/n8/ast/expression/VariableDeclarationExpression.cpp @@ -22,6 +22,8 @@ #include #include +#include + #if defined(__unix__) || defined(__linux__) || defined(__APPLE__) # include #elif defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) @@ -56,7 +58,8 @@ DynamicObject VariableDeclarationExpression::visit(SymbolTable& symbols) { return {}; } - +#include +#include NativeFunction VariableDeclarationExpression::loadNativeFunction( std::string& libName, std::string& funcName, @@ -84,7 +87,13 @@ NativeFunction VariableDeclarationExpression::loadNativeFunction( #endif else { #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) + + std::filesystem::path path(library); + std::cout << "Loading DLLs from: " << path.parent_path().string().c_str() << std::endl; + + AddDllDirectory(path.parent_path().wstring().c_str()); handle = LoadLibraryA(library.c_str()); + #elif defined(__APPLE__) handle = dlopen(library.c_str(), RTLD_LAZY); #elif defined(__unix__) || defined(__linux__)