首页 > 其他分享 >VS2008 LIB的升级改造

VS2008 LIB的升级改造

时间:2024-04-28 13:58:09浏览次数:22  
标签:std VS2008 LIB void server 升级 base lib String

今天用VS2019编译一个在VS2008下Coding的工程的时候,VS给出了一堆链接错误信息,如下图所示的一些错误:

 

Error 47 error LNK2019: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) referenced in function "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z) D:\server\mysqlpp.lib(dbdriver.obj) server

Error 48 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(datetime.obj) server

Error 49 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(stadapter.obj) server

Error 50 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(sqlstream.obj) server

Error 51 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(connection.obj) server

Error 52 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(mystring.obj) server

Error 53 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(row.obj) server

Error 54 error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ) D:\server\mysqlpp.lib(query.obj) server

Error 55 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(dbdriver.obj) server

Error 56 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(datetime.obj) server

Error 57 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(stadapter.obj) server

Error 58 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(sqlstream.obj) server

Error 59 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(connection.obj) server

Error 60 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(mystring.obj) server

Error 61 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(row.obj) server

Error 62 error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB) D:\server\mysqlpp.lib(query.obj) server

Error 63 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(qparms.obj) server

Error 64 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(sqlstream.obj) server

Error 65 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(options.obj) server

Error 66 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(field_types.obj) server

Error 67 error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) referenced in function "public: char __thiscall mysqlpp::SQLTypeAdapter::at(unsigned int)const " (?at@SQLTypeAdapter@mysqlpp@@QBEDI@Z) D:\server\mysqlpp.lib(stadapter.obj) server

Error 68 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(manip.obj) server

Error 69 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(null.obj) server

Error 70 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(datetime.obj) server

Error 71 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(type_info.obj) server

Error 72 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(vallist.obj) server

Error 73 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(field_names.obj) server

Error 74 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(query.obj) server

Error 75 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(dbdriver.obj) server

Error 76 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(tcp_connection.obj) server

Error 82 error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen@_String_base@std@@SAXXZ) D:\server\mysqlpp.lib(null.obj) server

 

 

问题总结:

       因为静态链接库mysqlpp.lib在旧版本IDE上编译的,所以string类中符号被解析成形如 static void __cdecl _Xran()或static void __cdecl _Xlen() 

       而在高版本的VS2019上string中的_Xran与_Xlen符号则被解析成了__declspec(noreturn) void _Xran() const或__declspec(noreturn) void _Xlen() const

       所以才会在链接过程中出现上述开头出现的一堆问题

#include <string>

namespace std2008

{

class _String_base_2008

{

public:

{

__declspec(dllexport) void _Xlen2008(void) const;

__declspec(dllexport) void _Xran2008(void) const;

};

};

void std2008::_String_base_2008::_Xran2008 () const

{

std::_String_base::_Xran ();

}

void std2008::_String_base_2008::_Xlen2008 () const

{

std::_String_base::_Xlen ();

}

Save this code as "compat.cpp" and compile with

cl /D_DLL_EXPORT /EHsc /LD compat.cpp /link

Now lets examine the lib file, that has been created:

dumpbin /exports compat.lib

In my case it looks like this:

Dump of file compat.lib

File Type: LIBRARY

Exports

ordinal name

?_Xlen2008@_String_base_2008@std2008@@QBEXXZ (public: void __thiscall std2008::_String_base_2008::_Xlen2008(void)const )

?_Xran2008@_String_base_2008@std2008@@QBEXXZ (public: void __thiscall std2008::_String_base_2008::_Xran2008(void)const )

When looking at the linker errors about missing symbols, you see the decoration that is required. In your case its "?_Xran@_String_base@std@@SAXXZ" and "?_Xlen@_String_base@std@@SAXXZ"

The last step is to tell the linker to create a library that maps the standard decorated names to a another name using the symbols from your linker error and the names taken from dumpbin.

Cl /EHsc /LD compat.cpp /link /export:?_Xran@_String_base@std@@SAXXZ=?_Xran2008@_String_base_2008@std2008@@QBEXXZ /export:?_Xlen@_String_base@std@@SAXXZ=?_Xlen2008@_String_base_2008@std2008@@QBEXXZ

Cl /EHsc /LD compat1.cpp /link /export:??0exception@std@@QAE@ABQBD@Z=??exception_2008@std2008@@QAEXABQBD@Z

Now add the "compat.lib" library as additional library to your project and now it should link successfully.

Compact.c代码

#include <string>

namespace std2008

{

class _String_base_2008

{

public:

__declspec(dllexport) void _Xlen2008(void) const;

__declspec(dllexport) void _Xran2008(void) const;

};

};

void std2008::_String_base_2008::_Xran2008 () const

{

std::_String_base::_Xran ();

}

void std2008::_String_base_2008::_Xlen2008 () const

{

std::_String_base::_Xlen ();

}

生成DLL和LIB

cl /D_DLL_EXPORT /EHsc /LD compat.cpp /link

生成可用的LIB

Cl /EHsc /LD compat.cpp /link /export:?_Xran@_String_base@std@@SAXXZ=?_Xran2008@_String_base_2008@std2008@@QBEXXZ /export:?_Xlen@_String_base@std@@SAXXZ=?_Xlen2008@_String_base_2008@std2008@@QBEXXZ

 

Compact1.c代码

#include <string>

namespace std2008

{

class exception_2008

{

public:

__declspec(dllexport) exception_2008(char const * const & ch);

};

};

std2008::exception_2008::exception_2008(char const * const & ch)

{

std::exception::exception (ch);

}

生成DLL和LIB

cl /D_DLL_EXPORT /EHsc /LD compat1.cpp /link

生成可用的LIB

Cl /EHsc /LD compat1.cpp /link /export:??0

exception@std@@QAE@ABQBD@Z=??exception_2008@std2008@@QAEXABQBD@Z

 

将生成的compat.dll和compat1.dll拷贝至EXE目录,compat.lib和compat1.lib则拷贝至源文件与mysqlpp.lib同一目录中,即可顺利编译了!!

标签:std,VS2008,LIB,void,server,升级,base,lib,String
From: https://www.cnblogs.com/djcsch2001/p/18163438

相关文章

