Paizo Top Nav Branding
  • Hello, Guest! |
  • Sign In |
  • My Account |
  • Shopping Cart |
  • Help/FAQ
About Paizo Messageboards News Paizo Blog Help/FAQ
Pathfinder Roleplaying Game
Pathfinder Society

Pathfinder Beginner Box

Pathfinder Adventure Card Game

Pathfinder Comics

Pathfinder Legends

Programming (C++) Beginner


Technology


Though placing this thread on this messageboard makes no sense, my question is, what free compiler and environment should I try and use on my Mac for learning (or at least messing around with) C++?

This is pretty much my first attempt to learn anything technology related, and I'm trying to learn a whole programming language right off through the logic that trying to take my time and download more programs that will actually work on my computer will be harder than just having one project that's way too hard.

I've been trying to use CodeBlocks; however it doesn't seem to be really meant for Macs, and though I've had the most success with it so far, the MingW compiler doesn't work well (if it even downloaded, pretty fuzzy on that).

I can't download Apple XCode as my shiny new computer isn't quite shiny and new enough to run the latest version.

Suggestions? Sort of tired of Googling answers and having all the answers be, 'Google it N00B.'


If you can find an install disc that came with your mac, which you SHOULD have for emergencies anyway, you can install Xcode from there.


Yucale wrote:
I can't download Apple XCode as my shiny new computer isn't quite shiny and new enough to run the latest version.

Which version do you think will run?

>This FAQ< says XCode 3 is a free download too.


C++ is not a good language to learn programming in. It is exceedingly complex and gives you nothing as to structure. Instead, try Processing. I had great fun with it.


Sissyl wrote:
C++ is not a good language to learn programming in. It is exceedingly complex and gives you nothing as to structure. Instead, try Processing. I had great fun with it.

As may be. I've messed around a bit with Gamemaker, but that doesn't have the code part I'm looking for. Heard Java's a good beginning language. Haven't heard of Processing.

Part of why I chose C++ is, apart from stubbornness, I don't get so much conflicting advice over it- sure it's not a good beginner's language, but if you learn it you can do something with it.


Tensor wrote:
Yucale wrote:
I can't download Apple XCode as my shiny new computer isn't quite shiny and new enough to run the latest version.

Which version do you think will run?

>This FAQ< says XCode 3 is a free download too.

Not sure. I've looked at various old releases but none of them seem to be an actual version of XCode, just updates.


You can do things with it.. But unless you learn to deal with memory allocation, data structures and a ton of other stuf, you won't make it work.

Qadira

Pathfinder Comics Subscriber; Pathfinder Adventure Path, Campaign Setting, Companion, Maps, Modules, Roleplaying Game, Tales Subscriber

Post your version of OSX and what hardware you are running on and we can help more.

One option might be to install MacPorts and then install the GCC C++ compiler from there.

The simple bits of C++ are no worse to learn than C, although Sissyl is correct that there are better languages to learn clean and formal program design via.

I would advise just using a simple text editor and the Terminal command line to get started with programming. An IDE like CodeBlocks comes in useful later.


Everyone else is well-meaning, but wrong. :)

If you are seriously motivated and not intimidated by the material, and you want to program games (I'm extrapolating that from your post) then go big. You'll learn a lot from a lower-level language about how graphics and hardware interact, how the machine uses memory, all that jazz.

Not everyone needs baby steps. I sure did.


The simple bits of C++ ARE C. =)

If you can do it, you'll learn a lot. However, you'll likely get stumped on some stupid syntax requirement and get lost. That's why Processing is a wonderful language to start with. It is (IIRC) a Java version that is specifically designed to let you start doing simple graphical programs, i.e. all the drudge work is done for you, letting you do the cool stuff instead. There is also a library of very instructive examples to work from.

www.processing.org

Shadow Lodge

Doesn't mac come with a developer package (Xcode)? I have a mac for personal use but I code at work on a linux machine (I use gedit to edit and g++ to compile). Grab the book C++ primer plus. Usually I hate programming books because I don't learn anything, however, C++ Primer Plus is one of my favorites. I code for scientific applications so my advice might not be the best for game coding.

