Eclipse export to .exe for terminal program?

Nov 30, 2014 at 2:12am
closed account (SzUk92yv)
Heyo.

I just wrote this simple random program in Eclipse and I can't seem to find out how to compile it into an e executable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//============================================================================
// Name        : pieORpi.cpp
// Author      : Khanovich
// Version     :
// Copyright   : MIT License
// Description :
//============================================================================
#include <iostream>
using namespace std;

int main(void);
void AskAgain(void);

void AskAgain(void) {
	string text;
	cout << "Would you like to try again? (y/n): ";
	cin >> text;
	if (text == "y") {
		main();
	} else if (text == "n") {
		cout <<  "See you soon!";
	}
}

int main(void) {
	string text;
	cout << "Enter some text: ";
	cin >> text;
	if (text == "pi") {
		cout << endl << "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912" << endl; //pi
		AskAgain();
	} else {
		cout << "pie" << endl;
		AskAgain();
	}
}


From what I've googled, a terminal window won't open to show the code. Is there anyway I could do this? The files I've built and such can be downloaded here: http://www.mediafire.com/download/9a755jwabnu50db/pieORpi.zip

P.S. also would be useful if someone could provide steps with how to create a .dmg file like this too for mac
Nov 30, 2014 at 6:09am
Hi,

Nothing to do with your problem, but don't ever call main(), and no need to declare it either. void is not necessary when there are no arguments, but that could be a matter of preference. Put your function definitions after main().

Investigate loops.

Cheers
Nov 30, 2014 at 2:17pm
closed account (SzUk92yv)

Hi,

Nothing to do with your problem, but don't ever call main()
Edit & Run
, and no need to declare it either. void is not necessary when there are no arguments, but that could be a matter of preference. Put your function definitions after main()
Edit & Run
.

Investigate loops.

Cheers


You're not understanding my question. I know the code is fine and that void is optional.

My problem is that I can't figure out how to export my C++ project in Eclipse to an executable file that will open up the terminal to display the program (i.e. no gui).
Dec 1, 2014 at 6:48am
Hi,

You're not understanding my question. I know the code is fine and that void is optional.


I did say:

Nothing to do with your problem


And your code is not fine. Don't ever call main() - it's a serious problem. Investigate how to do loops instead. There is no need to declare functions if you define them before main, so just move them after main(). This is so a reader doesn't have to go searching through the file looking for where main() is.

As for your problem, try looking for how applications are launched - there should be options for executing code in a terminal. Check that you have a console app and not a Windows or other kind of gui app.

Hope this helps. ;+)
Dec 1, 2014 at 1:33pm
any use?
"How to Make an Executable File in Linux Using Eclipse C++":
http://www.youtube.com/watch?v=dZj7zI28jpY
or
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fgetting_started%2Fcdt_w_newproj.htm

(you also need to #include<string> by the looks of it).
Dec 2, 2014 at 5:24am
You're not understanding my question. I know the code is fine and that void is optional.

void is not optional. void is illegal in standard c++. it is literally against the standard. same as calling main(). calling main is illegal
Dec 2, 2014 at 6:58am
@xkcd reference: Would you at least check that what you're saying is correct before you say it?

http://ideone.com/eO4WlF
Dec 2, 2014 at 8:05am
forgive me... i was stressed out (for unrelated reasons) when i wrote that and for some reason thought he meant void main()
Topic archived. No new replies allowed.