Can you compile and run a c++ file in the Linux terminal? - c++

I am coding on a Raspberry Pi, and I just learned C++,and I want to continue coding in it. I am using the Raspbian OS. I can't download xCode, as it is humongous, and the Raspberry Pi would break. In CodeCademy, it teaches you to compile and run the programs using g++ and ./a.out. Is there any way to do that in the terminal of the Raspberry Pi?

Yes, but you have to install a C++ compiler first. As root, run apt-get update && apt-get install g++. Then you can run g++ as usual.

Related

Can't compile with gtk+ on codeblock ubuntu

So i'm really new at C and C++ (like.....i started a week ago).
I have this c++ script that i'm working on, I made an interface in gtk+ that work fairly well. Till now i used window 10 but I had to do some multithreading (using pthread) and window is quite bad at handling those. So i decided to work on Ubuntu 16.
There begin the trouble, can't figure out how to make everything works....I'll try to be specific.
I'm using Ubuntu 16.0.4, mingw, openal and gtk+, to install everything i used :
sudo apt-get install gpp gcc g++ mingw-w64 codeblocks
sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev
sudo apt-get install libopenal-dev libalut-dev
sudo apt-get install libgtk2.0-dev build essential
and if i understand it right it install the latest package of everything.
If i create an gtk+ project and test it with a simple code it works just fine....But when i try to test MY code i get an "fatal error: config.h file not found" in resample_defs.h...
And if I paste my GTK+ script that work earlier in place of my code i get the same error. So apparently gtk+ work with *.c but not with *.cpp
how do i fix that ?
Any help would be welcome at this point...
Ok, got it. I feel stupid now.
Resample_defs.h WAS slignthly changed by de guy that created the script I work on.
There was an
#if !defined(WIN32) //which force the include of config.h
But since i'm now in Linux OS it doesn't work, so add an :
#ifdef __linux__
well, that's that. Thank you very much for your help ! I can code now !

Qt5.7 installed on Raspberry Pi3 and working...how to get QtCreator?

I've finally mangaged to get Qt5.7 on a Raspberry Pi3, and have built an example which runs on the Pi, this was done by carefully following:
Step by Step instructions on how to install Qt5.6 on Raspberry Pi3
To get 5.7 on the Pi simply replace:
git clone git://code.qt.io/qt/qtbase.git -b 5.6
With:
git clone git://code.qt.io/qt/qtbase.git -b 5.7
This sets-up the tool chain on a Linux host in my case Ubuntu 16.04, however it doesn't install QtCreator, I then tried installing QtCreator and messed up the build, so I had to start over.
How do I get the latest QtCreator installed on either the Ubuntu 16.04 or preferably on the Pi3 ?
I just started following these instructions: https://www.ics.com/blog/configuring-qt-creator-raspberry-pi
It starts with installing QtCreator on the Desktop, as you are cross compiling, why would you want it on the Pi itself?
Still waiting for the build to complete, wonder if it will all work right away :)

C++ compiler/SDK for Ubuntu 12.04 - Netbeans

I have installed Netbeans 7.1 on Ubuntu. When I was activating C++ in netbeans, it didn't lead me to the page where C++ compiler/SDK exists, as it did in windows. I am using Cygwin in windows, but seems like it is not there for Linux.
Please guide me to the correct location where I can find correct C++ compiler/SDK for Linux, which I can use in Netbeans.
You need to install gcc
gcc is the gnu c and c++ compiler
simply open a console and type:
sudo apt-get install build-essential
CPP setup instructions for netbeans:
http://netbeans.org/community/releases/60/cpp-setup-instructions.html

openmpi libraries for c++

I am using an ubuntu 10.04 system and I installed mpi libraries using
sudo apt-get install openmpi-bin openmpi-doc libopenmpi-dev
I am able to compile and run pure c-mpi code using the commands mpicc and mpirun but I am not able to compile cpp-mpi code using mpicc
Do I need to install any additional libraries to compile cpp code ?
more googling gave me the answer
I had to use mpicxx to compile and run the code

How to port a Ubuntu C++ library to MinGW?

In Ubuntu, there is a package called uuid-dev. To install and use it, I just need to run apt-get install uuid-dev. However, in MinGW, I couldn't install this package using mingw-get install.
May I know what are the basic steps to port a C++ application/library from Ubuntu to MinGW?
It might already support compilation under MinGW. Generally you would download the source, unpack them and run ./configure and see what happens.
Give that a try and get back to me.