NetBeans 7 c++ remote development host include path - c++

Maybe this is a little bit esoteric, let's see how it goes.
I'm writing a c++ program using NetBeans 7 on a Windows 7 x64 box, but building on a remote development host, which is actually an Ubuntu Server 10.4 x64 virtual machine running on VirtualBox 4.
Source files are shared using VirtualBox shared folders. I've been able to create projects, build and debug them with no problems.
However, the code assist features of NetBeans keep on complaining that none of my include files can be found, and therefore I get a code assist "unable to resolve identifier" error for every single function call.
This is not very surprising, as the include files are actually in /usr/include, which is not part of the shared folder scheme, and therefore are not directly readable by NetBeans (it can and should read them using ssh though). But I would expect for NetBeans to allow me to set remote directories for code assist. I've looked through many settings and haven't found anything resembling what I'm looking for.
Sure, it's possible to just ignore this errors, but apart from me being near-OCD, that would be the same as disabling code assist, and I really appreciate it when the IDE tells me about a typo or other things that can be done with code assist.
Any ideas?

You might want to try the following settings in Netbeans, which solved my problem of code assist on remote hosts:
1) Project Build Settings
a - Right-click on the project in the project pane, select "Properties"
b - Expand "Build" and click "C++ Compiler"
c - In the "Include Directories", make sure you set the correct Configuration (Debug or Release) at the top, click the "..." to open the "Include Directories" window
d - Put the full path of the include directory. Notice that when you click "Select", Netbeans will automatically prepend the Windows path information. Since you are developing on a remote Linux host, you must now click the "Edit" button and edit this path to resemble the Linux file path (without the C:)
2) Netbeans Code Assistance Options
a - In the Netbeans menu bar, click "Tools" and then "Options"
b - Click "C/C++" at the top, then select the "Code Assistance" tab
c - Make sure the "Tool Collection" is set to the proper remote host at the top
d - For bot the "C Compiler" tab and the "C++ Compiler" tab, click "Add" and manually type the full path to the directory you want Code Assist to index.
e - Again, when you click "Select", Netbeans will automatically prepend the Windows path PLUS change the slashes to Windows slashes (ugh)... so now you must click "Edit" and edit those paths to represent the correct Linux syntax
Hope that helps!!

Related

Change vscode C++ library path

Currently, I want to practice my C++ so I open a new folder to write some C++ codes. But weird thing happened. The editor shows me that one library bits/stdc++.h can not be resolved. Initially, I tried to delete and download MingW again at the D panel and reset the system path. But after that nothing changed.
I tracked the path of iostream (this one could be resolved) but found somehow my vscode point the library path at C->MicroSoft Visual Studio->2019....->iostream instead of D:/MingW/bin. I don't know how to solve this. So I tried running a cpp file at cmd that outputs "Hello World" to check my g++ setting, and it ran smoothly. I guess this is because my Vscode sets its library-finding path to the Microsoft VS 2019 but I can't find out where to change this.
Below will attach some screenshots as a detailed description, hope they can help you fix this question.
Note that I do not have the c_cpp_properties.json file, I also don't know why I don't have.
Now I want to set my editor library-finding path to D:/MingW/bin. Or if my assumption is wrong, please point out the correct way.
Change the header file to something wrong like "issotream". When it highlights it as an error, hover over it and select quick fix and click IncludePath. This will open a settings page, there you can add your bin path.
Open settings (UI if you're not comfortable with json), you can do it pressing
ctrl + shift + P
then select Preferences: Open Settings (UI) and search for include path. From the left drop down menu select Extensions -> C/C++ and navigate to Include Path. Here you can add new default paths.
Mind you that this will not tell the compiler anything about the libraries.

Configuration of C++ on Windows OS

I installed the MinGW-w64 C/C++ package on C:\.
What are the system environment variables I should add into the Windows OS so that I can code in C/C++ on VS Code e.g. C:\MinGW-w64...\bin, etc?
You shoul add the path of the GCC compiler
mostly it should be like C:\MinGW\Bin
(here C:\ can also be something if you put that at some other place or a different drive, I normally install it directly in C drive and it works well)
Search for Path in Windows Search, you'll find an option of "Edit Environment and Path Variables"
Open it
Go to system variables (so it can be available to all users)
Click on the path, there will be some blank lines, paste your copied path from Windows Explorer, or click the browser option to browse it.
The main thing to add in path in MinGW\Bin which contains all compile binaries)
I hope you get what I went to say.

Disable "The build directory needs to be at the same level as the source directory" warning in Qt Creator

