C ++:Visual Studio 2015中未解析的外部符号_sprintf和_sscanf [英] C++: Unresolved external symbol _sprintf and _sscanf in Visual Studio 2015

查看:4695
本文介绍了C ++:Visual Studio 2015中未解析的外部符号_sprintf和_sscanf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个研究项目,我正在为科学计算语言编写一个C ++插件。不幸的是,允许用户执行此操作的库并不保持非常完好。



我在XCode中启动了项目,它在那里构建得很好。后来我不得不搬到一台电脑,所以我将代码迁移到Visual Studio 2015。由于这样做,我无法构建由于以下错误:

  LNK2001:未解析的外部符号_sprintf 
LNK2019:未解析的外部符号_ssetf在函数_GetDDouble
中引用LNK2019:未解析的外部符号_sprintf引用函数_CheckRunningInMainThread

尝试修复是添加标题 #define _CRT_SECURE_NO_WARNINGS 。然而,这a)修复没有错误和b)添加警告 C4005:'_CRT_SECURE_NO_WARNINGS':宏重新定义。我假设库已经定义了这个宏,预计这个问题。

解决方案



div>

将以下库添加到链接器输入文件中:

  legacy_stdio_definitions.lib 
stdio.h 功能。如果一个目标文件(或库成员)依赖于其中一个函数,那么 legacy_stdio_definitions.lib 提供了一个可以链接到的函数的外部可链接版本。 p>

您的另一个选项是重新编译依赖VS 2015的这些功能的单元(这可能是首选选项)。


For a research project, I'm writing a C++ add-on to a scientific computing language. Unfortunately the library that allows users to do this is not kept very well up-to-date.

I started the project in XCode, where it built fine. Later I had to move to a PC, so I migrated the code to Visual Studio 2015. Since doing this, I haven't been able to build due to the following errors:

LNK2001 : unresolved external symbol _sprintf
LNK2019 : unresolved external symbol _sscanf referenced in function _GetDDouble
LNK2019 : unresolved external symbol _sprintf referenced in function _CheckRunningInMainThread

An attempted fix was to add the header #define _CRT_SECURE_NO_WARNINGS. However, this a) fixed no errors and b) added the warning C4005 : '_CRT_SECURE_NO_WARNINGS': macro redefinition. I assume the library already defined this macro, anticipating this problem. Regardless, it didn't solve the problem.

How should I proceed?

解决方案

Add the following library to the linker input files:

legacy_stdio_definitions.lib

VS 2015 now uses inline definitions that call internal functions for many of the stdio.h functions. If an object file (or library member) depends on one of those functions, then the legacy_stdio_definitions.lib provides an externally linkable version of the function that can be linked to.

Your other option is to recompile the unit that depends on those functions with VS 2015 (this is probably the preferred option).

这篇关于C ++:Visual Studio 2015中未解析的外部符号_sprintf和_sscanf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