描述:
我在写一个ATL COM,
在debug下编译没有问题,在其他模式下就有下面的错误
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseUMinSize/OutlAddin.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
好像是库的问题,如何解决啊
解决方案1:
RESOLUTION
Remove _ATL_MIN_CRT from the list the preprocessor defines to allow CRT startup code to be included.
1. From the Project menu, click Settings.
2. In the Settings For drop-down list, select Multiple Configurations.
3. In the Select project configuration(s) to modify dialog box that displays, select the check boxes for all release versions, and then click OK.
4. Click the C/C++ tab in the Project Settings dialog box, and then choose the General category.
5. Remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
NOTE: You can also remove calls to the CRT functions within the generated CServiceModule::LogEvent function.
Copied from msdn
不好意思,我用的是VC.net,没有问题,后来找了一个VC6测试了一下,也没问题。不过我上面的回答是错误的,提示找不到main,表示使用的控制台子系统。
因此楼主可尝试在Project/Settings下的Link下的Output中的最下面的选项编辑框中查看,看下在ReleaseUMinSize下是否有/subsystem:console这个选项,有的话将其改成/subsystem:windows即可
C运行时期库错误,在工程的属性中(VC6:Project/Setting..)将其改为使用多线程DLL版,而不是多线程版。
因为楼主选择的是ReleaseUMinSize,为了MinSize,ATL生成向导已经将工程配置为使用动态连接的C运行库,而不是静态连接的,以缩小最终尺寸。所以要使用DLL版的C运行时期库