• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > 使用STL类在ATLcom中的问题

使用STL类在ATLcom中的问题

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了atlcom.h,stl中容器分哪2大类,stl jerry的问题,问题类信息,问题建议类信息等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 使用STL类在ATL com中的问题
描述:

我在一个空的ATL com项目中,想使用
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
这几个头文件中的类,
结果在Debug时,一切OK没有问题,
但我在Release minsize时,就报
Generating Code...
Linking...
   Creating library ReleaseMinSize/ATLTest.lib and object ReleaseMinSize/ATLTest.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/ATLTest.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
但我能够包含比如#include <vector>
这样的stl头文件,但不能使用上面的四个,而且是Debug可以,release不可以。
不知是为什么?


解决方案1:

ATL工程里如果用到了C运行库函数,就不能再用这个宏了.
The following also applies to ATL 3.0: 
A. This usually happens when the C Run-Time (CRT) startup code is required for some CRT functions. You can either remove all references to the CRT functions that require the startup code or remove the _ATL_MIN_CRT preprocessor definition from your compiler settings. 
You can link statically or dynamically to the CRT. Statically linking causes the CRT code to be placed in your executable image and you do not need to have the CRT DLL (Msvcrt.dll). If you dynamically link to the CRT, references to the code in Msvcrt.dll are placed in your image. For your image to run, Msvcrt.dll must be present. Even when dynamically linking to the CRT, there can still be some code statically linked, such as DllMainCRTStartup. 
An entry point, explicitly or implicitly specified when linking, is called by the operating system after loading the image. For a DLL, the default entry point is DllMainCRTStartup. For an EXE, it is WinMainCRTStartup. You can override the default with the /ENTRY linker option. The CRT provides an implementation for DllMainCRTStartup, WinMainCRTStartup, and wWinMainCRTStartup (UNICODE entry point for an EXE). These entry points (CRT startup code) call constructors on global objects and initialize some data structures used by some CRT functions. This startup code adds about 25K to your image when statically linking. 
Some CRT functions can be used without the CRT startup code, for example, functions with the mem prefix, wcslen, wcscmp, and strlen. The following require the CRT startup code: 
String comparison routines
Memory allocation routines
Global objects with constructors
C++ exception handling (/GX) 
ATL is aimed at minimizing the image size and the reliance on run-time DLLs. It provides alternative implementations for common CRT APIs that would otherwise require the CRT startup code. The use of these APIs is controlled by the _ATL_MIN_CRT macro. Using _ATL_MIN_CRT does not mean that you cannot use the CRT routines. However, if you use the routines that require the CRT startup code, then you will get a linker error that _main is unresolved. Providing your own implementation of _main does not solve this problem. 
If C++ exceptions (/GX) are enabled, then you must link in the startup code. The _ATL_MIN_CRT macro cannot be used in this case. MFC requires code to be compiled with the /GX option. Therefore, you cannot use _ATL_MIN_CRT in conjunction with MFC. You can use SEH (structured exception handling), __try, and __except with _ATL_MIN_CRT, because the startup code is not required. In many cases, since most of the CRT source code ships with the product, you can use some of this code and replace only parts of it with system calls to avoid the startup code. 
To find out what is causing the problem, do one of the following: 
Open the Project Settings dialog box, select the Link tab, and click Input in the Category box. Type LIBCMT.LIB in the Ignore libraries text box. Now do a build. You will get a list of unresolved externals. This list contains the CRT routines you are using. Look for the routines that you think may require the startup code. 
Turn on the /VERBOSE linker option. From the resulting linker output, you can find a list of routines that require the CRT startup code. 
If you need the startup code, then remove the _ATL_MIN_CRT definition from the Project Settings. You can also dynamically link to CRT. This reduces your image size but requires Msvcrt.dll. 
When building as Release, the default option is to statically link to CRT and use _ATL_MIN_CRT. This gives a smaller image size than dynamically linking to CRT, at least when the startup code is avoided and the CRT APIs used by AppWizard are used. 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 为什么用向导生成的ATLCOM工程(dll)没有dlldatac文件
  • ATLCOM中能够用继承自CWnd的MFC类吗
  • ATLCOM事件,如何实现多个连接点的问题?
  • 如何在MFC程序中实现ATLCOM接口,并支持事件?
  • ATLCOM另我郁闷
  • 为什么我的ATLCOM控件中的输入框不能响应回车键?盼解答
  • 为什么我的ATLCOM控件中的输入框不能响应回车键?盼解答
  • 怎么样得到ATLCOM的DLL的路径????
  • 大家来说说ATLCOM、ActiveX、DLL三者有什么区别和联系?
  • ATLcom初学者求教关于VC编译错误

相关文章

  • 2017-06-05 请问怎样能够在后台运行的程序中截到控制台桌面上运行的程序的图?
  • 2017-06-05 ExcelCOM中CopyAddMove中Before/After参数问题
  • 2017-06-05 DLL的调用方法,急
  • 2017-06-05 用过cfgmgr32DLLcfgmgr32lib的进来
  • 2017-06-05 怎么样终止线程才能不内存泄露?
  • 2017-06-05 为什么ATL和MFC的idl文件,声明的语法有所不同?
  • 2017-06-04 一个关于VC、VBA、WORD的问题
  • 2017-06-04 使用_RecordsetPtrOpen打开一个xml字符串的问题,高手指教
  • 2017-06-04 MSChart问题
  • 2017-06-04 ATL初学者,各位能否推荐几本入门电子书籍

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 关于dll共享段和导出变量的几个问题,求助
    • 怎么做类似word的基于服务的程序
    • 收发同步问题
    • 线层中循环等待问题(在线等,即刻发分)
    • vc2005中插入多张图片!!!
    • 请问CreateWindowEx为什么无法创建WebBrowser呢?
    • 如何在richedit中用程序删除任意一行,插入一行等问题?
    • 我想利用M$的IFilter提取DOC/PDF的文本,怎么做,谢谢。
    • 有关调用dll的一些问题
    • 关于ATLDLL中DTPicker的问题

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有