21 const char* path_env = std::getenv(
"PATH");
26 std::string path_str(path_env);
27 std::istringstream iss(path_str);
28 std::string path_segment;
31 const char path_delimiter =
';';
32 const std::string executable_extension =
".exe";
34 const char path_delimiter =
':';
35 const std::string executable_extension;
39 while (std::getline(iss, path_segment, path_delimiter)) {
40 std::filesystem::path full_path = std::filesystem::path(path_segment) / (commandName + executable_extension);
43 if (std::filesystem::exists(full_path) && std::filesystem::is_regular_file(full_path)) {
67 throw std::runtime_error(
"ccObjectLinker: Linker path not set. Call searchAndSetupLinker() first.");
70 throw std::runtime_error(
"ccObjectLinker: Object file path not set.");
82 command +=
" -Wl,--start-group";
83 for (
const auto &file : this->
getConfig()->additionalLinkingFiles) {
88 command +=
" -Wl,--end-group";
97 if (!std::filesystem::exists(elysia_path_fs) || !std::filesystem::is_directory(elysia_path_fs)) {
98 std::string error_msg =
"ccObjectLinker: Elysia runtime path does not exist or is not a directory: " +
100 throw std::runtime_error(error_msg);
105 command +=
" -lelysia_runtime";
109 command +=
" -shared";
117 command +=
" -mconsole";
118 replace_all(command, std::string(
"\""), std::string(
"\\\""));
119 command =
"powershell.exe -Command \"&" + command +
"\"";
122 int result = std::system(command.c_str());
124 std::string error_msg =
"ccObjectLinker: Linker command failed with exit code " + std::to_string(result) +
". Command: " + command;
125 throw std::runtime_error(error_msg);