问题“fatal error C1902: Program database manager mismatch; please check your installation”的解决方案:
Well, I belive it is not really a compiler bug.
Here are steps how I got it and solve:
1. I like to compile some sources from the command prompt, so I added to the PATH environment
variable - "C:/Program Files/Microsoft Visual Studio 8/VC/bin/".
After that I had to copy some files from "C:/Program Files/Microsoft Visual Studio 8/Common7/IDE/"
to get cl.exe working (one of files was mspdb80.dll).
2. Some time later I tryed to compile a project from MSDev and got C1902 error.
3. With MSDN search I got to this place to see Jonathan Caves's helpful message about mspdbsrv.exe.
4. I just copied that EXE to /VC/bin/ and everithing becomes Ok.
5. Now I can compile anything from both MSDev and C:/ :).
IMHO this problem arises when mspdb80.dll exists in some of directories that are listed in the PATH environment variable, but mspdbsrv.exe does not. By default, both of them are not on the search path, so just guys like me who are copying files around HDD are able to face this problem :).
Thanks for help. Hope this post will be of some use.
I suspect that there is a more fundamental problem here. It seems that somehow you have
got a mismatched mspdb80.dll and mspdbsrv.exe on your system. The only fix,
unfortunately, is to do a re-install of the product.
Here's the steps I would advise:
Make sure the IDE is not running
Run "Task Manager" and click on the "Processes" tab: if there is a mspdbsrv.exe process running
then select the process and then click on "End Process" button at the bottom
Uninstall the product
At this point you might want to search for any copies of "mspdbsrv.exe" and "mspdb80.dll"
on your machine: you may have older versions left over from an earlier install:
if you find any you should delete them.
Once you are certain that your machine is clean you can then re-install the product.
These steps, hopefully, will ensure that you have matched versions of mspdb80.dll and mspdbsrv.exe
vc中error LNK2001:unresolved external symbol _WinMain@16的解决方法
注:本文最初发表在csai上的blog http://blog.csai.cn/user1/16781/archives/2006/6412.html,现在在这里做个备份。
一,问题描述
error LNK2001: unresolved external symbol _WinMain@16
debug/main.exe:fatal error LNK 1120:1 unresolved externals
error executing link.exe;
二,产生这个问题可能的原因
1, 你用vc建了一个控制台程序,它的入口函数应该是main, 而你使用了WinMain.
2. 你用vc打开了一个.c/.cpp 文件,然后直接编译这个文件,这个文件中使用了WinMian而不是main作为入口函数。vc这时的默认设置是针对控制台程序的。
三, 解决方法
1.进入project->setting->c/c++, 在category中选择preprocessor,在processor definitions中删除_CONSOLE, 添加_WINDOWS
2.进入project->setting->Link, 在Project options中将 /subsystem:console改为/subsystem:windows.
3.保存设置,Rebuild All.
VS2005中的设置请参考对应项进行设置
四,VS2005中的设置
1.菜单中选择 Project->Properties, 弹出Property Pages窗口
2.在左边栏中依次选择:Configuration Properties->C/C++->Preprocessor,然后在右边栏的Preprocessor Definitions对应的项中删除_CONSOLE, 添加_WINDOWS.
3.在左边栏中依次选择:Configuration Properties->Linker->System,然后在右边栏的SubSystem对应的项改为Windows(/SUBSYSTEM:WINDOWS)
4.Rebuild All. Ok ?
测试:(环境:vs2005,编程语言vc)
1.用文本编辑器编写如下代码:
// test.c
#i nclude <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MessageBox(NULL, "Hello!", "title", MB_OK);
}
假设把文件包存为test.c.
2.用vs2005建一个Win32 Console Application, 注意在Application Settings设置为Empty project. 然后把test.c添加到工程中去。
3.vs2005建立的工程默认是支持UNICODE的,我不用这个,所以在菜单中选择 Project->Properties, 弹出Property Pages窗口。在左边栏中依次选择:Configuration Properties->General,然后把右边栏的Character Set 改为Use Multi-Byte Character Set.
4.编译,出现如下错误:
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
C:/test/Debug/test.exe : fatal error LNK1120: 1 unresolved externals
5.按照上述VS2005中的设置方法进行设置,然后再编译,错误消失了吧!
(Update:2006-10-28添加第四部分)
VC2008中,加上#include <tchar.h>即可。因为该文件定义了winmain等的Unicode和ASCI版本