I love C++ but because of legacy code I use Fortran 90 mostly (I like it too but it is outdated).


brock wrote:

Post your version of OSX and what hardware you are running on and we can help more.

Mac OS X

Version 10.6.8

Processor: 3.06 GHz Intel Core 2 Duo
Memory: 4 GB 1067 MHz DDR3

No idea what part of this info you're looking for, but there it is.


Is Wine worth downloading?

I should also mention I'm more interested in programming things to run on Windows and, probably, gaming consoles than I am for Macs.


Asphere wrote:

Doesn't mac come with a developer package (Xcode)? I have a mac for personal use but I code at work on a linux machine (I use gedit to edit and g++ to compile). Grab the book C++ primer plus. Usually I hate programming books because I don't learn anything, however, C++ Primer Plus is one of my favorites. I code for scientific applications so my advice might not be the best for game coding.

I love C++ but because of legacy code I use Fortran 90 mostly (I like it too but it is outdated).

The install disc for my computer is, for now, lost somewhere in the morass of my parent's 'filing system'. On the Mac website there are downloads for XCode but, as mentioned, none of the versions I've found will download/are at least sorta up-to-date.

I've found a lot of promising C++ tutorials online; getting a compiler and IDE that will work are my current concerns.

Qadira

Pathfinder Comics Subscriber; Pathfinder Adventure Path, Campaign Setting, Companion, Maps, Modules, Roleplaying Game, Tales Subscriber

So you have the latest version of Snow Leopard. You can access the Mac App Store and get hold of XCode from there, I think. I'm on Lion, so I can't double check. There was one version that you had to pay for, but it wasn't too expensive.

Snow Leopard is supported by MacPorts, so you can get all sorts of compilers from there. You just need any version of XCode installed to get MacPorts going, so the old versions should be fine.

Look here and ignore (2.) about installing X11 for now.

Don't bother with XCode as an IDE if you are not going to be purely targeting the Mac.

NetBeans is a pretty good IDE and has support for C++. It's also cross-platform so you can use the same IDE on Windows.

That said, I'd strongly suggest starting with a basic text editor and the command line. At some point, you'll hit a problem that requires you to know what your IDE is doing under the hood and starting that way will mean that you can figure it out.

WINE is a useful tool for getting Windows programs to run, but I would think twice about using it as a target for development. Better to use VirtualBox or similar to get a Windows install running on your Mac and test your code in that.

So:

  • Get an old XCode either from the web as you have already found or from the App Store
  • Download and install MacPorts
  • 'port install gcc' to get the latest version of the GCC compiler
  • Use vi or emacs or textedit or TextWrangler to create a simple HelloWorld.cc
  • gcc -o HelloWorld HelloWorld.cc
  • ./HelloWorld
  • ... onwards and upwards


Processing, as far as I've gotten, is working like a dream.

I would still prefer to try C++. I've looked for previous versions of XCode, but none seem to be available on the App Store.

Qadira

Pathfinder Comics Subscriber; Pathfinder Adventure Path, Campaign Setting, Companion, Maps, Modules, Roleplaying Game, Tales Subscriber
Yucale wrote:
I would still prefer to try C++. I've looked for previous versions of XCode, but none seem to be available on the App Store.

Odd that it's not on the App Store any more.

Do you have a free Apple Developer membership? If not, sign up here.

Then go to here and the XCode 3.2.6 download shows up on page 4 for me.


I downloaded it, but the computer won't recognize it.

Qadira

Pathfinder Comics Subscriber; Pathfinder Adventure Path, Campaign Setting, Companion, Maps, Modules, Roleplaying Game, Tales Subscriber
Yucale wrote:
I downloaded it, but the computer won't recognize it.

What exactly happens? Does in mount the disk image ok? What do you see in the disk image? What do you do next, and what exact error messages does it produce? Do you have any other version of XCode installed? Do you have a /Developer folder already? Do you have anything in /Applications named XCode?


