shaolinmaster
Posts: 2
Joined: Thu Aug 01, 2013 3:05 pm

Pi, Macbook, C++

Thu Aug 01, 2013 3:09 pm

Hi All,

I'm new here and new to programming in general

I am starting a course where I will be learning C++

I am thinking of getting a Raspberry Pi and wondered if it is possible to hook it up through my Macbook to learn C++. How would I program C++ on the Raspberry Pi? Can I do it from Command Line? I'd rather do it direct than through another program / application

I have searched and can't really find anything that answers my questions

Many Thanks in advance

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1665
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Pi, Macbook, C++

Thu Aug 01, 2013 5:23 pm

Hey there; have a read of this;
http://gettingstartedwithraspberrypi.tu ... th-bonjour

This will allow you to access the file system of the Pi over your network.
You can then use a code editor tool on your Mac to do the programming and then just go into the Pi to compile and run it.

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Pi, Macbook, C++

Fri Aug 02, 2013 9:07 am

You can use SSH to issue the compiler commands and
start the result.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

shaolinmaster
Posts: 2
Joined: Thu Aug 01, 2013 3:05 pm

Re: Pi, Macbook, C++

Fri Aug 02, 2013 11:43 am

Thanks for the replies

Sorry to be a pain, I really am a noob!

I have read the article and have a couple of questions?

Do I download apt-get and then netatalk, or netatlak and then apt-get. If I'm been honest, I don't rally understand what these 2 do?

Apologies in advance

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: Pi, Macbook, C++

Fri Aug 02, 2013 11:49 am

apt-get is the front-end to the debian package manager.
You use it to download and install other programs.

Heater
Posts: 15950
Joined: Tue Jul 17, 2012 3:02 pm

Re: Pi, Macbook, C++

Fri Aug 02, 2013 12:08 pm

All you need to do is open an ssh session to your Pi, you then have a command line interface through which you can edit your code, using the vim or emacs or other text editor, and then you can compile it with gcc and run it.
$ gcc -o hello hello.cpp
$ ./hello
What you use to get the ssh session from a Mac I have no idea but as it is a Unix system surely you can open a terminal window on your Mac and it has an ssh command.

If you have a screen on your Pi you could used an IDE like the one that comes with the Qt GUI toolkit. Do an "apt-cache search qt" to see what packages Qt has available for development. You should find the Qt Creator IDE in there.

Or you could install the Code::Blocks IDE which is quite light weight.

Personally I develop C and C++ code on my workstation first. Using Qt Creator or whatever IDE. Only when it is good shape do I move it to the Pi and build it from the command line.
Memory in C++ is a leaky abstraction .

Return to “General discussion”