I have a Qt project located in the folder /Users/donaldduck/OneDrive/Documents/myproject, and I want to have the build directory as a subfolder of the source directory, at /Users/donaldduck/OneDrive/Documents/myproject/build-myproject. The problem is that Qt Creator gives me a warning saying "The build directory needs to be at the same level as the source directory":
Other than this warning, the project compiles just fine. I don't even get any problems that the build directory is a subfolder of the source directory. I searched on the web to see why I get this warning, and I found that it's probably because not having the build directory at the same level as the source directory could cause problems with relative paths. But I don't have any relative paths in my program, I have all of the files in a QRC resource.
So this error is just annoying, and I would like to disable it. I've searched the web for a solution, but haven't found anything.
Also, I only get this warning on my Windows computer and on my Mac virtual machine. I have a similar folder structure (the build directory is a subfolder of the source directory) on my Linux virtual machine, but none of them give any warning. Also, before I updated Qt on Windows, I didn't get that warning, but since I updated it I've been getting this warning on Windows also.
How can I disable this warning?
Disabling not possible but the solution is to change build directory.
This warning does show if the source- and the build directory do not contain the same number of / (or \ on windows) in their absolute path names.
Assuming your source directory is "c:\dev\source\project", then "..\build-directory" is fine, but e.g. "..\build\directory" is not. "c:\dev\build\project\debug" is not ok, but "c:\dev\build\project-debug" is. "./debug" and "debug" are not ok as build directories either.
Is what you can observe as well? Or are all paths starting with "..\" triggering this warning?
Qmake will fail to build projects that are not following the "same distance from root" rule in some rare corner cases and will produce really cryptic output when it does. So we need to warn about a setup like this.
you can use your default directory like this: ../%{CurrentBuild:Name}
Screenshot:
I use this directory: ../Build/Windows/%{CurrentBuild:Name} and I don't care about the warning!
Reference: https://bugreports.qt.io/browse/QTCREATORBUG-16616
I know this post is old but since the versions of Qt have evolved a bit since then, I allow myself to post this answer to best help those who would be confronted with this problem on Qt Creator 9.0.1 :)
I set up this architecture (in my documents) to separate my sources "Projets_Qt" from my builds "Projets_Qt_Builds".
Then under Qt Creator I went to the "Edit" menu then "Preferences" and "Build & Run"
In the "General" tab I filled in "Project Directory" the folder of my sources "C:\Users\juan\Documents\Projets_Qt"
In the "Default Build Properties" tab I filled in "Default build directory" the folder of my builds "../../Projets_Qt_Builds/%{JS: Util.asciify("build-%{Proj... ...". It's a relative path built from the sources actually
Think about it :
If you perform this operation while projects have already been created, do not forget to modify the project in question.
Once your project is open, use the "Projects" menu in the right icon bar, then in the desired kit modify "Build Directory"
Hope this information can help :)

Eclipse indexing not working

