How to make Netbeans remove deleted files from the project? - c++

I am developing a C++ program using CMake as a Makefile generator. I have added the project as an existing source to the Netbeans and everything works nice except when I update lists of dependencies for my build targets.
Netbeans is able to get the new files added to the project, but keeps removed files hanging with a small yellow warning icon in the list of files. So the only way they could be removed is to manually in the GUI or by removing them from configurations.xml in the project.
As far as I understand the issue is about the way Netbeans scans for external changes. Is there a way to tell it to remove deleted files from the project?

You can try solutions mentioned here:
right click on your project in the "Projects" window,
click on "Properties",
click on "Ignored folders" in the left panel called "Categories",
click on "Add folder" and select the folders you want to ignore.
You can also clear the cache located in:
C:\Users\username\.netbeans\7.0\var\cache. //Deleting this directory should clear the cache for you.

To remove a file name with no file from my C++ static library project...
< File < OpenProject < "YourProject" (< means left click) (Leads To Projects.)
< Source Files > a.cpp < Remove File From Project (> means right click)
< Header Files > a.h < Remove File From Project (And the header file.)
I'm using netbeans 8.2. Curiously only c.cpp is listed under "Source files".
And only c.h is listed under "Header Files".
All the other (actual, real) source and header files are listed under "Important Files".

Related

How can I tell Visual Studio to use the project directory instead of the current file directory when including files?

I am refactoring my Visual-Studio-C++ project to use a folder structure rather than the filters in Visual Studio but I have noticed that when I try to include a file, it will use the current directory of that file so my includes look something like...
#include "../../server/IGameServer.h"
This is quite problematic when I refactor and move things around as I then have to go into each file and change their includes...
Is there a way to make every file start from the base directory no matter where the current file is, or a way to include the folder path so I can just use
#include "IGameServer.h"
(1) Go to project properties:
And add folders to "Addiotional Include Directories". ...Make sure that you aply to "All Configurations" (Debug, Release, etc.) and "All Platforms" (X86, X64).
--
(2) Click on that line + one more click on right side, on the down-arrow) & click Edit.... It opens a dialog that looks like that (I already added some folders in this example):

Open files in NetBeans 8.0.2 are kept in the project file thus making it dirty in GIT

I've been using NetBeans for the last couple of years and only recently upgraded to 8.0.2. It seems that the new project file tracks which files are open in the project workspace (C++) and thus the project file appears as modified whenever I open Netbeans, although I haven't changed anything. Is there a setting to disable this?
Create a file named ".gitignore" in the top-level directory, if it does not
already exist.
Add the line:
nbproject/private/
To do this with Netbeans:
Window -> Files, Select the Directory and right-click for Pop-up.
New -> Other ... -> Empty File.
Name the file ".gitignore"
When you do diffs and commits etc. it should ignore the private files that might have changed.

Use source files in different directory in NetBeans Dynamic Library Project

I am new to C++ and NetBeans and I am trying to build a Dynamic Library project using it :). I want to build a plugin which uses source files located in different directories, and would like to keep them separately (as its a plugin ;)). I already tried to include the directory where the source files are located using Properties > Build > C++ Compiler > Include Directories, but it still gives errors in referencing to these files. These errors say the following:
"Cannot find include file "vtkPolyDataAlgorithm.h" "
Can anyone help me on this? I assume its a bit of a basic-basic-basic question, but I'm trying to learn autodidactically as a geologist from background, so you might see my problem :). I really hope you can help me out! Thanks :)
Ellen
While your way is the default way to add directories which contain additional headers (e.g. for libraries), you can add further Source-directories using Properties -> General -> Source Folders (-> Add).
It's also possible to add files (cpp / h) to your project, without setting a directory:
Right click on your project -> Add existing item ... or Add existing items from folders ...
But you have to care about your paths, you may have to browse to the headers using #include "../headers/here/example.h.

How to add FastMM to a C++ Builder project?

