如何使用MSVC编译2005年的.dll文件?

问题描述 投票:0回答:1

我需要编译lame_enc.dll的旧版本(MP3编码器,版本3.97)。

向Visual Studio 2019的单向迁移报告说,可能需要更改代码才能正确创建项目。尝试编译DLL时,有几个警告和以下错误。

C1189   #error:  Macro definition of snprintf conflicts with Standard Library function declaration  libmp3lame  C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\stdio.h    1935

LNK1181 Cannot open Input file "C:\Users\*\Desktop\lame-3.97\libmp3lame\Debug\libmp3lame.lib".  LameMp3EncDll   C:\Users\*\OneDrive\Desktop\lame-3.97\Dll\LINK  1   

[MSBuild和Devenv自2019年,2015年和2010年以来均导致相同的错误。

C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\stdio.h(1935,1): fatal error C1189: #error:  Macro definition of snprintf conflicts with Standard Library function declaration [C:\Users\*\Desktop\lame-3.97\libmp3lame\libmp3lame_vc7.vcxproj]

This是我正在使用的确切版本和文件。

我需要使用/执行哪些操作来编译dll?

visual-studio visual-c++ dll compilation msbuild
1个回答
0
投票

我需要使用/执行哪些操作来编译dll?

Visual Studio 14+在snprintf中将_snprintf定义为stdio.h

解决方案>>

[1)

以管理员身份运行VS2019,然后重新打开您的项目

[2)

#define snprintf _snprintf文件中的stdio.h更改为
#if _MSC_VER < 1900
#  define snprintf _snprintf
#endif

** 3)**编辑->查找和替换->在文件中查找->

查找内容

#\s*define\s+snprintf

查找

:整个解决方案(包括外部项目)

选择Match caseUse Regular Expressions

enter image description here

因此,请将#define snprintf _snprintf更改为:

#if _MSC_VER < 1900
#  define snprintf _snprintf
#endif

注意

:在id3tag.c文件中更改它们>

更改

#ifdef _MSC_VER
#define snprintf _snprintf
#endif

至:

#if _MSC_VER < 1900
#  define snprintf _snprintf
#endif
© www.soinside.com 2019 - 2024. All rights reserved.