Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adammcd

macrumors member
Original poster
Nov 15, 2007
34
0
FYI: The Q's that I asked in this post have been answered... thanks!
Additional comments are welcome (of course), but as far as I am concerned, all of my questions have been answered. Thank you all very much!

-Adam

5-6 years ago I took a single C++ course. I've done little with C++ since then, so I definitely qualify as a 'Newbie'.

Lately I have been writing simple 'command line' C++ applications in Xcode to help me solve some tricky math problems. I tried out Xcode first (since it was already on my Mac), and could only figure out how to get my simple C++ programs to work/run by creating them as "Command Line Utility"->"C++ Tool" programs in Xcode. I type in my code, I hit the "build and go" button, then I open up my executable file and it runs in my terminal -- very basic, but it works and it is all that I need.

Now I am wondering if I could give others my executable file so that they could use them. Here are my thoughts/questions:

(1) Could I just send my executable file to any windows/mac/other user, have then double click on it & it will open up in a terminal window for them and work without any issues?
(2) Even if '(1)' does work, it would be nice to have my programs look a little better. I have *no* GUI experience, but I am wondering if somehow I could change/adapt my code so that my programs look a little nicer (are more user-friendly if I sent them to others for use).
(3) Should I be using the "command line utility" in Xcode, or is something else more appropriate (if so, I need help -- I couldn't other methods to work)? Should I start using something other than Xcode?
(4) How much time/effort would it take for someone like me to learn to use Xcode or another application to adapt my existing programs into more user-friendly ones (with a GUI?) that I could send to other people to use? I am only willing to put so much time into this...

Keep in mind I have no GUI experience, I only know (a little) C++, and my programs are "all-in-one" programs (meaning I don't have separate files, like .o, .h, .c files floating around, just one file [I actually do not remember how using multiple files works and what the reasons are for having code in separate files are, but that is a whole other topic]).

Any comments/help/suggestions would be appreciated.

Thanks -- Adam
 

Muncher

macrumors 65816
Apr 19, 2007
1,465
0
California
(1) Could I just send my executable file to any windows/mac/other user, have then double click on it & it will open up in a terminal window for them and work without any issues?

The C++ source code may be portable, but the executable will not be. If you compile it on a mac, expect it to work on only macs.

(2) Even if '(1)' does work, it would be nice to have my programs look a little better. I have *no* GUI experience, but I am wondering if somehow I could change/adapt my code so that my programs look a little nicer (are more user-friendly if I sent them to others for use).

This would involve either learning all about Carbon (Apple's old C++ GUI API, which is being phased out and isn't worth the trouble) or Cocoa (which means learning Objective C).

(3) Should I be using the "command line utility" in Xcode, or is something else more appropriate (if so, I need help -- I couldn't other methods to work)? Should I start using something other than Xcode?

Using that is fine. I like XCode, and the Command-Line Utility template lets you make quick programs without any nasty GUI coding.

(4) How much time/effort would it take for someone like me to learn to use Xcode or another application to adapt my existing programs into more user-friendly ones (with a GUI?) that I could send to other people to use? I am only willing to put so much time into this...

A while. If I were you I'd start by learning Objective C. I've heard it makes GUI programming very easy, but I haven't found the time to learn it properly. You'll most likely need a book for it (the forum search bar is your friend).
 

adammcd

macrumors member
Original poster
Nov 15, 2007
34
0
Muncher, thanks for your quick and thorough reply -- it was very helpful.

It is too bad that incorporating a GUI will require much effort (in contrast, I've heard that in java that creating a GUI isn't so bad).

So, making a really nice GUI will definitely require lots of learning & work on my part. My code is short & simple, so figuring out how to rewrite it in Objective C might actually be an option. However, I would prefer to stay working in C++.

Muncher mentioned that my executable file that works on my mac will work on other macs. I believe that all Macs come with a 'terminal' utility, so it really should work on *anyone's* Mac, yes?

Would it be possible to use Xcode or a different C++ application ("compiler"?, "front-end"?, I'm not sure what the word is here...) to create an executable file that would work for the average Windows user?

Thanks again to Muncher. If anyone else has their 2 cents to offer I wouldn't mind hearing it.

-Adam
 

SRossi

macrumors regular
May 27, 2009
202
0
Glasgow, Scotland
Would it be possible to use Xcode or a different C++ application ("compiler"?, "front-end"?, I'm not sure what the word is here...) to create an executable file that would work for the average Windows user?

The way that I create C++ apps on windows is using the Dev C++ application and this will create a .exe file that can be used on ALL windows machines.

Some changes may have to be made though.

Stephen
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
5-6 years ago I took a single C++ course. I've done little with C++ since then, so I definitely qualify as a 'Newbie'.

Lately I have been writing simple 'command line' C++ applications in Xcode to help me solve some tricky math problems. I tried out Xcode first (since it was already on my Mac), and could only figure out how to get my simple C++ programs to work/run by creating them as "Command Line Utility"->"C++ Tool" programs in Xcode. I type in my code, I hit the "build and go" button, then I open up my executable file and it runs in my terminal -- very basic, but it works and it is all that I need.

Now I am wondering if I could give others my executable file so that they could use them. Here are my thoughts/questions:

(1) Could I just send my executable file to any windows/mac/other user, have then double click on it & it will open up in a terminal window for them and work without any issues?
(2) Even if '(1)' does work, it would be nice to have my programs look a little better. I have *no* GUI experience, but I am wondering if somehow I could change/adapt my code so that my programs look a little nicer (are more user-friendly if I sent them to others for use).
(3) Should I be using the "command line utility" in Xcode, or is something else more appropriate (if so, I need help -- I couldn't other methods to work)? Should I start using something other than Xcode?
(4) How much time/effort would it take for someone like me to learn to use Xcode or another application to adapt my existing programs into more user-friendly ones (with a GUI?) that I could send to other people to use? I am only willing to put so much time into this...

Keep in mind I have no GUI experience, I only know (a little) C++, and my programs are "all-in-one" programs (meaning I don't have separate files, like .o, .h, .c files floating around, just one file [I actually do not remember how using multiple files works and what the reasons are for having code in separate files are, but that is a whole other topic]).

Any comments/help/suggestions would be appreciated.

Thanks -- Adam

You can create executable files that will work on _many_ Macintoshes, but it takes a tiny bit of effort. Here are the things to look out for:

1. The projects that XCode create for you contain a "Debug" and a "Release" target. It is quite possible that a "Debug" target will only work on your Macintosh (for example if it relies on the Zerolink feature), so you should give the "Release" target to others.

2. Macs come with PowerPC and Intel processors, and in 32 and 64 bit variations. Have a look at the build settings: In "Groups & Files", open the "Targets" thing, click on your target, Command-I for Info, Select the "Build" tab and in "Architectures" check that "Standard (32 bit Universal) is selected. That will make your project run on all recent and many, many older Macs.

3. In the same place, choose the "Base SDK". If you don't have a UI, you most likely don't need say 10.5 features, so use 10.4 as the "Base SDK" if you want your code to run on Machines with Tiger, or even 10.3.9 if you want your code to run on Panther machines.

In MacOS X, you can't produce an executable that will run on Linux or Windows. Obviously you can just distribute your source code, if you don't mind doing that.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Would it be possible to use Xcode or a different C++ application ("compiler"?, "front-end"?, I'm not sure what the word is here...) to create an executable file that would work for the average Windows user?

Just about the terms: You would use a different combination of compiler, linker, and library. Usually these are combined with other development tools in an "IDE" (integrated development environment). XCode is an example of an "IDE", because it compiles editor, debugger, compiler, linker and so on.

A "front-end" and a "back-end" are the major parts of a compiler. Lets say you are creating a compiler and you want a C++, C, and Objective-C compiler for PowerPC, Intel, Intel 64-bit and ARM processors. You would write three front-ends (for C++, C and Objective-C) which understand one of the three languages each, and extract exactly what the computer is supposed to do from your program. Then the compiler writer would create four back-ends, one for each processor architecture. The back-end translates the general information what the program should do into code for that specific processor.
 

Muncher

macrumors 65816
Apr 19, 2007
1,465
0
California
It is too bad that incorporating a GUI will require much effort (in contrast, I've heard that in java that creating a GUI isn't so bad).

Well the learning curve is steep, but it shouldn't be all that bad once you know how to do it. I would suggest learning Python over Java, it's more useful now in my opinion.

Thanks again to Muncher. If anyone else has their 2 cents to offer I wouldn't mind hearing it.

-Adam

That's why I'm here! :p:D
 

adammcd

macrumors member
Original poster
Nov 15, 2007
34
0
Thanks to gnasher; I found your two posts quite helpful.

However, I am still a bit confused after reading these two bits of information:

[First]
The way that I create C++ apps on windows is using the Dev C++ application and this will create a .exe file that can be used on ALL windows machines.

Some changes may have to be made though.

Stephen

[Second]
In MacOS X, you can't produce an executable that will run on Linux or Windows. Obviously you can just distribute your source code, if you don't mind doing that.

So, if I want to create an executable file that is usable on (all?) Windows machines, I use a different IDE, such as DEV C++. And apparently this IDE/Application is ran on a Windows machine -- not a Mac, correct?

I own a Mac and I have access to a Linux computer that has C++ software available for use on it. The only Windows computer I have access to is one that I log into at my university -- I am not sure if this Windows machine has a C++ IDE or not, and I am not sure if I have permissions to download/install new software. I'll have to check.

I think for now that I will just use characters such as '-' & '|' to make my executable file reasonable to look at (instead of going the GUI route). It sounds like I can make an executable file that should be readable on all modern Macs right here on my (Mac) computer. And, if I have this straight, I will need to use a Windows machine (or perhaps Linux? Probably not if Macs won't cut it...) to create a version of my executable that will work on all (modern) Windows machines.

I think I will also try to learn some Objective C. Learning it would be nice on its own, and if I am able to rewrite my programs in Objective C, it sounds like I should then be able (with a bit more effort) to create a GUI right here on my Mac. Can I assume that the resulting program I create (intact with a GUI) will only be able to be run on Macs and that I need to use an Objective C IDE on a Windows machine to create a program (w/GUI) that can be run on Windows machines?

-Adam
 

drangew

macrumors newbie
Jun 22, 2009
1
0
This might be something

I have used The SDL programming Libraries for Linux and windows. A lot of tutorial and examples exist, a few explains how to set this up on Mac. Beeing totally newbee on macintosh, probably starting to do mac-suport for customers very soon. Putting up a G4 right now and will try to
This is a good place to start:
http://gpwiki.org/index.php/C:SDL_tutorials

This show how to set up SDL using XCode 2.1:
http://lazyfoo.net/SDL_tutorials/lesson01/mac/index.php
Sorry that I haven't tryed this out yet.
mvh drangew
 

cqexbesd

macrumors regular
Jun 4, 2009
175
42
Germany
It is too bad that incorporating a GUI will require much effort (in contrast, I've heard that in java that creating a GUI isn't so bad).

I don't think it is much easier doing GUIs in Java than it is in Cocoa. Both require you to learn extra stuff - and it isn't as simple as command line programming - but its doable if it interests you. A Cocoa GUI will be OSX only mind you.

One thing to note is that you don't have to write your GUI in the same language as your command line tool. You can have them as two separate apps and just have the GUI app run the command line app as a user would, capture the output and then display in the GUI. Therefore the GUI could be written in anything - Cocoa/Obj-C, Python, Java, WxWidgets/C or even a RAD like Runtime Revolution (http://www.runrev.com) which is quite quick to run up simple programs and is cross-platform though isn't free.
 

SRossi

macrumors regular
May 27, 2009
202
0
Glasgow, Scotland
So, if I want to create an executable file that is usable on (all?) Windows machines, I use a different IDE, such as DEV C++. And apparently this IDE/Application is ran on a Windows machine -- not a Mac, correct?

I own a Mac and I have access to a Linux computer that has C++ software available for use on it. The only Windows computer I have access to is one that I log into at my university -- I am not sure if this Windows machine has a C++ IDE or not, and I am not sure if I have permissions to download/install new software. I'll have to check.

Yes the software has to be installed on a windows machine and it will compile the source code for windows machines. This is the only way that I know that you can create windows .exe files.

See here for Apple Tutorial on objective-C http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html (This is very helpful)

Stephen
 

Muncher

macrumors 65816
Apr 19, 2007
1,465
0
California
Thanks to gnasher; I found your two posts quite helpful.

However, I am still a bit confused after reading these two bits of information:

[First]


[Second]


So, if I want to create an executable file that is usable on (all?) Windows machines, I use a different IDE, such as DEV C++. And apparently this IDE/Application is ran on a Windows machine -- not a Mac, correct?

I own a Mac and I have access to a Linux computer that has C++ software available for use on it. The only Windows computer I have access to is one that I log into at my university -- I am not sure if this Windows machine has a C++ IDE or not, and I am not sure if I have permissions to download/install new software. I'll have to check.

I think for now that I will just use characters such as '-' & '|' to make my executable file reasonable to look at (instead of going the GUI route). It sounds like I can make an executable file that should be readable on all modern Macs right here on my (Mac) computer. And, if I have this straight, I will need to use a Windows machine (or perhaps Linux? Probably not if Macs won't cut it...) to create a version of my executable that will work on all (modern) Windows machines.

I think I will also try to learn some Objective C. Learning it would be nice on its own, and if I am able to rewrite my programs in Objective C, it sounds like I should then be able (with a bit more effort) to create a GUI right here on my Mac. Can I assume that the resulting program I create (intact with a GUI) will only be able to be run on Macs and that I need to use an Objective C IDE on a Windows machine to create a program (w/GUI) that can be run on Windows machines?

-Adam

Generally, it is much easier to compile programs on the machine they are designed to run on. However, it might be possible to cross-compile on a mac to create a linux executable file. I wouldn't recommend it to you though, that's rather advanced.

Once you learn Objective-C and Cocoa, making simple GUIs should be trivial.

Objective-C is a mac phenomenon. If you want to make truly portable code, learn Python. It is currently the best for that. However, don't expect any of your GUI code to be portable; each OS has its own system and they are rarely inter-compatible. (Exception: POSIX/X11).

I have used The SDL programming Libraries for Linux and windows. A lot of tutorial and examples exist, a few explains how to set this up on Mac. Beeing totally newbee on macintosh, probably starting to do mac-suport for customers very soon. Putting up a G4 right now and will try to
This is a good place to start:
http://gpwiki.org/index.php/C:SDL_tutorials

This show how to set up SDL using XCode 2.1:
http://lazyfoo.net/SDL_tutorials/lesson01/mac/index.php
Sorry that I haven't tryed this out yet.
mvh drangew

SDL is for 2D game programming. It is a fantastic library for what it does, but I wouldn't use it for GUI programming. Cocoa would be easier.
 

adammcd

macrumors member
Original poster
Nov 15, 2007
34
0
One thing to note is that you don't have to write your GUI in the same language as your command line tool. You can have them as two separate apps and just have the GUI app run the command line app as a user would, capture the output and then display in the GUI.
This totally made me have one of those "ah-hah!" moments.

I can't believe that I hadn't thought of this -- it seems so obvious now, but I would not have thought of it on my own. :eek:

For now I am going to stick with the idea of making a faux-GUI out of ASCII characters in the terminal. I will be using C++, so I'm assuming I should be able to compile my code on a windows machine with little or no changes in the code. A very portable solution.

If I have time I will also make a super simple Cocoa GUI App then later use my C++ terminal output to insert the text I want in that App -- but I don't think I'll ever bother with making a Windows GUI App using Python or the like.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Additional comments are welcome (of course), but as far as I am concerned, all of my questions have been answered. Thank you all very much!

-Adam
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.