First of all, I'm new to Linux OS.
I installed ubuntu and eclipse and the c/c++ package.
I started a new project, that is the default project, "Hello World c++ project",
and when I run it, it's given me the erorr:
Description Resource Path Location Type
Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options C/C++ Scanner Discovery Problem
What should I do?
Try to install all developer tools typing in console: sudo aptitude install build-essential. It will install g++, gcc and all libraries.
I had the same problem. Here's how I fixed it:
Run sudo sudo apt-get install build-essential to install the gcc, g++ and libraries.
Update the PATH environmental variable in the /etc/environment file adding /usr/bin/g++
Restart your VM or PC for this changes to take effect.
Related
I'm new to programming and I'm trying to set up C and C++,
I have the C/C++ extension pack installed and enabled on VScode,
I have mysys64 installed on the C:\ drive,
I added the Mingw-w64 destination folder path, with \mingw64\bin appended, to the system path in Edit environment variables for your account (windows settings).
The problem is that I can't run the g++ compiler (checking the version also doesn't run) and I'm very sure the address at system path is correct because I've checked it more than 6 times and I've also followed every single step on https://code.visualstudio.com/docs/languages/cpp until Check your MinGW installation (because it doesn't work).
The error messages I get are:
Command 'g++' not found, but can be installed with: sudo apt install g++,
and when I try: "Build Hello World" on https://code.visualstudio.com/docs/languages/cpp
I get:
/image/
Notes:
I run Windows 10 Pro, version: 21H2, OS build: 19044.1826
I already had WSL(ubuntu) installed before mysys64
Edit: I used a different machine and followed the same steps, it works there now. Looks like the problem is with the machine
Install WSL extension in VSCode, run VSCode from WSL (WSL2 better because its faster), then install g++ (sudo apt install g++) from WSL; MingW is evil :)
The objective is to compile a C++ program with Boost.Python in Eclipse on the OS on Linux Mint 18. In particularly, we want to run the template program:
#include<boost/version.hpp>
#include<boost/python.hpp>
#include<iostream>
using namespace std;
int main() {
cout << "My first boost program with version: " << BOOST_LIB_VERSION << endl;
return 0;
}
This personally took me quite a while to get working, so the tutorial below should serve as a one-stop-shop reference for anyone in a similar situation. Note on software used:
Boost version: 1.62.0
Python version: 2.7.12
OS: Linux Mint 18 Xfce 64-bit
Eclipse version: CDT 9.1.0 for Eclipse Neon.1
Installing Eclipse CDT
Make sure that you have Java installed. For the Java JDK (if you want to also develop Java programs), run:
sudo apt-get install default-jdk
To simply run Java programs (such as Eclipse), you can install the lighter Java JRE:
sudo apt-get install default-jre
Both JDK and JRE will work, but JDK takes up more space.
Go to CDT download webpage and download the Linux 64-bit file eclipse-cpp-neon-1-linux-gtk-x86_64.tar.gz
Assuming you downloaded the file in ~/Downloads/, run the following command to unpack ("install") Eclipse into the /opt/ directory:
sudo tar zxvf ~/Downloads/eclipse-cpp-neon-1-linux-gtk-x86_64.tar.gz -C /opt/
To create a desktop launcher icon, run
sudo gedit ~/.local/share/applications/eclipse.desktop
and in the text editor copy-paste:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse
You now have Eclipse installed, but you don't need to run it yet, just keep reading and following the instructions :)
Installing Boost
The instructions are more or less given here, but for the sake of cohesion I write them here.
Download boost_1_62_0.tar.gz
Assuming you downloaded the file into ~/Downloads/, run the following command to unpack Boost into the /usr/include/ directory:
sudo tar zxvf ~/Downloads/boost_1_62_0.tar.gz -C /usr/include/
It's as easy as that - you now have Boost... but that's not all yet. Read on :)
Building Boost.Python and Boost.System
The Boost libraries Boost.Python and Boost.System must be built before they can be used. Here's how you do this:
Go into the Boost directory in your Terminal:
cd /usr/include/boost_1_62_0/
Run the command:
sudo ./bootstrap.sh --prefix=/usr/local
To build Boost.Python and Boost.System into the /usr/local/lib folder, run:
sudo ./b2 install --with-system --with-python
once the command has finished, you will find libboost_system and libboost_python (with various file endings) in /usr/local/lib
That's it for building the necessary Boost libraries. Note that any other Boost library that needs to be built can be done in the same way.
Preparing Python 2.7
Linux Mint 18 comes with Python 2.7 pre-installed. For me, running the command python --version returns the output Python 2.7.12. I'll assume this is the same for you - but probably it doesn't make a difference what the version is. However, to get our objective of the C++ program with Boost.Python to build and run, you have to execute the additional command:
sudo apt-get install python-dev
which places some additional necessary files (particularly pyconfig.h) into /usr/include/python2.7.
Installing Linux GCC
Linux GCC allows you to compile C++ programs. To install everything necessary, simply run:
sudo apt-get install build-essential
Making our program run in Eclipse
Now we've got everything configured to be able to write, build and run our program in Eclipse. So, let's do it!
Run Eclipse, either from the terminal (either by using the desktop icon we've created or by running /opt/eclipse/eclipse in the Terminal).
If it's your first time running Eclipse, you'll be prompted to choose a workspace (basically, a folder where all Eclipse project files will be stored):
Now go to File -> New -> C++ Project and enter the following and click Finish (you can use whatever Location you wish, including the default location (i.e. the one of your workspace)):
Now go to File -> New -> Source File, enter the following and click Finish:
In the main.cpp file that automatically opens in the editor, type in the program that we want to compile (note that I customized my Eclipse layout, so it looks different from the default layout you might have):
Now the secret sauce. Go to Project -> Properties -> C/C++ Build -> Settings where you will see:
Go to GCC C++ Compiler -> Includes and, using the little icon that looks like a folder with a green plus sign, add the following Include paths:
Go to GCC C++ Linker -> Libraries and add the following Libraries and Library search paths:
Press OK to close the Project Properties window.
Back in the main Eclipse window, first click the hammer icon to build the project, then the green play icon to run it (both buttons are highlighted in the below screenshot). In the console view you will first see a successful build, then the Terminal output of our program:
That's it! We've achieved our objective of building and running a C++ program with the Boost.Python library included. That's the end of this tutorial, I hope it helped you :)
I downloaded Ubuntu 14.04TLS recently.
I'm very new to the Linux environment as I'm a Windows user. I don't really know how to install application on the Linux environment.
please I need help on how to get code blocks with MinGW for Ubuntu and how to configure it.
Also I need help on how to install gtkmm and configure code block to locate it.
I don't know if the same way we do
Open Project > Build Options…
Select your project.
On the Compiler settings tab, select Other options
and add this to the field:
pkg-config gtkmm-3.0 –cflags
Select the Linker settings tab and type the following
line in the Other linker options text area:
pkg-config gtkmm-3.0 –libs
that we will also do for Ubuntu. Also are we doing anything about environment variable.
also if you can recommend tutorials that I can use to understand the Ubuntu environment properly.
thank you once again
install code blocks on linux ubuntu (mingw is windows version of gcc)
sudo apt-get install codeblocks build-essential
install gtkmm
sudo apt-get install libgtkmm-3.0-dev
This is everything you need to know:
https://www.google.com/url?sa=t&source=web&rct=j&ei=6f8EVILBHYjBOP35gOAN&url=http://dottonetto.com/home/wp-content/uploads/2012/02/Programming-with-gtkmm-3.pdf&cd=1&ved=0CBsQFjAA&usg=AFQjCNEAIkFNCENMdOh0VvUo4zmDymL9cw&sig2=HKTiOjNFUdauvTGIQUlnhQ
I just installed Ubuntu 12.10, and I tried to install Eclipse and C++, but I failed miserably.
I started with an installation from the Software Center, Eclipse worked, but only in Java. Then I started googling for installation guides and tutorials, but after hours of downloads and installations, the C++ in Eclipse still doesn't work.
So now I have two questions:
How do I clean up this mess?
Actually, how do I know if there is a mess?
According to the Ubuntu Software Center, Eclipse is installed and has three add-ons.
How do I know if the other installations of other Eclipse versions/packagings overwrote each other or if I have multiple installations?
How do I install the latest version of Eclipse and C++ in Ubuntu 12.10?
There is a package called eclipse-cdt in the Ubuntu 12.10 repositories, this is what you want. If you haven't got g++ already, you need to install that as well, so all you need is:
sudo apt-get install eclipse eclipse-cdt g++
Whether you messed up your system with your previous installation attempts depends heavily on how you did it. If you did it the safe way for trying out new packages not from repositories (i.e., only installed in your home folder, no sudos blindly copied from installation manuals...) you're definitely fine. Otherwise, you may well have thousands of stray files all over your file system now. In that case, run all uninstall scripts you can find for the things you installed, then install using apt-get and hope for the best.
I used (the suggested answer from above)
sudo apt-get install eclipse eclipse-cdt g++
but ONLY after then also doing
sudo eclipse -clean
Hope that also helps.
I also tried http://www.eclipse.org/cdt/ in Ubuntu 12.04.2 LTS and works fine!
First, I downloaded it from www.eclipse.org/downloads/, choosing Eclipse IDE for C/C++ Developers.
I save the file somewhere, let´s say into my home directory. Open a console or terminal, and type:
>>cd ~; tar xvzf eclipse*.tar.gz;
Remember for having Eclipse running in Linux, it is required a JVM, so download a jdk file e.g jdk-7u17-linux-i586.rpm (I cann´t post the link due to my low reputation) ... anyway
Install the .rpm file following http://www.wikihow.com/Install-Java-on-Linux
Find the path to the Java installation, by typing:
>>which java
I got /usr/bin/java. To start up Eclipse, type:
>>cd ~/eclipse; ./eclipse -vm /usr/bin/java
Also, once everything is installed, in the home directory, you can double-click the executable icon called eclipse, and then you´ll have it!. In case you like an icon, create a .desktop file in /usr/share/applications:
>>sudo gedit /usr/share/applications/eclipse.desktop
The .desktop file content is as follows:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec="This is the path of the eclipse executable on your machine"
Terminal=false
Icon="This is the path of the icon.xpm file on your machine"
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE
Name[en]=eclipse.desktop
Best luck!
I was in the same boat. Installed Eclipse, realized need CDT.
sudo apt-get install eclipse eclipse-cdt g++
This just adds the CDT package on top of existing installation - no un-installation etc. required.
http://www.eclipse.org/cdt/
^Give that a try
I have not used the CDT for eclipse but I do use Eclipse Java for Ubuntu 12.04 and it works wonders.
Is there one command so that I can automatically install a C and C++ compiler/linker for using Eclipse on Unix?
One I have done this, when I load eclipse and I'm creating a project should the compiler now show up, or do I have to navigate and locate the compiler/linker?
sudo apt-get update
sudo apt-get -yqq install libc6-dev g++ gcc