I'm trying to configure FASTMM4 for Builder C++ 6 and the steps I followed are;
Downloaded zip from sourceforge.
Under the Project -> Options -> Linker menu I unchecked "Use Dynamic RTL".
Unzipped the contents at C:/tools/FASTMM and added FASTMM4.pas file to my test C++ VCL project.
Simply compiled the unit from Project menu and got a new FastMM4.hpp file in FastMM folder.
Included FastMM4BCB.cpp file in my project and also wrote #include <FASTMM4.hpp> on the top.
Added path to FastMM_FullDebugMode.dll and FastMM_FullDebugMode.lib and moved FastMM_FullDebugMode.dll to the Bin folder in Builder C++ install directory.
Enabled the line {$define FullDebugMode} from FastMM4Options.inc.
Did I miss anything? why do I have the following errors?
I found the instructions in FastMM4BCB file itself and I got it working.
Usage:
Copy FastMM4BCB.cpp, FastMM4.pas, FastMM4Message.pas, FastMM4Options.inc,
and FastMM_FullDebugMode.lib to your source folder.
Copy FastMM_FullDebugMode.dll to your application's .exe directory (if you
intend to use FullDebugMode).
To your project, add FastMM4Messages.pas first, then FastMM4.pas, then
FastMM4BCB.cpp. On compiling the .pas files, .hpp files are created and
imported by the subsequent files.
Add USEOBJ("FastMM4BCB.cpp") to your project file, BEFORE any other
USEFORM directives.
Under the Project -> Options -> Linker menu uncheck "Use Dynamic RTL"
(sorry, won't work with the RTL DLL).
FastMM will now install itself on startup and replace the RTL memory manager.

"Error C1083: Cannot open source file" Shouldn't Be Looking For The File At All

I was trying to #include a cpp file with some functions so I can use that cpp file later with other projects. It gave me an 'already defined in .obj' error and since then that .cpp file was like binded with my project. (I understood that's not the way, the answer here helped me with the already defined)
If I exclude the .cpp file from the project, remove it from the directory and remove the #include line it still looks for it:
c1xx : fatal error C1083: Cannot open source file: 'std.cpp': No such file or directory
Diagnostic:
Outputs for D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\CBMAIN.CPP|D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\STD.CPP: (TaskId:15)
It shouldn't be looking for the std.cpp at all, I removed it! So is there a way I can reset the project and recompile so that the program doesn't look for it? I already tried Rebuild and Clear -> Build Project
When I ran across a similar problem with VS Express, I wound up having to open up the the .vcxproj file (which is just XML), and remove the offending
< ClInclude Include="FILEPATHANDNAME" > tags.
Many of the solutions here will not work
Fullproof method:
Open the vxproj file that is giving you trouble in a text editor.
remove all references to the file it cannot find.
OK, I have no idea how I did it but I'm still going to try to write what I did.
Save all and Close solution
Open the .vcxproj file (not .sln)
Build -> Clean [Project Name]
Save all and Close
Open the .sln file again.
Build -> Project Only -> Clean Only [Project Name]
Build -> Project Only -> Build Only [Project Name]
That's exactly what I did and worked for me. I think the main thing to do is clean, save, close, open, build, but I'm not sure.
In Solution Explorer you can select/deselect option "Show All Files".
Try both options and make sure excluded file is not included in project for both of them.
That's what I had:
I used "Show All Files" option (so you can see all the files in project directories). I excluded one of my .cpp files from project. However, it behaved as this file is in project.
That's how I managed to fix it:
I switched "Show All Files" off and saw this file still belongs to project! So I excluded this file once again.
As I see, that's a known issue.
This worked for me, hope it will be useful for someone else.
Try to verbose builder output to see exact steps of what's going on. I suppose, you use Visual Studio, right?
Go to menu "Tools -> Options"
In options dialog, select "Projects and Solutions -> Build and Run"
Change current mode of "MSBuild project build output verbosity" from "Minimal" to something like "Diagnostics" or "Detailed".
Rebuild your project and investigate Output windows
Builder dump should shed more light on your current settings (I suspect you have more references to that file than you expect)
This happened to me because I renamed folder from inside the IDE. None of the above solutions worked. The only way to fix this is by opening vcproj in notepad and you should see the offending files in the <ItemGroup>. Just delete those lines.
Or sometimes, like in my case, the issue is simply in the naming of the folders in the location. I had a very long path with folders that I like to name with special characters so they show up at the top and it's easy to access them.
As soon as I put my solution in a folder just in D: drive, the issue was gone.
When I renamed a file, I found I had to go to SolutionExplorer, Source File, select the file, first exclude from Project, then re-add it to project, and rebuild the solution it lives in. It was still showing up as the old file name under Source Files for me.
I had the same problem, but I had another .sln worked fine. After tooling around with the Project->Properties-> to make them look identical, nothing worked. I opened both .vcxproj files and copied the contents of the working version into my non-working version. (I noticed that the two files had different lengths. The non-working version was longer by about 20 lines.) I just changed the RootNameSpace to the non-working version's name. I saved the non-working file and presto! It worked.
I removed those sources from Project and re-added them. Somehow, references were messed up after a hurry project refactoring.
For people having problem related to "error C1083: Cannot open source file":
Error is caused by settings in *.vcxproj file. Probably you deleted/moved source file by file explorer, not by Visual Studio's "Solution Explorer". Thus, your *.vcxproj file is corrupted. Fix is to manually correct settings in *.vcxproj file.
How Visual Studio settings files work
Visual Studio saves solution's info into file. This file is usually in project's solution directory, has extension .sln and base name is same as name of solution, f.ex.:
NameOfSolution.sln
Similarly, project's info is saved into one file (each project has its own file). Base name of this file is name of project, extension is .vcxproj, and usually is located in subdirectory named as your project, f.ex.:
NameOf1stProject/NameOf1stProject.vcxproj
NameOf2ndProject/NameOf2ndProject.vcxproj
Both *.sln and *.vcxproj files are textual files. You can open them by using Notepad.
How to fix problem
Find *.vcxproj file responsible for your project.
If you don't know where it is, open in Notepad the *.sln file of your solution. Search for name of your solution. You will find line like:
Project("{9AA9CEB8-8B4A-11D0-8D22-00B0C01AA943}") = "NameOf1stProject", "NameOf1stProject\NameOf1stProject.vcxproj", "{A8735D0A-25ED-4285-AB8F-AF578D8DB960}"
Value under "NameOf1stProject\NameOf1stProject.vcxproj" is location of *.vcxproj file of your project.
Open found *.vcxproj file by text editor (f.ex. Notepad).
Search for line on which is filename you are struggling with.
Example: if you are looking for "RemovedFile.cpp", then you should find line:
<ClCompile Include="RemovedFile.cpp" />
Delete that line.
If you have opened Visual Studio, it asks you if it should refresh solution - select yes. If it is not opened - just start using it.
In case of any problems, try to rebuild solution (top banner -> Build -> Rebuild Solution)
In my cases, it worked. 30 mins of trying to fix, <1 minute of fixing.
This helped in my case. To sum it up, my path to the project was too long, so I moved my project to something shorter i.e. D:\my_project and everything worked in a blink of an eye.
I had this same problem, but for me the issues was that I was using Bash on Windows (WSL) to clone the repository and then using VS to compile.
Once I deleted my clone and used Windows command line (cmd.exe) to clone the repo then the error 1083 went away.
This is caused by not removing/deleting the file properly. Go to Solution Explorer, select your solution, at the left corner, activate the icon: show all files.
(if you already removed the problem file, restore it from recycle bin)
Select the problem file, do remove and delete from within Solution Explorer and you should not have this problem. And remember to do it the proper way from now on.
This is on MS 2010
If you have that file in your project directory but you still got the error, on your IDE go to Solution explorer--> Remove that file-->then open the project directory on your file explorer-->Select that file and drop it on a specific location in IDE solution explorer. I fixed it this way. I use the Windows platform.
I got this error when I got a code from my peer and I tried directly running it on my system. Ideally to avoid such errors, I should have just copied the source and header files and should have created the VS solution of my own.
To resolve the errors I removed the files from the Solution Explorer and added them again. Following image shows the Solution Explorer window.
The remove option comes after right clicking on the file names.