2

I have a header file called simpio.h, which is in the same folder as the file which is including it in its header. However, I keep on getting the error "Cannot open include file: 'simpio.h': No such file or directory." I am using Visual C++ 2008 Express Edition. Help would be appreciated.

Thanks

user1943827
  • 113
  • 2
  • 8
  • Are you using `<>` or `""`? Because angle-brackets could be problematic. – yzt Jul 27 '13 at 21:45
  • 1
    You need to show your current code attempt(s) so we can better assist you. You are probably using < > when you should be using " " – Paul Renton Jul 27 '13 at 21:45
  • check [this](http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename) – bibbsey Jul 27 '13 at 21:49

2 Answers2

4

You need to use double quotes:

#include "simpio.h"
Sector95
  • 641
  • 6
  • 12
  • #include using namespace std; #include "simpio.h" int main() { int sum = 0; cout << "Hellasdasdsdadsadsadsasdasdasdasddado\n"; cin.get(); sum = sum + 1; return 0; } erorr is :1>Linking... 1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 1>Debug\SecondProject.exe : fatal error LNK1120: 1 unresolved externals – user1943827 Jul 27 '13 at 21:48
  • Please add your code to the original question, it really makes diagnosing the problem much easier. Based on my quick Google, it sounds like a linker setting: http://social.msdn.microsoft.com/Forums/vstudio/en-US/14e85604-6929-4707-a22e-8cdf596926a6/msvcrtdlibcrtexewobj-error-lnk2019-unresolved-external-symbol-winmain16-referenced-in – Sector95 Jul 27 '13 at 21:52
  • 1
    When you created the project, you should have chosen "Win32 Console Application" and not "Win32 Application". Only a console application is a standard C program with a "main" function. – librik Jul 28 '13 at 02:54
3

You have to know that you should use <> when you are trying to include a standard library header or when you want to include a file for which the path is contained in the Additional include directories option.

You have to use "" when you whant to include a file who doesn't satified the previous explanation, let's say that it is almost always file specific to your project.

Some example :

#include <iostream>           // library file
#include <boost/thread.hpp>   // there is "C:\SDKS\boost in my Additional include directories

#include "MyHeader.h"             // Local file, at the same place of my .vcproj
#include "Header/AnotherHeader.h" // Local file in a folder named "Header"

In your case, we can think that you are in the second case. You just have to do :

#include "simpio.h"

Or if your file is in another folder :

#include "SomeFolders/simpio.h"
Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62