Hi, @Mate
You could use \"
instead of ".
\" space path \"
\"C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.37.32705/bin/Hostx64/x64/link.exe\"
Since there is one space between link.exe and /out, you need to add another pair of \"
.
" \" \"(space) link.exe \" (space) /out:test.exe \" "
E.g.
#include <cstdlib>
int main() {
const char* command = "\"\"C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.37.32705/bin/Hostx64/x64/link.exe\" /out:test.exe \"XXX/ConsoleApplication1.obj\" \"/libpath:C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.37.32705/lib/x64\" \"/libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/um/x64\" \"/libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/ucrt/x64\" \" ";
int result = system(command);
system("test.exe");
return 0;
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.