It appears in Downloads, but when I try to open it it labels it 'not recognized'. I've heard that my computer should have a version of XCode already on the install disk, but that has to be installed separately and the disk is currently lost. I have nothing named XCode in Applications or anywhere else I've looked.
/Developer folder?

Qadira

Pathfinder Comics Subscriber; Pathfinder Adventure Path, Campaign Setting, Companion, Maps, Modules, Roleplaying Game, Tales Subscriber
Yucale wrote:

It appears in Downloads, but when I try to open it it labels it 'not recognized'. I've heard that my computer should have a version of XCode already on the install disk, but that has to be installed separately and the disk is currently lost. I have nothing named XCode in Applications or anywhere else I've looked.

/Developer folder?

That normally indicates that the .dmg file is corrupt. Try downloading again, and if that doesn't fix it try the previous version 3.2.5 which is available at the same page - it's possible, although unlikely, that the 3.2.6 .dmg is corrupt on the Apple server.

/Developer is a folder that is created by an old install of XCode. Now that it is distributed through the App Store, it installs in /Applications instead.

There are some other things to try on this list at Apple Support Communities.


I've installed XCode and macports; should macports open as an application? It's showed up as a folder in my documents, however, it does not seem to be doing anything.

Qadira

Yucale wrote:
I've installed XCode and macports; should macports open as an application? It's showed up as a folder in my documents, however, it does not seem to be doing anything.

It's a command line based application, so you need to work from Terminal, which is in Applications/Utilities.

As I mentioned above, you should now be able to type 'port install gcc' to get the latest version of the compiler. You might need to do 'sudo port install gcc' if it complains about permissions.

What version of XCode did you get to install? You may also be able to run Xcode, go to preferences, downloads, and select and install 'command line tools' to get a compiler you can run from the terminal installed as well.

Then try to write and compile a simple program as above.

In any case, having MacPorts installed gives you simple access to a vast set of different languages, libraries and tools to play with.


I've brought up Terminal, but unfortunately, whenever I use 'sudo port install gcc' it says 'command not found' and 'port install gcc' simply gives me

Worleys-iMac:~ brianworley$

in a new window every time I enter the new command.

Qadira

Do you get similar results to these:

silver:Library djb$ which port
/opt/local/bin/port

silver:Library djb$ echo $PATH
/opt/local/bin:/opt/local/sbin:/opt/gmt/bin:/Users/djb/idl70/bin:/opt/subve rsion/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/itt/id l/bin/:/sw/bin:/Users/djb/bin

silver:Library djb$ which sudo
/usr/bin/sudo

Try 'sudo date' and check it prints the date.


It was cooperating, and I used 'port install gcc' again. I got;

Warning: port definitions are more than two weeks old, consider using selfupdate
Error: Port gcc not found

That actually seems a bit more promising. Are there updates back on the Macports site that I should download?

Qadira

Yucale wrote:

It was cooperating, and I used 'port install gcc' again. I got;

Warning: port definitions are more than two weeks old, consider using selfupdate
Error: Port gcc not found

That actually seems a bit more promising. Are there updates back on the Macports site that I should download?

Yep, every couple of weeks do:

sudo port selfupdate

This lets MacPorts know what the latest 'stuff' is. Then

sudo port upgrade outdated

This will get the latest stuff.

Now, it turns out that I was mistaken about how to install the MacPorts version of gcc. It's split out by version. So instead do

sudo port install gcc47

Tip, you can list all of the ports, and just look at the ones that relate to gcc by doing

port list | grep gcc


Worleys-iMac:~ brianworley$ sudo port install gcc47
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Computing dependencies for gcc47Error: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
Worleys-iMac:~ brianworley$

I moved the macports to applications; however, I have to navigate to it by using the search function at the top of the finder window in applications. This hadn't been an issue before. Should I move the macports files to somwhere else?
Also, I know for a fact that XCode is on my computer, installed and able to be opened; not having gcc yet, though, I haven't done much with it. Opening the installer and re-installing it to be sure, however, results in it telling me that it can't be installed because either necessary data is missing or my internet connection is faulty (I doubt the latter).

