zoukankan      html  css  js  c++  java
  • Debug Tips

    //z 2012-4-25 16:46:33 PM is2120@csdn
    0. 正则表达式
    /*.gz$/ 匹配以gz结尾的字符串

    //z 2012-4-22 20:44:31 IS2120@CSDN
    1.编译设置问题(enable exception)
    1.0 概述
    编译设置问题

    1.1 具体错误
    今天编译某个模块的时候总是遇到如下错误:
    error LNK2001: unresolved external symbol ___CxxFrameHandler
    error LNK2001: unresolved external symbol __except_list
    error LNK2001: unresolved external symbol __EH_prolog


    1.2 环境:vc6,not using mfc

    //z 2012-4-22 20:46:52 IS2120@CSDN
    1.3. 解决方案
    不启用 enable exception 即可

    1.4 issue
    只是表面上解决了问题,可能和我使用了新的SDK有关

    //z 2012-4-22 21:07:23 IS2120@CSDN
    1.5 cause
    应该和使用了预编译头文件有关,而两边不匹配
    warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompiled

    warning C4651: '/D_CPPUNWIND' specified for precompiled header but not for current compile

    warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompi

    warning C4651: '/D_CPPUNWIND' specified for precompiled header but not for current compile

    C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompiled
     header
    warning C4651: '/D_CPPUNWIND' specified for precompiled header but not for current compile
    RTFExporter.cpp
    warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompil
    ed header
    warning C4651: '/D_CPPUNWIND' specified for precompiled header but not for current compile
    TXTExporter.cpp
    warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompil
    ed header
    warning C4651: '/D_CPPUNWIND' specified for precompiled header but not for current compile

    //z 2012-4-23 17:32:07 PM IS2120@CSDN 又遇见了几个编译和链接错误

    2. fatal error LNK1104: cannot open file 'LIBC.lib' (vs2010)
    解决方法一:

    I could solve this prblem in my case (using library (built with VC++ 2003) for controlling an RFID readers)

     1. Include the library file LIBC.LIB into your project (Project -> Ad existing item -> All files -> pick the Lib file)

     This step allow the project to build successfully

     2. Add LIBC.LIB to the folder corresponding to "C:\Program Files\Microsoft Visual Studio 8\VC\lib"

     After that you'll be able to link successfully...

    解决方法二:
    I solved this problem by switching to libcmt.lib (the multi-threaded version of libc.lib).  VC++ 6.0 supported libc.lib (single-thread, statically linked library), but VC++ 2005 and 2008 do not.  They offer only the multi-threaded static library.  Go with this option, and your project now supports concurrency if you ever need it... :-)

    Make the change in your Project Properties | Configuration Properties | Linker | Input window.  On the line for "Additional Dependencies", change libc.lib to libcmt.lib.


    解决方法三:
    In Project Properties under Linker, Input enter libc.lib in the field "Ignore Library". this works to solve the problem with freeglut_static

    3.error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
    thanks for reporting this issue. while your project requires some minor fixes to build at all (precompiled headers are turned on, but there is no precompiled header file, and the project is being built unicode, but trying to pass an ansi string to OutputDebugString), after fixing these the project compiles and links fine. presumably whatever problem existed in beta2 has since been fixed. thanks again

    4. LNK2019: unresolved external symbol _memset referenced in function
    Does MSVC++ 2005 (vs2008 vs 2010) automatically inject calls to _memset()?
    I eventually solved my own problem, and this solution might help others who have posted about this issue.

    Given this loop:

    while ( n-- )
    {
        *p++ = b;
    }

    ...the compiler will generate a call to memset.
    But given this semantically equivalent loop instead:

    if ( n != 0 )
    {
        do
        {
            *p++ = b;
        }

        while ( --n );
    }
    ...the compiler does not generate a call to memset and emits reasonable code.
    The other workaround I tried successfully was to declare the loop pointer volatile, as in:

    volatile char * vp = p;

    while ( n-- )
    {
        *vp = b;
    }


    I made VS2010 work without linking to msvcr100.dll but it's a pain in the a*s, really.

    1. First, you have to make your own msvcrt.lib using dumpbin.exe and lib.exe (you have to make it for msvcrt.dll which resides in your system32 / syswow64 folder, depending on the version you need). The msvcrt.lib you get with VS is for MSVCR100.dll, not MSVCRT.dll. And we need the latter one.

    2. you have to make a static library with 2 functions: _crt_debugger_hook and __crt_debugger_hook (notice the difference in underlines). Both these functions must be declared as C functions, take no parameters, and return nothing. Their bodies may be empty.

    3. In your actual project, enable "ignore all default libraries".

    5. Add the following libraries in this exact order: my_own_msvcrt.lib;crt_debugger_hook_static.lib;msvcrt.lib;libcmt.lib;

    "my_own_msvcrt.lib" is the one you make in step 1, while "msvcrt.lib" is the original you get with VS2010.

    6. Append any additional libs you need.

    7. Make your own "main" function which takes no parameters, doesn't return anything, and uses __stdcall calling convention. Make it the executable's entrypoint. Actually the name doesn't matter - you can name it "MyCodeRules" if you wish.

    Example declaration:

    VOID __stdcall MyMain() {

    }

    These steps stop VS2010 from linking to msvcr100.dll. They actually make it intelligent and use intrinsic functions almost always. And even if it does link to something sporadically, it will be the plain old msvcrt.dll everyone has in their system folder.

    LIMITATIONS: In case you don't know, you pretty much strip all of C++ stuff from your executable, by using the above method, therefore you can use, like, almost nothing c++'ish -- only standard C.

    //z 2012-4-23 17:32:07 PM IS2120@CSDN

    5. unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)

    The symbol is defined in msvcrt.lib. You are not linking with that library because you specified the /NODEFAULTLIB linker option. Either remove that option, or add msvcrt.lib as an input library. Thanks for taking the time to report this!

    //z 2013-04-28 10:53:35 IS2120@BG57IV3.T244104627 .K[T8,L119,R5,V110]
    6. 如何调试 Windows 脚本宿主、 VBScript 和 JScript 文件
    REGEDIT4

    [HKEY_CLASSES_ROOT\CLSID\{834128A2-51F4-11D0-8F20-00805F2CD064}]
    @="ScriptDebugSvc Class"
    "AppID"="{A87F84D0-7A74-11D0-B216-080000185165}"

    [HKEY_CLASSES_ROOT\CLSID\{834128A2-51F4-11D0-8F20-00805F2CD064}\LocalServer32]
    @="D:\\Program Files\\Microsoft Script Debugger\\msscrdbg.exe"
       

    [HKEY_CLASSES_ROOT\CLSID\{834128A2-51F4-11D0-8F20-00805F2CD064}\ProgID]
    @="ScriptDebugSvc.ScriptDebugSvc.1"

    [HKEY_CLASSES_ROOT\CLSID\{834128A2-51F4-11D0-8F20-00805F2CD064}\VersionIndependentProgID]
    @="ScriptDebugSvc.ScriptDebugSvc"

    将以上几行保存成MSScrDbg.reg文件
    然后运行加入到注册表
    请先备份注册表

  • 相关阅读:
    spring boot 启动类 添加组件
    spirng boot 添加过滤器
    spring cloud spring-hystrix 缓存
    spring cloud spring-hystrix
    spring cloud spirng整合feign
    spring cloud feign
    cxf-client
    spring cloud客户端启用负载均衡
    spring cloud 负载均衡自定义
    VS2013 配置pthread
  • 原文地址:https://www.cnblogs.com/IS2120/p/6745906.html
Copyright © 2011-2022 走看看