Click here to Skip to main content
14,696,499 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a project which works successfully when its in release mode but it gives a fatal error in debug mode how to clear this error in debug mode.

Should I include library files in debug mode in the linker? If yes what are the actual library files I can include to solve this problem.

The project is created using 7.1 vc++ mfc i am running in debug mode in vc++9.1 is it causing problem?
Posted
Updated 19-Jan-12 19:51pm
v4
Comments
CPallini 19-Jan-12 7:12am
   
Could you please report here the exact error message?
chaiein 19-Jan-12 7:14am
   
>d:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\directmidi\csegment.cpp(380) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 9.00.21022
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>BSCMAKE: error BK1506 : cannot open file '.\Debug\CCollection.sbr': No such file or directory
CPallini 19-Jan-12 7:21am
   
Compiler is telling you "stdafx.h" is missing. Check if it is really missing (or disable precompiled headers in Project settings).
chaiein 19-Jan-12 7:27am
   
I included stdafx.h in csegment.cpp and disabled precompiled headers
I got 1>d:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\piano\piano.cpp(41) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
1>Octave.cpp
1>d:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\piano\octave.cpp(42) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
1>Object.cpp
1>d:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\piano\object.cpp(34) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
chaiein 19-Jan-12 7:30am
   
when i commented the stdafx in csegment.cpp I got the above fatal errors.

If i remove the comment i am getting

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

cannot open file '.\Debug\CCollection.sbr': No such file or directory
CPallini 19-Jan-12 7:37am
   
You shouldn't do both: EITHER you disable 'precompiled headers' in you project settings (and comment out '#include "stdafx.h"' in all of your sources) OR include stdafx.h (as the very first header) in csegment.cpp.
chaiein 19-Jan-12 7:49am
   
I included stdafx.h as the very first header and able precompiled headers but ended up with 103 Errors

1st error:
c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(717) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CPallini 19-Jan-12 7:53am
   
Looks a UNICODE issue, see
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.atl/2006-07/msg00011.html
chaiein 19-Jan-12 23:32pm
   
i gave multiple unicode still does not work:(
chaiein 19-Jan-12 23:57pm
   
1>Dmhelp.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(717) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(718) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(719) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(720) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(721) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(722) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(723) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(724) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(728) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(729) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(730) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(731) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(810) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(811) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlconv.h(812) : error C2440: 'return' : cannot convert from 'LPWSTR' to 'LPTSTR'
1> Types pointed to ar
Jochen Arndt 20-Jan-12 3:19am
   
As already mentioned by CPallini, it looks like a UNICODE issue. Did you read the link from his comment? Please check all your project files for lines containing '#define _UNICODE' or '#define UNICODE'. There must be none. With Unicode builds, the definitions are passed to the compiler on the command line when Unicode is enabled in the project settings.
Jochen Arndt 19-Jan-12 7:14am
   
Please tell us which specific error occurs. Otherwise, we can't help you.
chaiein 19-Jan-12 7:18am
   
>d:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\directmidi\csegment.cpp(380) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 9.00.21022
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>BSCMAKE: error BK1506 : cannot open file '.\Debug\CCollection.sbr': No such file or directory


This is how i get error.
chaiein 19-Jan-12 7:36am
   
fatal error C1083: Cannot open include file: 'StdAfx.h': No such file or directory



Please help me how to clear this.I have StdAfx.h and StdAfx.cpp files in the project folder. stdafx.h and StdAfx.h are they same or different? whether i include stdAfx or stdafx.h i get those files not found
Jochen Arndt 19-Jan-12 7:55am
   
The case does not care. There should be only one file. But the path 'd:\new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\directmidi\csegment.cpp(380)' looks curious. What is your project folder's path where the stdafx.* files are located? If it is not the same path and the file csegment.cpp is located in a subdirectory, you may use '#include "..\stdafx.h"' (or even '..\..\stdafx.h' if it is 2 directories above).
Kethu Sasikanth 19-Jan-12 9:52am
   
Do you have #ifdef preprocessors one for debug and another for release? If so check what is it inside.
Guyverthree 19-Jan-12 12:52pm
   
Be sure to check that you have not inadvertently, changed the include paths on your project in debug mode so that they differ from the release versions....
chaiein 20-Jan-12 0:22am
   
I a using visual c++ 9 version but the project was built 7.1 version is it causing problem?

1 solution

Judging by the error(s) you got, your project settings have to be different for Debug and Release mode regarding the use of precompiled headers.

Note that the decision to use or not use precompiled headers affects the entire project, and every cpp file in your project! If you set the options to use them, all cpp files must include the associated header file (usually stdafx.h) as the very first line in that file (except comments or empty lines). If that is not the case, you get the error message that you mentioned. Of course, the include statement by itself is not sufficient, if the header file does not exist, or cannot be found: make sure it's there and part of your project, and that the directory it's stored in is accessible through your include path.

Note that even if you don't use precompiled headers, you normally still need to include the associated files as it declares types that you may reference or includes other headers that do. So, commenting out the include statement is almost always an error!

If you're unsure about the required settings, compare with the settings you used for the Release version, or ask here.
   
Comments
JackDingler 19-Jan-12 17:48pm
   
Just to add, you can enable and disable this on a file by file basis.

You do this by selecting the files in the solution, right clicking and choosing properties. You can then change the compiler settings for those specific files.
chaiein 19-Jan-12 23:23pm
   
I have added stdafx.h in a newfolder which is inside the project and i have included as below
#include ".\\newfolder\\stdafx.h"

Also I have made Precompiled headers able

new midi updated\directmidi_src2_3b (2)\directmidi_src2_3b\midistation\midistationdlg.cpp(1382) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>BSCMAKE: error BK1506 : cannot open file '.\Debug\CCollection.sbr': No such file or directory
Stefan_Lang 20-Jan-12 4:06am
   
At this point I feel that your project settings concerning precompiled headers are messed up for good. I suggest not using them, i. e. change your project's settings to not use precompiled headers.

The only alternatives I see are
1) you read up on precompiled headers in the MSDN help documentation and fix it based on that information
2) you scratch the project and use the built-in wizerd to create it new, from scratch.

