Hello everybody,

Ran into a bit of trouble! During compilation I get the following error:

fatal error C1083: Cannot open include file: 'login.h': No such file or directory

The login.h does exist in my directory folder.

Please let me know where I have gone wrong.

I am attaching the following files:
lib_test.cpp
login.h

Recommended Answers

All 11 Replies

just as well you got that error because NEVER EVERY UNDER NO CIRCUMSTANCES put executable code in a header file (inline functions are the only exception.) Take that function out of that *.h file and put it in a *.cpp file. Then compile the two *.cpp files separately and link the object files together. Exactly how to do that will depend on the compiler you are using.

just as well you got that error because NEVER EVERY UNDER NO CIRCUMSTANCES put executable code in a header file (inline functions are the only exception.) Take that function out of that *.h file and put it in a *.cpp file. Then compile the two *.cpp files separately and link the object files together. Exactly how to do that will depend on the compiler you are using.

I am using MS VC++ 2008 Express version.

I did exactly what you said.

It is showing the exact same error again twice......

This error is in the include.h file

fatal error C1083: Cannot open include file: 'login': No such file or directory

fatal error C1083: Cannot open include file: 'login': No such file or directory

Now, Do you suggest to change all my .h file to .cpp?

So -- where is <login> header file? Is that the same file you posted previously but as login.h? If it is, it belongs in the same folder as the other *.cpp files in the project.

>>Now, Do you suggest to change all my .h file to .cpp?'
Not at all -- only the ones with executable code.

All the files are in the folder.
But still it is failing to find the file

zip up your entire project folder and attach it so that I can see what the problem is.

zip up your entire project folder and attach it so that I can see what the problem is.

PSA below!

Ancient Dragon! Did you find the cause to the problem?

Thanks

1) in login.cpp change #include <login> to #include "login.h" 2) in include.h, change #include <login.h> to #include "login.h" When surrounded by angle brackets < and > the compiler does not look in the project directory for include files. You have to put it in quotes to do that.

After you fix that you will get a lot of other errors.

1) in login.cpp change #include <login> to #include "login.h" 2) in include.h, change #include <login.h> to #include "login.h" When surrounded by angle brackets < and > the compiler does not look in the project directory for include files. You have to put it in quotes to do that.

After you fix that you will get a lot of other errors.

Well Yeah.....20 errors in total.....which includes an include file error??

Well Yeah.....20 errors in total.....which includes an include file error??

Nope -- here are the errors I get. As you can see, the first error is about undefined symbol "printMenu". Fix that up and recompile. I'm not going to fix all the errors in this program for you -- that is for you to do.

1>c:\dvlp\tmp\lib_test\lib_test\login.h(31) : error C3861: 'printMenu': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(99) : error C2084: function 'int login(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\login.h(9) : see previous definition of 'login'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(138) : error C2084: function 'void printMenu(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\menu.h(7) : see previous definition of 'printMenu'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(159) : error C3861: 'login': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(179) : error C2084: function 'void viewFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\view.h(7) : see previous definition of 'viewFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(186) : error C2084: function 'void options(int)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\menu.h(7) : see previous definition of 'options'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(196) : error C3861: 'viewFile': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(208) : error C2084: function 'void createFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\create.h(9) : see previous definition of 'createFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(233) : error C2084: function 'void readFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\read.h(6) : see previous definition of 'readFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(249) : error C2084: function 'void exitScreen(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\exit.h(8) : see previous definition of 'exitScreen'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(258) : error C2084: function 'void editFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\edit.h(10) : see previous definition of 'editFile'
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(260) : error C3861: 'readFile': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\lib_test.cpp(279) : error C2084: function 'void searchFile(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\search.h(9) : see previous definition of 'searchFile'
1>login.cpp
1>c:\dvlp\tmp\lib_test\lib_test\login.h(11) : error C2065: 'string' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(11) : error C2146: syntax error : missing ';' before identifier 'username'
1>c:\dvlp\tmp\lib_test\lib_test\login.h(11) : error C2065: 'username' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(12) : error C2065: 'string' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(12) : error C2146: syntax error : missing ';' before identifier 'password'
1>c:\dvlp\tmp\lib_test\lib_test\login.h(12) : error C2065: 'password' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(20) : error C2065: 'cout' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(21) : error C2065: 'cin' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(21) : error C2065: 'username' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(22) : error C2065: 'cout' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(23) : error C2065: 'cin' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(23) : error C2065: 'password' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(25) : error C2065: 'username' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(25) : error C2065: 'password' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(29) : error C2065: 'cout' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(30) : error C2065: 'cout' : undeclared identifier
1>c:\dvlp\tmp\lib_test\lib_test\login.h(31) : error C3861: 'printMenu': identifier not found
1>c:\dvlp\tmp\lib_test\lib_test\login.cpp(10) : error C2084: function 'int login(void)' already has a body
1> c:\dvlp\tmp\lib_test\lib_test\login.h(9) : see previous definition of 'login'
1>c:\dvlp\tmp\lib_test\lib_test\login.cpp(31) : error C3861: 'printMenu': identifier not found

Nope -- here are the errors I get. As you can see, the first error is about undefined symbol "printMenu". Fix that up and recompile. I'm not going to fix all the errors in this program for you -- that is for you to do.

WOW! petty i never got so many errors;)

Anyhow brother I recreated my project in VC++ and avoided having so many .h files to which I realised I didn't needed to! So instead created on whole .cpp file with all the classes and functions.

Anyways thanks for all the support.

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.