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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-22-2003, 11:29 PM
|
#1
|
|
Member
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206
Rep:
|
How to compile a executable dos file by g++?
For example,
Code:
#include<iostream>
using namespace std;
int main ()
{
cout<<"hi"<<endl;
}
how to compile the code above to a executable dod file, such as *.exe, *.bat by g++ in linux?
Thank you.
|
|
|
|
09-22-2003, 11:32 PM
|
#2
|
|
Senior Member
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054
Rep:
|
linux doesn't need those type of file extensions, but if you want, use:
g++ -o hi.exe hi.cpp
edit: if you're talking about compiling that in linux and having it run in windows/dos, it won't to my knowledge. you have to compile the source code in windows/dos so it will run in windows/dos.
Last edited by megaspaz; 09-22-2003 at 11:39 PM.
|
|
|
|
09-22-2003, 11:46 PM
|
#3
|
|
Member
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206
Original Poster
Rep:
|
Thank you.
Yes, I want use the compiled file in dos/windows.
However, some compiler, such as Kylix can achieve this.
So I guess perhaps g++ also can achieve this.
Edit:
What about makefile's suffix rule?
I'll give it a go.
Last edited by Xiangbuilder; 09-23-2003 at 12:01 AM.
|
|
|
|
09-23-2003, 12:17 AM
|
#4
|
|
Senior Member
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054
Rep:
|
let's be clear here. i'm under the impression kylix can not do what you want. the target computer has to have kylix installed for you to be able to do it. either way, it's still not a straight compile and run. i could be mistaken about this, but i'm pretty sure with kylix you still have to make sure certain things are in order on the target machine. i am pretty sure that compiling source code using g++ in linux will not create a binary that will run in windows/dos.
|
|
|
|
09-23-2003, 12:48 AM
|
#5
|
|
Member
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206
Original Poster
Rep:
|
Thank you for your answer.
|
|
|
|
09-23-2003, 05:16 AM
|
#6
|
|
Member
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840
Rep:
|
The same is also the case with the compilers over all the OS. If you want to have to create a program that runs irrespective of platform, go for interpreted languages like perl, or better yet, go for JAVA.
|
|
|
|
09-23-2003, 06:22 AM
|
#7
|
|
Member
Registered: Jun 2003
Location: SEUK
Distribution: Debian & OS X
Posts: 194
Rep:
|
|
|
|
|
09-23-2003, 08:56 AM
|
#8
|
|
Member
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206
Original Poster
Rep:
|
Thank you.
I'll try it.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:52 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|