I doubt you are keen on either, so switching off PCH seems to be the best for now.

Note that, as mentioned before, your files may still depend on many headers, from windows, the core system, and more. The main purpose of the precompiled header is to put all that stuff into one header file (stdafx.h) and include that from every cpp file. That's how all the projects created by the wizards are set up anyway. If there's nothing in your stdafx.h, it won't fix your problems of missing type declarations: it does still need to include the relevant headers!
chaiein 20-Jan-12 0:06am
   
I have included:
"kernel32.lib dxguid.lib Uafxcwd.lib dsound.lib dxerr9.lib winmm.lib" in additional Dependencies of Input of Linker. in Debug Active


Even if i copy same files what is in Release additional dependencies and replace above contents with the copied one also there is no use:(
Stefan_Lang 20-Jan-12 4:08am
   
Adding these libs only tells the Linker where to find the object files that contain the system functions you use. That doesn't help the Compiler though! As long as the Compiler issues errors, you got to fix those!
chaiein 20-Jan-12 0:09am
   
Which are the files i should enable or disable on what bases should i select?
chaiein 20-Jan-12 0:11am
   
1>Dmhelp.cpp
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(717) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(718) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(719) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(720) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(721) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(722) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(723) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(724) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(728) : error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(729) : error C2440: 'return' : cannot convert from 'LPCOLESTR' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(730) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPOLESTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(731) : error C2440: 'return' : cannot convert from 'LPOLESTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(810) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(811) : error C2440: 'return' : cannot convert from 'LPTSTR' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlconv.h(812) : error C2440: 'return' : cannot convert from 'LPWSTR' to 'LPTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\P
Stefan_Lang 20-Jan-12 4:21am
   
This indicates you have included some system headers out of order.

The best way to include system headers is to just go along with the settings and files that the project wizards provide for you. Among other things, they will add the appropriate include statements for your project into stdafx.h.

The fact that you didn't have one indicates you removed it, or maybe that you tried to manually set up the project. That makes it somewhat hard to restore stdafx.h to a proper state - especially when giving remote advice.

One thing you could try is to just add the following line to your stdafx.h:
#include <windows.h>

You can add other include statements after that line if you wish, but not before.

If that doesn't fix the problem, the best alternative I can think of is create a new project using the project wizard, then add your cpp and h files to recreate the project.
chaiein 20-Jan-12 0:14am
   
based on the above errors should i change the version instead of 2008??Please help me:(
Nathusingh Rathod 20-Jan-12 5:10am
   
In case if you are using any macro for release mode but not for debug mode then also it might create problem.So just check it in preprocessor definitions tab in project settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900