I am using CDT in Eclipse 3.5.2 Galileo in Ubuntu.
My eclipse's indexer doesn't work at times. By that I mean when I ctrl click a function it says Could not find symbol in index. Also, F3 button click results in the same error message. Actually most of the places it is not working and works in very few places.
I have seen some other versions of Eclipse where under File menu a menu item listed for Indexing. Like File->Indexer->Rebuild.... But in my File menu there is no such menu item for the Indexer.
Will the only way be to use some other release of Eclipse or am missing something? Any pointers regarding this would be helpful.
In my case nothing has worked and at last I did the following:
1) Close the project
2) Delete the project(do not check from disk option)
3) create new project with existing code(use the deleted project path)
4) Successfully indexed my c++ code
To add paths containing code to parse, follow these steps :
1. Right click on the project
2. Select Properties
3. Go to C/C++ General
4. Go to Path and Symbols
5. If the paths are missing, add paths.
To re-parse the code follow these steps :
1. Right click on the project
2. Select Index
3. Rebuild
If this doesn't work, then you are out of luck. c++ is very difficult language to parse.
If your indexer is stuck and it hangs for infinite time, you can delete the indexer related files of your project from .metadata. Make sure eclipse is not running in the meanwhile.
The .metadata directory is located as a hidden folder in the path of your workspace.
There you can navigate to:
<workspace_path>/.metadata/.plugins/org.eclipse.core.runtime/.settings/
Inside the .settings/ directory there are .prefs files which store the preferences of each project individually.
For example: org.eclipse.cdt.core.prj-test-project.prefs stores the preferences of the project test-project
Open this file with the text editor and remove all the lines starting with indexer. This will reset the indexer settings for this specific project to the default.
Alternatively, you can remove all the lines starting with indexer from org.eclipse.cdt.core.prefs; doing this will reset the indexer settings for the whole workspace.
I believe you can clear the index by running:
rm .metadata/.plugins/org.eclipse.jdt.core/*.index
And then restarting Eclipse. It will then rebuild its index.
This worked for me in a Java project, but I imagine its the same index for all (most?) project types.
Right click on the project.
Select New->Convert to a C++ Project.
Select your configuration. And then Next
Indexer will start indexing all the files.
For me this worked:
Right click and close the project
Open the project again
Right click and select Index->Rebuild
I hope it helps anybody.
You can try rebuilding the index.
Right-click on the project in Project View. Then Index -> Rebuild.
Here is the solution I used after Project->C++ Index->Rebuild failed. This trick avoid deleting your current project :
1) Copy the current project (Right click->Copy from Project Explorer)
2) Paste it (Right click->Paste from Project Explorer) and give the copy another name
3) The indexer should now start and index both projects
4) When indexation is complete, you can delete the copy
PS: Make sure your original project is an actual C++ Project or this will obviously not work.
Convert a project to C or C++ nature:
Right click on project: New >  Convert to C/C++ Project
In "Convert to C or C++": Choose C/C++ Project
In "Project options": Check "Specify Project Type"
...Project Type: Choose "Makefile project"
...Toolchains: Gross GCC
I was having the same problem and it turns out that the index folder was owned by root (I must have run Eclipse as a root once for some reason) I reclaimed the project folder using sudo chown -R username projectfolderpath and problem solved.
Execute eclipse.exe -clean -refresh where the eclipse is installed.
Create a new C/C++ Project in Eclipse with Given Source code folder path. (Not with New Project based on existing workspace)
Above steps worked for me.
For me it was issue that when creating a project indexer was chosen as none. Deleted the project and while creating the project again I chose the indexer options as per my need "LINUX_GCC", then it worked for me
Just came across the same problem in my C++ ARM Cross GCC project. I'm developing on Windows, using Makefile and an Ubuntu Docker image with GNU ARM Embedded Toolchain to build the project.
The solution to get rid of the unresolved symbols, in my case, could be divided into two parts:
The CDT Arm Cross GCC Built-in Compiler Settings didn't have the path to the compiler.
In the Project Properties -> C/C++ General -> Preprocessor Include Paths -> Providers(tab) the path to the compiler must be provided.
Using the GNU ARM Embedded Toolchain, the entry for the Command to get compiler specs: I currently use is:
C:\GNU_Arm_Embedded_Toolchain\9-2020-q2-update\bin\arm-none-eabi-g++.exe ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"
Note: Yes, I am having installed the same toolchain on my Windows machine as I'm using in the Docker image.
To verify, that the call is correct, you can tick the Allocate console in the Console View, which will provide hlepful output to the Console. Also, in the Entries tab, when you unroll the CDT Arm Cross GCC Built-in Compiler Settings you should see the includes and symbols included.
Missing symbol in the Project Properties -> C/C++ General -> Paths and Symbols menu.
As I have my defines in the Makefile, I forgot to add the define of my MCU also here.
Hope this helps to someone! :)
For the most part, the other answers tackle the situation wherein one "had" a working index earlier and things have gone astray for some reason.
On the other hand, I faced a problem wherein I needed to install everything from scratch (eclipse, workspace, c++ project etc.) and the indexing just wouldn't work. I finally found the solution here: https://www.eclipse.org/forums/index.php/t/1109004/
The key inputs from the above page are:
You need to setup include paths for the Indexer just as you would need
to for the compiler. The Indexer and compiler are completely independent.
The Indexer include paths are set by
Project -->Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab --> CDT UserSettings Entries ...
and
You could try using
Project --> Properties --> C/C++ General --> Paths and Symbols
That's supposed to merge telling the compiler and Indexer
in one place.
However, this latter part of the suggestion did not work for me.

How Do I Use Eclipse to Debug a C++ Program on Linux?

I don't use Eclipse as an IDE, and have no interest in doing so. However, I do like its source-level debugging.
Is there any way I can use it to debug a C++ Linux app without going through the ritual of creating a project? (In effect, can I just use it like a frontend to gdb?)
If not, what are the steps I need to follow to create a project that I can use to just debug an existing C++ program that is built using Makefiles or other tools (SCons, CMake, etc.). I don't want to be able to "develop" in Eclipse; all I need to do is debug.
Take a look at this question. Create a C/C++-project, use your project's source directory as project directory, select to use the external builder, and change "make" to whatever tool you want.
The tricky part is to get the indexer to work correctly and find all your header files.
EDIT: CMake 2.6.x has support for generating CDT project files, which might be a more straightforward solution.
I don't know if this has changed in the 4+ years since the question was posted, but there's a much easier way to do this. I'm on Eclipse Luna (4.4.2).
> eclipse&
then
File > Import > C/C++ > C/C++ Executable > Next > browse to executable > Next > choose a project name > Finish
No other project setup required, no source paths (which should be in the object code). Just like running gdb/insight/etc. Almost makes it worth installing Java.
Configuration for debugging in Eclipse.
In eclipse,
Go to Window->preferences
A popup will appear then select C/C++ , click on drop down arrow ,then select Debug and click on drop down arrow.
Select Source Lookup Path and then click on Add.
After clicking on Add, click on Path Mapping and then click on OK.
Specify the mapping path name and then click on Add .
In compilation path select Cygwin path (need to install) and then click ok .
In debug option,click on source Lookup Path and select Path Mapping:Project source and click on apply and then ok.