Artem Selivanov
Artem Selivanov

Reputation: 1957

How to cross-platform compile on windows for linux using gcc?

My aim is to create cross-platform C++ python modules. I'm usingCyther (cross-platform The Cross-Platform Cython/Python Compiler).

Cyther uses GCC to compile modules and gives the user the ability to add GCC command-line args.

So, I need run compiler on Windows, but compile for Linux. What args I must pass to GCC to compile a module for Linux (or other platform)?

Is this possible, if so how?

Upvotes: 1

Views: 1791

Answers (1)

Jan Hudec
Jan Hudec

Reputation: 76236

Gcc must be built separately for each compilation target. It can be built for any target on any host. The target you need is i386-linux-gnu (or often i586-linux-gnu) for 32-bit and x86_64-linux-gnu for 64-bit Linux.

Note that it provides separate binaries, i386-linux-gnu-gcc, x86_64-linux-gnu-gcc etc. Parameters are then the same.

I am not sure anybody provides that, but you can build it yourself. A tool to help you with that is described in C++ cross-compiler from Windows to Linux.

Or you can go the simpler way and build on Linux (including cross-compilation to Windows). This kind of things is just so much easier on a decent Linux distribution.

Upvotes: 1

Related Questions