0

I'm new to programming and when I compile my build it produces an "Unix executable file", which won't run on my friends PC. I'm using "clang++" as my compiler, and Visual Studio Code as my IDE, but it isn't producing a file that will run on both platforms. Below is the entirety of my very simple code. Is there a way to configure the build so that it produces a Windows Executable?

#include<iostream>

using namespace std;


int lotteryPrint() {

    cout <<"lotteryFinalresult";

return 0;}


int main()
{

int UserLotteryinput;


cout <<"Enter a lucky number ";

cin >> UserLotteryinput;

if (UserLotteryinput == 100) 

{

    cout <<"Win!";

} else {

    cout <<"Loss...";
    
}

return 0;
}

  • You cannot produce a file that will run on both platforms. You need to compile it twice, with different compilers. The code itself is irrelevant. – n. m. could be an AI Oct 14 '22 at 16:44
  • Your computer is running Linux? – user253751 Oct 14 '22 at 16:47
  • ***but it isn't producing a file that will run on both platforms*** I don't know of any IDE that will do that by default. These are two different OSs you will need 2 different compilers and 2 different executables. You can install a cross compiler that will allow you to build for MS windows in linux or macOS or freebsd or some other posix OS but that may not be an easy task for a beginner. – drescherjm Oct 14 '22 at 16:53
  • They probably got it set up with WSL and didn't realize what that means. – sweenish Oct 14 '22 at 17:44
  • You're looking for cross compiling. You configure Visual Studio Code to use a different compiler that builds executables for Windows. I didn't like Visual Studio Code (personal choice) when I tried it out, so my familiarity with it is very weak. Too weak to tell you how to set up multiple build targets. – user4581301 Oct 14 '22 at 18:17

0 Answers0