Visual Studio keeps referring to old files
for my project where I'm working on, I've run into the problem where Microsoft Visual Studio 2010 seems to keep referring to old files, even when these have been excluded from the solution and new ones have been imported.
The situation in a whole: I had a project where I've created a slightly different version of a specific class (a SIFT feature extractor, in case people are curious) which is a little bit more optimised and also fixed a bug or 2 that were in the code I found on the web. The result was me creating the following new files:
- SIFT.h - My version of the header for the feature extractor class
- SIFT.cpp - My implementation of the feature extractor class
- Keypoint.h - A header that defines the 'Keypoint' object, which is used by the feature extractor.
- Descriptor.h - A header that defines the 'Descriptor' object, which is the description of a Keypoint object.
These files added to a solution, which was built on OpenCV 2.2 version (which is a Computer Vision library), and this has the right linking to the libraries of the OpenCV 2.2 version. Compiled, ran it, works.
I had to change back to OpenCV 2.1 because of video support, which isn't working properly in 2.2 (or at least, I'm having problems with that version). For this I made a new solution, and linked everything to libraries of OpenCV 2.1. The files I mentioned above, I 'imported' them by right click corresponding folder -> Add -> Existing Item. So I imported the SIFT.cpp into the Source Files folder, and the 3 headers into the Header Files folder. Compiled, ran it, works.
Now comes the part where my problem occurs. A colleague of mine asked me to see what actually happens when I use the code I based mine on (that had the bugs in it and was slightly less optimised). So I removed the files I 'imported' with the 'Add-> Existing Item' method above, and then imported the other files also with the 'Add -> Existing Item' method. The files added are: - SIFT.h - The original version of the header for the feature extractor class - SIFT.cpp - The original implementation of the feature extractor class - KeyPoint.h - A header that defines the 'Keypoint' object, which is used开发者_StackOverflow社区 by the feature extractor. - Descriptor.h - A header that defines the 'Descriptor' object, which is the description of a Keypoint object. Note that there files indeed have almost the exact same names, but still have different content. I fixed a few interfacing errors because if different capitalization, then compiled it... And got these:
error LNK1120: 1 unresolved externals
C:\Users\my name\Documents\Visual Studio 2010\Projects\name solution\Release\name solution.exeerror LNK2001: unresolved external symbol "public: void __thiscall SIFT::doSift(void)" (?doSift@SIFT@@QAEXXZ)
C:\Users\my name\Documents\Visual Studio 2010\Projects\name solution\name solution\Executables.objI then noticed that the program is referring to the "doSift" method of the SIFT class, which is the naming of my version of SIFT, and not the other version I got from the internet which uses the name "DoSift" instead! I then started to check referencing in the code that uses the SIFT object (right click -> Go to Definition) and it refers to my version of SIFT.cpp instead of the other one that is now added to the solution (and is the only one in the solution.) The same applies to the headers... Visual Studio is referencing my versions that are not longer even in the solution, instead of the ones it should check which are in the solution.
I probably can work around this issue, by just creating a new solution from scratch. But that also means I have to set up the linking to the OpenCV files... And surely there is a way to prevent this additional work each and every time I would like to use a different version of the code.
I've already tried cleaning the solution (using the Clean Solution from the right click menu) and rebuilding after that. But that doesn't solve the issue. I'm not using any type of version control what-so-ever, because frankly... I don't understand these yet.
Anyone able to help me out with this one? Thanks in advance, Xilconic
A few things you might check. First, make sure you are not referencing any extra include directories (check the project ==> properties ==> c/c++ ==> general ==> "additional include directories" setting). Second, I've found it helpful to actually open the vcproj file directly to see where the files are being pulled from.
精彩评论