Mac - c++ - create file.exe [duplicate] - c++

This question already has answers here:
Clang C++ Cross Compiler - Generating Windows Executable from Mac OS X
(3 answers)
Closed 5 years ago.
I've write a c++ project using xcode on a mac.
What I need is to create a .exe file to run the project on windows in anothre pc (no virtualization).
I've read that xcode doesn't provide this service and so I've tried to compile it also in Eclipse (on mac) but I'm not able to get the .exe file.
Is it possible, on mac, to generate a .exe of a c++ project runnable on windows?
Thank you

Yes, it is possible and it's known as cross-compilation. Besides building your own toolchain for doing this, you can use MinGW: Cross compiling with MinGW

Related

Is it possible to compile from Windows to Linux with gcc/g++?

Apologies for the beginner question.
In short I'm trying to compile a very simple C++ program for Linux from Windows 10. A few answers say "install cygwin" but I'm not sure it's the optimal solution. Would it be simpler to just install Linux and build for Linux from Linux and for Windows from Windows, or do cross-compilers already exist that could take care of the work for me?
Thank you
Edit: maybe my question wasn't clear. Essentially, I'm using VSCode on Windows. I have C++ code that I'd like to compile for Linux from Windows. I installed MinGW and it lets me compile Windows executables without issue. However I have no idea on how to compile executables for Linux.
You have several choices:
WSL.
WSL(Windows Subsystem for Linux) its linux termanal in windows, so you can compile linux code in windows. This solution is the simpliest and I would recommend to use it.
Visual studio.
Visual studio has a package that allows you to compile programs for Linux. More details here
The Linux and Windows libraries have some implementation differences. And also have different executables. Windows project may not work on Linux. But you can use the Visual Studio IDE with the Linux Developer Extension. Or can use WSL (Linux terminal for Windows) with Visual Studio Code (just install correct extension).
Compiling a very simple C++ program for Linux from Windows 10 can be done on a vanilla Windows 10 system by installing an Arm-provided, mingw32, toolchain:
Aarch32/Arm 32 bit:
gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-linux-gnueabihf
Aarch64/Arm 64 bit:
gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-linux-gnu
I'm sorry, I didn't quite understand the question. But when I start linux and try to make a C++ program. I started by trying to install the compiler through the terminal, then made a simple C++ program, and it worked. To begin with I visited this site :
https://linuxconfig.org/how-to-install-g-the-c-compiler-on-ubuntu-18-04-bionic-beaver-linux
Hopefully can help

Where to compile a C++ program? [duplicate]

This question already has answers here:
How to install older version of GCC on Windows 10
(3 answers)
Closed 2 years ago.
I am new to coding in C++ and I am not sure where I can compile a C++ program, I am learning C++ through a website that already has a place to compile the code built into it. I know how to compile a program by using these commands: g++ [program name].cpp -o [name you want to give] and then do ./[name you gave]. I want to know where I can compile my code outside of this website.
Thanks.
There are lots of places you can write code for c++. Usually people will use IDEs such as
Visual Studio Code
Code::Blocks
CLion
Eclipse
CodeLite
etc...

How to run a C++ code in Matlab [duplicate]

This question already has answers here:
Call C++ code from MATLAB?
(4 answers)
Closed 8 years ago.
I have codes which are written in C++ and I would like to use them in Matlab. In my folder I have these files:
do_it.cpp
hist (I guess it's a binary file)
hist_lebesgue.cpp
hist_lebesgue.hpp
tools.cpp
tools.hpp
The program is supposed to make a pdf distribution of your data set.
I was told that to run the code in Linux (I guess by C++ compiler) you need to call the binary 'hist' from the linux commandline. If you are in the
folder where the binary lies then you need to type for example
['./hist 1000 2 path_to_file'].
path_to_file is the path of your data file.
Now I want to use this code to run it in Matlab. Could someone please help me how I can do this. What should I type in Matlab's command Window?
PS. I am using mac.
Assuming you use Windows OS X: You can't run a Linux executable on Windows OS X. You have two options:
Compile the program for Windows OS X with the MinGW OS X version of gcc / g++.
If that doesn't work, or you find it too difficult: Install Linux (e.g. Debian) in a virtual machine (e.g. VirtualBox), and install the Linux version of Matlab in it.
EDIT: Once you have installed the compiler on your system (I trust you can find tutorials for that with Google), you could try this command for compiling the program:
g++ hist_lebesgue.cpp tools.cpp do_it.cpp -o hist
I can't promise it will work though, since I don't know the source code and can only guess how to compile it. You should ask the person who gave you the source code for instructions how to compile it.

How to compile C++ on linux for to make a windows binary [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Howto compile for Windows on Linux with gcc / g++?
We don't have windows here how can I compile this program for some ppl? Is there some kinda Wine for linux programs to run on windows or what.
You can use cross-compiler gcc-mingw
I did not use it myself and about it only theoretically.

running linux c++ code in windows [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
C++ Portability between Windows and Linux
i am new to c++ programming and i dont really know much about it
i am running linux (ubuntu) in my desktop and my laptop is running windows but it has charger problems.. anyway, what i want to do is to program softwares in linux and run them in my laptop (windows)... so my question is is there any difference between programming c++ in linux and windows and if the generated program only runs on linux, can i re-compile the code that has been compiled and ran fine in linux??
i have looked in google but i didnt really get useful informations!
C++ code can be compiled quite happily on Linux, Windows and a gazillion other platforms. Where you will have problems is with the libraries that you link to. So long as you stick to the standard library of C++ or highly portable libraries like boost then you should have relatively few issues. If you link to a library that is only available on one of the platforms, then you will hit trouble.