LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2011, 07:24 PM   #1
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Rep: Reputation: Disabled
Compile to Native MinGW


Well it's really simple : Can I make MinGW compile to a Native (I think that means processor not OS, I hope it does) executable instead of a Win32 Console Application?
Thanks.
 
Old 11-20-2011, 02:11 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Buster (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Used to be the '-mwindows' flag for the compiler. This is now deprecated; I gather that the right way now is to pass the subsystem command to the linker '-Wl,-subsystem,windows', but I haven't tried this (there are other subsystem modes such as 'native', 'console' and so on).
 
Old 11-22-2011, 11:42 AM   #3
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
Those tags sound more like there for compileing to/for a WIN32 Console app.
If they arnt I hope you understand.
If this clears anything up:
I want it to compile for my Pentum 4 and not Windows.0
Please help!
I'll try those tags when I get home today!
 
Old 11-22-2011, 07:35 PM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Buster (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Just to clarify some terminology.

Windows runs on x86 hardware (which includes Pentium 4 etc). So when you use a compiler such as gcc (as part of MingW32), or a Microsoft compiler, you are already compiling to native x86 code, which will execute on a Pentium 4.

However, all programs run within a context, the operating system. After a C program is compiled, it is linked to libraries (for example those that do I/O) and the initialization stub that starts the program. These libraries and stub are specific to the operating system.

If you want to compile for a system other than Windows, then you will need the appropriate libraries.

A Windows console application is still a native x86 program; it is just that the initialization stub opens up a console window for the I/O. Compiling with the flags I suggested will change the linking so that the initialization does not open a console window. This means standard I/O will not work unless you run it from console, but you can use the Windows API to create a GUI.

If this does not answer your question, you might need to clarify what you mean by 'native', since it has more than one meaning.
 
Old 11-22-2011, 07:59 PM   #5
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
Umm i thought/read that it uses a few things in system32 and I want it to run independent of these so that I can run it on the Linux half of my computer (no Internet, can't get wine) withought problems.
I guess these things are the stubs...
Isnt there a 'Portable App' thing where it packs all this stuff into the exe?

Last edited by Zssfssz; 11-22-2011 at 08:02 PM.
 
Old 11-22-2011, 09:17 PM   #6
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Buster (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 359Reputation: 359Reputation: 359Reputation: 359
Quote:
i thought/read that it uses a few things in system32
Yes, but more to the point, it will use the Windows API, which is the whole point of using MingW32. If you want to run on the Linux side of the machine, then the easiest method is just to compile under Linux using the standard gcc environment.

The operating system forms a layer between an application and the hardware. A standalone application that interfaced only with the hardware would require a boatload of work (in effect, you'd have to write all your own hardware drivers), and it would interfere with the normal operation of the operating system.

There isn't a portable exe format that will run under both Windows and Linux. This is not just the minor problem of incompatible executable formats, but the need for a common interface layer between the applications and the hardware. Wine gets around this by adding a Windows API layer above the Linux operating system.

If you specifically want to cross-compile for Linux under Windows, you might be better off looking at a Cygwin environment.
 
Old 11-22-2011, 11:01 PM   #7
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
It's a simple consol (non-GUI) app.
And I have MinGW because it seems more stable (and less controlative) than Cygin.
It also came with my IDE.
I have open watcom and can compile to a .elf but I don know what syntax differences there would be...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] The way to compile kernel with -mtune=native (or -march=native) kaz2100 Debian 3 08-18-2011 04:45 AM
[SOLVED] How to compile C programs with solaris ultrasparc native compiler... trist007 Solaris / OpenSolaris 2 01-11-2011 03:19 PM
Fedora style MinGW Cross Compile Suite for Slackware? Gavin Harper Slackware 0 11-06-2010 11:03 AM
How to compile .jar Java byte-codes into native machine codes? ilgaar Linux - Software 6 08-29-2010 12:20 AM
Attempting to Cross-compile SDL_image with mingw on a linux host Eupator Programming 6 02-03-2010 06:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration