用atl做com组件,用extern "c" 调用了一C函数库,debug编译链接通过,但release链接时出错。
出错信息如下
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

解决方案 »

  1.   

    Note   When building a Release version of a project, you can get the following link error:LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
    This error occurs if you are using CRT functions that require CRT startup code. The Release configurations define _ATL_MIN_CRT, which excludes CRT startup code from your EXE or DLL. To avoid this error, do one of the following: Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. On the Project menu, click Settings. In the Settings For: drop-down list, choose Multiple Configurations. In the Select project configuration(s) to modify dialog box that appears, click the check boxes for all Release versions, and then click OK. On the C/C++ tab, choose the General category, then remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
    If possible, remove calls to CRT functions that require CRT startup code and use their Win32 equivalents. For example, use lstrcmp instead of strcmp. Known functions that require CRT startup code are some of the string and floating point functions.
      

  2.   

    project settings中
    /SUBSYSTEM:CONSOLE改为/SUBSYSTEM:WINDOWS
      

  3.   

    To:zhuwenzheng() 
      已经是/SUBSYSTEM:WINDOWS了
      

  4.   

    masterz() 不是已经说了吗?
    #undef _ATL_MIN_CRT 就行了,此外,不要使用CRT函数,如
    strcmp之类的,可以用lstrcmp等代替
      

  5.   

    _ATL_MIN_CRT去掉了没用,另外
    人家写的C函数库是没法改的。加了个main()函数居然可以解决!!
      

  6.   

    是不是使用了_bstr_t 产生的?我也碰到过关注