diff --git a/source/loaders/c_loader/source/c_loader_impl.cpp b/source/loaders/c_loader/source/c_loader_impl.cpp index b8866bb95e..7c4d24bc99 100644 --- a/source/loaders/c_loader/source/c_loader_impl.cpp +++ b/source/loaders/c_loader/source/c_loader_impl.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -322,6 +323,23 @@ static loader_impl_c_handle c_loader_impl_handle_create(loader_impl_c c_impl) /* TODO: Take the c_loader and add the execution paths for include (and library?) folders */ /* tcc_add_include_path, tcc_add_library_path */ + std::string incl_path = c_impl->libtcc_runtime_path; + std::string metacall_incl_dir = "include"; + + #if defined(_WIN32) + auto i = incl_path.find_last_of('\\', incl_path.size()-3); + #else + auto i = incl_path.find_last_of('/', incl_path.size()-3); + #endif + + incl_path.replace(i+1, metacall_incl_dir.size(), metacall_incl_dir); + + /*Add metacall include path (so this works )*/ + tcc_add_include_path(c_handle->state, incl_path.c_str()); + + /*Add metacall library path (in other to find libmetacall.so)*/ + tcc_add_library_path(c_handle->state, c_impl->libtcc_runtime_path.c_str()); + (void)c_impl; return c_handle;