C++ to MacOS | Sololearn: Learn to code for FREE!


C++ to MacOS

hello, i have written C++ code on my windows with visual studio is there a way to give this code to someone with a mac?


9/1/2019 6:05:52 AM

Cat Sauce

5 Answers

New Answer


Cat Sauce I was talking about IDE on mac, i know what you are using on windows. Anyways, copy both the files in any folder. open a terminal/console or whatever you call in mac, ensure your compiler is in your path type g++ or gcc or clang, If it says not found then the compiler the compiler is not in your path else go to the directory where you copied the files and type g++ myprogram.cpp if it complain about header file then add that too g++ myprogram.cpp myprogram.h it will create the binary file myprogram.o then run it /.myprogram ensure you have execute permissions


~ swim ~ i did, how do i convert it now?


i use visual studio and i have 1 main file and 1 class (.cpp & h)


Cat Sauce If you have used Standard C++ only then there should not be a problem but things to consider 1. C++ compiler and version on MAC, VS does exist for mac but i don't know if it is as good as it is on Windows. If the compiler is totally different like g++, clang then you might get some warnings and/or error if the C++ feature you are using is not yet implemented on g++ or clang (this generally doesn't happen as both of them are top compilers) Remove any visual studio specific stuff from your code.


Do you have single file or multiple files? Which compiler you are using? Are you using any IDE?