  • Util 应用框架 UI 全新升级
    UtilUI已经开发多年,并在多家公司的项目使用.不过一直以来,UtilUI存在一些缺陷,始终未能解决.最近几个月,Util团队下定决心,终于彻底解决了所有已知缺陷.Util应用框架UI介绍Util应用框架UI建立在Angular,Ng-Zorro,Ng-Alain基础之上,用于开发企业中后台.......
  • 简约不简单:Model 3芯片双层PCB设计,HMI控制器高效升级!
    产品高性能和可靠性的需求日益增长,特别是在工业应用领域中,这些要求更是严苛。为了满足这些不断升级的需求,启明智显推出了全新的Model3芯片。这款芯片以其卓越的性能和强大的功能,被设计用作人机界面(HMI)产品的主控制器,为HMI产品提供了强大的技术支持。Model3芯片【Model3芯片......
  • Alibaba Cloud Linux release 3 Python 3.8 安装
    AlibabaCloudLinuxrelease3Python3.8安装https://zhuanlan.zhihu.com/p/690125733背景买了台阿里云服务器玩玩,项目需要Python3.8,但是机器上配置了3.6.8机器信息:机器信息:Linuxversion5.10.134-16.1.al8.x86_64AlibabaCloudLinuxrelease3linux的多python版......
  • python 如何动态加载lib中的函数
    classTestInstance:def__init__(self):#初始化库字典,存放找到的库self.lib=Proxy()#使用一个代理对象来模拟层级结构classProxy:def__init__(self):self._libObjectDictCache={}def_getLibInstance(self,l......
  • Matplotlib 设置x轴的标签
    在Matplotlib中,如果你有一个时间序列数据,并且x轴上的时间标签太多导致它们重叠或难以阅读,你可以通过几种方法来减少显示的标签数量或调整它们的格式。以下是一些常用的方法:使用plt.xticks()手动设置x轴标签:你可以通过plt.xticks()手动设置你想显示的x轴标签的位置和文本。imp......
  • FFmpeg开发笔记(十七)Windows环境给FFmpeg集成字幕库libass
    ​libass是一个适用于ASS和SSA格式(AdvancedSubstationAlpha/SubstationAlpha)的字幕渲染器,支持的字幕类型包括srt、ass等,凡是涉及到给视频画面添加字幕,均需事先集成libass。《FFmpeg开发实战:从零基础到短视频上线》一书的“7.3.1 Linux环境安装libass”介绍了如何在Linux环境......
  • windows bilibili客户端缓存视频导出
    视频缓存地址:C:\Users\Administrator\Videos\bilibili\一串数字使用winhex把视频和音频前面的八个0删除使用ffmpeg合并视频和音频ffmpeg-i视频文件-i音频文件-codeccopy输出地址......
  • dremio 25.0 KVStore 升级简单说明
    dremio25.0开始对于数据源的存储支持加密了,所以升级上稍有不同,官方给出的操作流程如下参考处理//对于已经运行的,应该先stop,然后进行应用包的替换dremiostop//执行dremio-admin的upgradedremio-adminupgrade//启动dremiostart//停止drem......
  • dotnet 8 版本与银河麒麟V10和UOS系统的 glib 兼容性
    刚刚好dotnet8的glib版本足够旧,可以运行本文记录于2024.04.26如果你阅读本文时间距离本文记录时间过远,可能本文记录的信息已失效dotnet根据dotnet的supported-os文档记录,当前的dotnet8是8.0.4版本,官方说明是支持Debian11及以上版本实际测试可以在debian1......
  • lib 安装失败,error Microsoft Visual C++ 14.0 is required.
    即使安装c++要占用c盘4G,而且仍然有可能报错,error:command'C:\ProgramFiles(x86)\MicrosoftVisualStudio14.0\VC\BIN\x86_amd64\cl.exe'failedwithexitstatus2另一种解决方法是直接下载whl,省去编译的过程https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib有可能......