Click here to Skip to main content
16,020,381 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 18: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

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.
 
Share this answer
 
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!

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