zoukankan      html  css  js  c++  java
  • 关于“无法定位程序输入点getaddrinfo于动态链接库WS32_32.dll上”的问题

    今天收到一个bug,说我们的产品在windows 2000的操作环境下无法正常安装运行,安装后弹出“无法定位程序输入点getaddrinfo于动态链接库WS32_32.dll上”的错误。 简单地在网上搜了一下,发现多个讨论和解决方案。

    方案一:http://hi.baidu.com/tjmd/blog/ITem/e35d0dd787b540dda144df98

       该问题一般出现在用VC编译的程序在XP和2003上可以正常运行,2000下则报此错误,解决方法比较简单,分两种情况,一种是对于VC6或者VC6升级到VC8的工程,修改编译选项中的_WIN32_WINNTWINVER0x0500,另一种是直接用VC8创建的工程,StdAfx.h里面已经有了这两个变量的定义,所以需要替换所有StdAfx.h文件里面_WIN32_WINNT和WINVER两个宏的变量,修改其值为0x0500,再编译即可解决!

    方案二:http://topic.csdn.net/u/20080429/11/6167d25d-8b3c-4e21-8629-3b981f439c35.html

       使用静态连接
    在编译开关里选择

    方案三:http://topic.csdn.net/t/20060828/13/4980483.html   

    应该说直接拷贝DLL是解决不了问题的。Top

    6 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2006-08-28 13:24:07 得分 0

    据我遇到的情况,是因为用到了getaddrinfo的的Unicode版本造成的(不管是直接还是间接),这个函数 (GetAddrInfoW),是Windows   XP   SP2才加上去的,低于XP   SP2的版本是无法用这个函数的,拷贝DLL也是不行的。需要改代码,然后再重新编译。Top

    7 楼lixiaosan(小三)回复于 2006-08-28 13:26:23 得分 50

    http://support.microsoft.com/kb/822334/en-usTop

    8 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2006-08-28 13:34:19 得分 50

    是不是用到了GetAddrInfo,FreeAddrInfo,CSocketAddr这些XP才支持的东东,需要你检查代码了。

    方案四:http://support.microsoft.com/kb/822334/en-us

    To resolve this problem, follow these steps:

    1. Copy the Atlsocket.h file to any directory that you want to use. This file is located in the following directory:
      Program Files/Microsoft Visual Studio .NET 2003/Vc7/atlmfc/include
    2. Add the following block of code to the copy of the Atlsocket.h file that you created in step 1.
      //Atlsocket.h
      #pragma comment(lib, "ws2_32.lib")
      #pragma comment(lib, "mswsock.lib")
      //Start of Addition
      #if _WIN32_WINNT < 0x0502
        #define ADDRINFOT addrinfo
        #define GetAddrInfo getaddrinfo
        #define FreeAddrInfo freeaddrinfo
      #endif
      //End of Addition namespace ATL
    3. Start Microsoft Visual C++.
    4. On the Tools menu, click Options. In the left pane of the Options dialog box, expand Projects, and then click VC++ Directories.

      Note If you are using Visual C++ Express Edition, expand Projects and Solutions in the left pane of the Options dialog box, and then click VC++ Directories.
    5. Under Show directories for, click Include files. Then, add the directory where the modified version of the Atlsocket.h file is located to the top of the list.
    6. Rebuild you application

     但是我们代码没有使用 StdAfx.h并且已经是静态链接也不是一个ATL工程也就不能引用ATLBase.h,最后综合上面的解决方案和意见,改出了自己的版本。

    将原有的#pragma comment(lib, "ws2_32.lib")改为了 

    #pragma comment(lib, "ws2_32.lib")

    //Start of Addition
    #if _WIN32_WINNT < 0x0502
      #define ADDRINFOT addrinfo
      #define GetAddrInfo getaddrinfo
      #define FreeAddrInfo freeaddrinfo
    #endif
    问题经测试已解决。

  • 相关阅读:
    两个链表的第一个公共结点
    数组中的逆序对
    C++强制类型转换运算符(static_cast、reinterpret_cast、const_cast和dynamic_cast)
    第一个只出现一次的字符
    机器学习算法速览表
    丑数
    设计模式---行为型设计模式【策略模式】
    设计模式---行为型设计模式【备忘录模式】
    设计模式----创建型设计模式【单例模式】
    设计模式----创建型设计模式【简单工厂、工厂方法、抽象工厂】
  • 原文地址:https://www.cnblogs.com/k1988/p/2165726.html
Copyright © 2011-2022 走看看