Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error can not open source file "..."

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.

like image 225
Cenoc Avatar asked Jul 11 '26 23:07

Cenoc


2 Answers

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:

  • http://msdn.microsoft.com/en-us/library/t9az1d21.aspx

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.

like image 125
Michael Burr Avatar answered Jul 14 '26 11:07

Michael Burr


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]

like image 28
jilles de wit Avatar answered Jul 14 '26 11:07

jilles de wit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!