MSBuidel - 将资源文件添加到项目后静态库编译失败
msbuild - static lib compilation failed after adding resource file to project
我有一个C++库,它被编译为动态和静态库。最近我将资源版本文件添加到源。动态库编译工作正常,但静态库编译开始失败,64 位目标出现以下错误:
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
x64Releasedllmain.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
以下是我的编译脚本:
@ECHO OFF
call "%VS140COMNTOOLS%"\vsvars32.bat
SET SourceDir=D:ProjectsMySampleLib
SET TargetDir=D:ProjectsPackages
ECHO 32 bit MySampleLib .LIB compilation VS2010
msbuild.exe %SourceDir%MySampleLibMySampleLib.vcxproj /t:Clean;Rebuild /p:Configuration=Release;Platform=Win32;ConfigurationType=StaticLibrary;PlatformToolset=v100
ECHO 64 bit MySampleLib .LIB compilation VS2010
msbuild.exe %SourceDir%MySampleLibMySampleLib.vcxproj /t:Clean;Rebuild /p:Configuration=Release;Platform=x64;ConfigurationType=StaticLibrary;PlatformToolset=Windows7.1SDK
当 Lib.exe 命令尝试链接 MySampleLib.res 时发生此错误
注意:该错误仅在我添加资源文件后出现。我不想将资源文件添加到静态库。
我终于通过修改以下.vcxproj
条目解决了这个问题
<ItemGroup>
<ResourceCompile Include="MySampleLib.rc" />
</ItemGroup>
自
<ItemGroup Condition="'$(ConfigurationType)'!='StaticLibrary'">
<ResourceCompile Include="MySampleLib.rc" />
</ItemGroup>
这阻止了在静态编译中链接资源文件。
相关文章:
- 如何使用MinGW编译器和SSL支持静态编译Qt
- 静态编译的Qt 5.13.1与OpenSSL 1.1.1d生成QSslSocket::connectToHostEncr
- Qt 静态编译无法读取路径
- 如何静态编译QT 5应用程序
- QT 静态库静态编译
- 静态编译 GRPC C++服务
- 是在同一体系结构上运行的静态编译的纯标准C 程序可移植
- 全局(静态编译的)变量位于哪里
- Ubuntu上的OpenCv静态编译
- 在Linux上静态编译osgconv,并支持obj文件
- 依赖VS2010中静态编译的库时未定义的符号
- 使用libcef_static.lib静态编译Chromium Embedded 3项目
- 在AIX上对proftpd进行静态编译
- 参考off64_t,在mingw下Qt 5的静态编译失败
- 是否可以在静态编译时从不同的源文件构建向量
- 使用boost::regex链接为静态编译我的项目
- 如何静态编译boost_iostreams
- QT创建者和xcode静态编译
- C++与GLUT在linux上静态编译
- 静态编译会破坏ABI吗?