Using make for cross platform compilation

前端 未结 6 1748
野趣味
野趣味 2021-02-05 05:03

I am currently developing a C project under Linux and Win32. The \'deliverable\' is a shared library, and all the development is done under Linux with the GNU tool chain. I am u

6条回答
  •  情书的邮戳
    2021-02-05 05:46

    If you are willing to use MSYS2 on Windows you might get it to run without making any changes at all compared to your code written for Linux. This goes for your C/C++ source code as well as for your makefile.(!)

    I have been developing code for Linux exclusively. When I tried running it inside an MSYS2 terminal, the code turned out to work just fine, and produced a Windows binary executable. I was positively surprised.

    You will need to know how to install and use MSYS2, of course. For example, to install make and g++, in an MSYS2 terminal run the commands:

    yes | pacman -Syu msys/make
    yes | pacman -Syu gcc
    

    If you want to find out where in Windows g++ has been installed, you can run where g++ in the MSYS2 terminal.

    References:
    https://www.msys2.org/wiki/MSYS2-installation/
    https://github.com/msys2/MSYS2-packages/issues/293

提交回复
热议问题