Reputation: 753
I want to start C++
development with NetBeans 15
, on Lubuntu Kinetic Kudu (22.10)
.
I installed first build-essential
sudo apt install build-essential
g++ --version
g++ (Ubuntu 12.2.0-1ubuntu1) 12.2.0
gcc --version
gcc (Ubuntu 12.2.0-1ubuntu1) 12.2.0
When selecting Tools > Options > C/C++
it says that either ccls
or the clangd
language protocol servers are needed.
I installed ccls
sudo apt install ccls
ccls --version
Ubuntu ccls version 0.20220729-1
clang version 14.0.6-2
Not sure if I should have installed clangd
instead or in addition to ccls
.
Now when I start NetBeans 15
choosing the C/C++
option it automatically selected the path to ccls
/usr/bin/ccls
Now I wanted to start a first Hello World C++
project, but somehow it looks complicated.
I would like to use the highest possible C++
standard version. The installed build-essential
comes with version 12.2
, and here for example https://gcc.gnu.org/onlinedocs/12.2.0/ I assume that for C++
it supports Standard 20
or even higher. I looked into it the very first time.
1. Choose Project: File > New Project > C/C++ > Lightweight C/C++ Project
2. Location: Project Path
I created a new folder myfirstcpp in /home/me/NetBeansProjects and selected it on this step.
3. Editor: Compile Commands
Here no clue what to specify.
I leave it empty and proceed.
4. Build: "Configuration Name", "Build", "Clean" and "Run"
Here no clue what to specify.
I leave it empty and proceed.
The project is created but completely empty, no artifact created upfront.
I created a CPP
file and copied the following code from the web
// C++ program to display "Hello World"
// Header file for input output functions
#include <iostream>
using namespace std;
// Main() function: where the execution of program begins
int main()
{
// prints hello world
cout << "Hello World";
return 0;
}
But the editor shows a yellow warning triangle stating compile commands not configured
. Also no option to run that simple Hello World programm, every Run
option is greyed out.
Obviously I have to configure steps 3-4
properly.
How?
Update on @skomisa
comment
I found that post before, but placing a .ccls
file with the exact same content
/home/me/NetBeansProjects/myfirstcpp/.ccls:
g++
-xc++
-Iinclude
-std=c++17
didn't change anything. Now I tried again, and after clicking around in the Project Properties
in the Editor
category by removing and adding the path /home/me/NetBeansProjects/myfirstcpp/.ccls
to the .ccls
file, switching into the Build
category without changing anything, all of a sudden the Run
options were active.
Weired, looks buggy to me... also when I closed NetBeans
, restarted, everything was again greyed out, until I clicked around again in the Project Properties
until the Run
options appeared active.
However, when I clicked the Run Project (myfirstcpp)
option I got this exception in the Output
window
Exception in thread "main" java.io.IOException: Cannot run program "": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at org.netbeans.modules.cpplite.project.runner.Runner.main(Runner.java:35)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:315)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:245)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 2 more
Either the content in the .ccls
file is not correct or incomplete, or in addition the Build
category has to be configured too.
I use OpenJDK
java --version
openjdk 18.0.2.1 2022-08-18
OpenJDK Runtime Environment (build 18.0.2.1+1-1)
OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)
if this is relevant.
Upvotes: 6
Views: 5082
Reputation: 1
I don't know if you have resolved this issue or not, but i had same problem and here is what i did to fix this.
You already installed build-essentials, so i assume you already installed gdb and cmake too.
install ccls and clangd (i don't know if this is necessary, but netbeans seems require them)
sudo apt install ccls clangd
Open the project or create a new one
Right click under your project then select Properties
Under the Build Categories fill up the Build form with g++ your_file.cpp
my file is main.cpp
so i write g++ main.cpp
Build your project. Now an output file was added to your project. mine is a.out
Go back to Project Properties and add that a.out
to Build > Run with ./
in front of it. ./a.out
Now try to run the project and see the Output below.
Upvotes: 0
Reputation: 81
Just installed NB15 on Ubuntu 22.04 and running C++ (using gcc/g++12) project. Follow mostly from
https://stackoverflow.com/a/66832862/6760184
Enable C++:
sudo apt install mlocate
and use ls -l `locate unpack200`
to locate unpack200.Enable C++17
Enable C++20
Right click project Properties/C++ Compiler/Additional Options and add
-std=c++20
Hope this helps!
Upvotes: 5