views:

74

answers:

3

Busy day today; asking more questions than usual... anyway....

I'm using VS2010 (downloaded via dreamspark) and although I can open the #include file by right clicking on it and pressing on Open Document, it complains "Error can not open source file "..."" which seems rather absurd. I'm using Qwt with Qt this time around and I'm specifically having the problem for:

#include <qwt_counter.h> 
#include <qwt_plot.h>

(And I am using the "<>"); not sure how to make those appear properly in the code above.

Thanks in advance.

A: 

Is the path where these files are located either the same as that of this source file, or included in the "additional include directories" in your project settings?

Project -> properties -> c/c++ section -> additional include directories.

If they are located in a subdirectory of the source file you're editing or of one of the additional include directories (I think) you can also include them with:

#include <path_to_file_1/qwt_counter.h>
#include <path_to_file_2/qwt_plot.h>

[edit] or of course what neil says [/edit]

jilles de wit
I tried both of those, but they didnt work, sadly... the odd thing is that Visual Studio seems to be able to find them, or at least open them, it's not giving an error when I ask to open the document; so it knows where it is... seemingly...
Cenoc
I have also tried moving the #include statements around relative to one another.
Cenoc
+1  A: 

As Neil indicated, try using quotes instead of the <> characters around the filename. When using the quotes, MSVC will look in the same directory as the file the #include is in for the specified file, then if it's not found there will look in the directories specified by the include path. When the filename is surrounded by <> characters, the current file's directory isn't looked at - the compiler goes right to the include path.

See http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx for details.

Note that this is an implementation dependent behavior - it might not apply to other compilers.

If that doesn't help, make sure that your include path contains the directory that the file is located in by setting the "Include Directories" property appropriately:

Finally, you might be using a makefile project (I'm not sure how common it is for Qt projects to continue to use qmake when built from VS) , in which case you'll need to perform whatever configuration is necessary in the make file(s) or parameters passed on the command line that invokes the makefiles.

Michael Burr
I'm using cmake; that's been pretty reliable in the past?
Cenoc
@Cenoc: it's not really a question of reliability - it's a question of configuration. If VS is using a makefile project, all it does is run the command line that kicks off the build - after that the compiler is invoked by makefile with whatever parameters the makefile gives it. At that point, the configuration of the VS project is out of the picture. You should make sure that however cmake needs the include directory path specified is done correctly.
Michael Burr
Ah, it turned out there was a circular linking happening and I had all my code in a .h file. Split it up and added the .cpp file, everything works fine.
Cenoc
A: 

It turned out there was a circular linking happening and I had all my code in a .h file. I split it up and added the corresponding .cpp file, now everything works fine.

Cenoc