Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It is rather strange situation, guys. I have a WTL template and compiler has no objections, compiling it. Excellent. Then I create an empty project and move files from the old project- one file by one. Same files, same include files and so on. But compiler is barking- it gives me this:
Severity Code Description Project File Line Suppression State Details
Error C2065 'CDCHandle': undeclared identifier Merge C:\Download\WTL\Include\atlgdi.h 1759

As you may see, the problem occurs inside one of WTL files. Why one project can be compiled but the other- similar- cannot?

What I have tried:

I do not know, what to do. I only tried exclude precompiled headers, then to use them, but without success
Posted
Comments
OriginalGriff 18-Mar-24 10:03am    
Have you checked that the order of the #include lines are the same in both projects?
Member 14105155 18-Mar-24 11:29am    
both lists of include files are the same- I'd taken stdafx.h from the first project and moved it to the second project
11917640 Member 18-Mar-24 10:24am    
Compare compiler command lines in two projects. You can find command lines in the log files, see Debug/Release project subdirectories. Another way to get more information about project build process is "Project build verbosity", you can find it in Tools - Options - Project and Solutions - Build and Run.
Member 14105155 18-Mar-24 16:26pm    
I did. I ran through all compiler's options. set "use precompiled headers" from Yes to Create and No. And miracle happened- compiler stopped barking. But the linker gave me this: cannot open 'libtiff.lib', used as an additional dependency. Hope, you understand, that the aforementioned file was (is) in the same folder with other project's files
11917640 Member 19-Mar-24 0:58am    
Cannot open 'libtiff.lib' - what is exact message? File is not found, or not recognized as valid lib file? To handle "File not found" situation, provide the full name (including path) in Additional linker dependencies. Does it work now? Then you need to understand, what is current build directory - probably not what you think. Finally, remove full path from the lib, and use "Additional library directories" to help the linker to find this library.

1 solution

I recommend starting from a solution that has already been made for a WTL project and adapting it for your project. This site has a good number of articles about WTL so I am sure something useful can be found : Code Project Search WTL[^]. By adapting I mean remove all source files that project references and then add all of yours into it. I have done this for several years now. I can not remember the last I had the wizard create a new project for me. I copy, rename, and revise previous project files so I am used to this.

You seem to be shooting in the dark regarding pre-compiled headers. They took me a while to figure out but ended up being pretty easy. First you select the Use option for all configurations of your project. Then you select the file that includes only your pre-compiled header file. With MFC it is usually called StdAfx.cpp but I usually call it PreCompiled.cpp. Once it is selected, right click on it select Properties for that file. In the property pages select Create as the pre-compiled header option for that file. The idea is one source (.cpp) file creates the .pch file for all the others to use.
 
Share this answer
 
Comments
Member 14105155 19-Mar-24 16:55pm    
yeah, thank you, I did similar things. I do have one pattern, created by WTL, the only one thing makes me inconvenient- same names for all solutions. I placed different solutions to different folders, but inside them all files had same names. Now I made an empty project and began to fill it with files. Looks like finally the process met with success
Rick York 19-Mar-24 18:28pm    
I rename the .sln, .vcxproj, and .filters files and then edit them to have the project name I want. This takes about one or two minutes. In fact, it is so quick that I haven't bothered to write a little to do it. I also change the GUID so that settings are saved correctly. There will be issues if they do not match.
Member 14105155 20-Mar-24 1:49am    
thank you again. I'll save your tips. How do you change GUID? Do you generate a new one? BTW, tle last method which I used (to create an empty project end add to it necessary files one my one) looks rather attractive. But its usage has some underwater stones, as I noticed. Another structure of folders- compiled didn't see lib files, placed into the folder with cpp files. I had to place lib files just to folder where sln file was placed.

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



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