Osirion

C++ is not an easy language, but if you can master it you can handle most of the other common languages.

Start small and don't try memory allocation until you have a firm grasp of the simpler concepts.

If you want to familiarize yourself with an IDE at the same time your learning to program, Eclipse is fairly decent.


I was trying that, but then got directed to CodeBlocks. Assuming I can get gcc, I should be able to use Terminal, no?

Qadira

Yucale wrote:

Worleys-iMac:~ brianworley$ sudo port install gcc47

Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Computing dependencies for gcc47Error: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
Worleys-iMac:~ brianworley$

I moved the macports to applications; however, I have to navigate to it by using the search function at the top of the finder window in applications. This hadn't been an issue before. Should I move the macports files to somwhere else?
Also, I know for a fact that XCode is on my computer, installed and able to be opened; not having gcc yet, though, I haven't done much with it. Opening the installer and re-installing it to be sure, however, results in it telling me that it can't be installed because either necessary data is missing or my internet connection is faulty (I doubt the latter).

That all sounds very odd... Why did you move macports? By move, do you mean that you moved the directory /opt/local into /Applications? /opt/local is where MacPorts installs all of it's stuff. I'm not sure what it is that you are navigating to in Finder - once MacPorts is installed, you should be able to do all you need to from a terminal window.

Ok. Let's come at this from a different direction. Can you run XCode, go to the Preferences, select Downloads, and install 'Command Line Tools'. Reboot (just to be sure) then do 'which make' and 'which gcc' and post the results.


It has, under Preferences

Key Bindings
Text Editing
Fonts & Colors
Indentation
File Types
Source Trees
SCM
Documentation

No Downloads that I can see.

I moved everything under macports to the screen that contains opt local; I had tried to place it in opt local, but it only placed it beside it. Trying to move those files to opt local failed: 'The items can’t be moved because “local” can’t be modified.'

Trying Terminal again, I get a the same error message.

Generally, when I download something onto the computer, it appears in downloads, where I drag it from to place wherever I intend to use it from. I had moved Macports from downloads to Applications originally.


Switching over to Processing, I got this

processing.app.SketchException: unexpected char: 'i'
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:353)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
at java.lang.Thread.run(Thread.java:680)

with

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}


It is a java version, not C++. There is no cout, I think, and the first function is called void setup(). You could simply do:

void setup() {
println("Hello world.");
}

The references are very good, and there are plenty of example sketches. Good luck.


A different route I should take? XCode still refuses to install, and- well, I basically have the exact same problems as before.

One last attempt to start off with C++.
Otherwise, I shall switch over to java with Processing, and thank you all for the advice with that.

Paizo / Messageboards / Paizo Community / Gamer Life / Technology / Programming (C++) Beginner All Messageboards

Want to post a reply? Sign in.

©2002–2014 Paizo Inc.®. Need help? Email customer.service@paizo.com or call 425-250-0800 during our business hours: Monday–Friday, 10 AM–5 PM Pacific Time. View our privacy policy. Paizo Inc., Paizo, the Paizo golem logo, Pathfinder, the Pathfinder logo, Pathfinder Society, GameMastery, and Planet Stories are registered trademarks of Paizo Inc., and Pathfinder Roleplaying Game, Pathfinder Campaign Setting, Pathfinder Adventure Path, Pathfinder Adventure Card Game, Pathfinder Player Companion, Pathfinder Modules, Pathfinder Tales, Pathfinder Battles, Pathfinder Online, PaizoCon, RPG Superstar, The Golem's Got It, Titanic Games, the Titanic logo, and the Planet Stories planet logo are trademarks of Paizo Inc. Dungeons & Dragons, Dragon, Dungeon, and Polyhedron are registered trademarks of Wizards of the Coast, Inc., a subsidiary of Hasbro, Inc., and have been used by Paizo Inc. under license. Most product names are trademarks owned or used under license by the companies that publish those products; use of such names without mention of trademark status should not be construed as a challenge to such status.