需要更多关于LNK2038不匹配的解释为'_MSC_VER' [英] Need more explanation on LNK2038 mismatch dectected for '_MSC_VER'

查看:3713
本文介绍了需要更多关于LNK2038不匹配的解释为'_MSC_VER'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个不再使用公司的同事的旧程序。这是我们使用的CPLEX优化。它是使用Visual Studio 2005和CPLEX121在C ++中内置的。其所在的服务器正在停用,我们正尝试将其迁移到新服务器。我试图重建在Visual Studio 2013中的新应用程序使用CPLEX126进行优化。



我得到的错误是:


说明:



>

错误LNK2038:检测到_MSC_VER的不匹配:值1600与项目名称中的值1800不匹配.obj


档案:


ilocplex.lib(ilocplex.obj)



这些不匹配有很多。我是Visual Studio和C ++的新手,但我已经设法通过更新CPLEX链接,现在这个错误正在发生。



从此论坛帖子:
错误LNK2038:检测到'_MSC_VER'的不匹配:值'1600'与CppFile1.obj中的值'1700'不匹配



我已经能够推断可能有一些我可以做的工具集或重新编译我的库这似乎对一些人在最后一篇文章,但我需要的所有更具体的帮助,如何确切地这样做。


不,它是对象文件。编译器发出的内容。它们似乎在.lib文件中。您需要重新编译它。评论时间70年01月01日原作者:David Heffernan



Hi David,iam新到c ++。Iam基本上是一个c#程序员。你可以详细说明评论 - user1654136编译器告诉你用VS2012重新编译Projectname1.lib。你可以详细说明评论 - user1654136 20:43
2



。评论时间70年01月01日原作者:David Heffernan


我不知道这意味着什么,



此外,您的解决方案中每个项目的



属性>配置。属性>常规>平台工具集
是所有的一个,v100为visual studio 2010,v110为visual studio 2012
你也可能在v100从visual studio 2012工作




我的项目的平台工具集是Visual Studio 2013( v120)。我需要添加一些其他工具集吗?下拉菜单中没有其他选项。



.cpp文件中还有一个代码块:



//设置Visual Studio版本
#define _VS2005_
#if _MSC_VER< 1400
#undef _VS2005_
#endif



我也不知道这是做什么,是导致错误。

解决方案

首先,您将重新编译CPLEX库,因为您将不会源代码,除非您在IBM内部的研发团队工作,否则您无法获得它。所以忘记了推理的线。您依赖于IBM提供的预构建库与您使用的编译器版本配合使用。



当您说您设法通过获取CPLEX链接更新,现在这个错误正在发生,我猜你已经设法更新了编译器使用的C ++包含文件的路径,所以你的编译错误已经消失了。但是你可能还没有更新库路径以向编译器显示要链接的库的正确集。



从您发布的错误,'_MSC_VER':value '1600'不匹配值'1800',这告诉我你正试图链接到为VS2010建立的CPLEX库,而你的代码是使用VS2013编译的。参见例如如何检测我是否用Visual Studio 2008编译代码?



如果你是C ++的新手,任何人都希望你走进一个大的现有代码库并尝试移植到新的编译器和libs,并让它直接运行,而没有做更多的研究和背景学习。您是否尝试构建并运行CPLEX提供的C ++示例?



您是否阅读过使用CPLEX设置C ++项目的说明?它们在CPLEX文件夹中的文件c_cpp.html中。



现在,我不知道CPLEX有VS2013的库。我在这里没有12.6,所以我不能确定。查看您安装的CPLEX副本,可能类似:



C:\Program Files\IBM\ILOG\CPLEX_Studio126\cplex\lib



...这应该告诉你支持什么版本的VS。我有x64_windows_vs2008,x64_windows_vs2010和x64_windows_vs2012



如果VS2013没有库的副本,那么我想你将不得不回到VS2012或VS2010 。有可以是一种方式来配置VS2013,使其像VS2012一样工作,并诱使它生成兼容的代码;但我猜,从IBM的角度看不会是一个支持的配置。



关于#define VS2005 的东西是使用C ++ pre - 处理器定义一个符号,可用于打开或关闭源代码的位。查找您的源代码中使用该符号的位置。我猜这是完全独立于你的链接问题。如果您在代码中进行更改以使其在更高版本的编译器和库中工作(或工作得更好),您可以选择类似的操作。


I inherited an old program from a colleague that is no longer with the company. It's an CPLEX optimization we use. It was built in house in C++ using Visual Studio 2005 and CPLEX121. The server where it's located is being decommissioned and we're trying to migrate it to a new server. I'm trying to rebuild the new application in Visual Studio 2013 using CPLEX126 for the optimizations.

Error I get is:

Description:

error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in (project name).obj

File:

ilocplex.lib(ilocplex.obj)

There are quite a few of these mismatches. I'm new to Visual Studio and C++, but I've managed to work through getting the CPLEX links updated, and now this error is happening.

From this forum post: error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj

I've been able to deduce there might be something I can do to the toolset or "recompile my libraries" this seemed to work for some people on the last post, but all I need more specific help on how exactly to do that.

No, it's the object files. What the compiler emits. They appear to be inside the .lib file. You'll need to recompile it. – David Heffernan Oct 24 '13 at 20:40

Hi David, iam new to c++ .Iam basically a c# programmmer. Can you please elaborate the comments – user1654136 Oct 24 '13 at 20:43 2

The compiler is telling you to recompile Projectname1.lib with VS2012. – David Heffernan Oct 24 '13 at 20:48

I have no idea what that means and I don't have enough reputation to comment.

Also,

for each project in your solution make sure that Properties > Config. Properties > General > Platform Toolset is one for all of them, v100 for visual studio 2010, v110 for visual studio 2012 you also may be working on v100 from visual studio 2012

the response is "That worked for me"

My Project's Platform Toolset is "Visual Studio 2013 (v120)". Do I need to add some other toolset? there's no other option in the dropdown.

There is also a block of code in the .cpp file:

// set up Visual Studio version #define _VS2005_ # if _MSC_VER < 1400 # undef _VS2005_ # endif

I also don't know what this is doing to see if it is causing the error.

解决方案

First - you will not be able to recompile the CPLEX library because you will not have the source code and there is no way you are going to get it unless you work in the R&D team inside IBM. So forget that line of reasoning. You are dependent on IBM providing a pre-built library that works with the version of the compiler that you are using.

When you say that you "managed to work through getting the CPLEX links updated, and now this error is happening", I am guessing that you managed to update the paths to the C++ include files that are used by the compiler, so your compilation errors have gone away. But you may not yet have updated the library paths to show the compiler the right sets of libraries to link with.

From the error you are posting, '_MSC_VER': value '1600' doesn't match value '1800', that says to me that you are trying to link with the CPLEX library built for VS2010, while your code was compiled using VS2013. See for example How to Detect if I'm Compiling Code With Visual Studio 2008?

If you are new to C++, it is plain crazy for anyone to expect you to walk into a large existing code base and try to port to new compiler and libs and get it to run straight away without doing a bit more research and background learning. Have you tried to build and run the C++ examples provided with CPLEX?

Have you read the instructions for setting up a C++ project with CPLEX? They are in a file c_cpp.html in the CPLEX folder.

Now, I don't know that CPLEX has libraries for VS2013. I haven't got 12.6 here, so I can't be sure. Have a look in your installed copy of CPLEX, probably something like:

C:\Program Files\IBM\ILOG\CPLEX_Studio126\cplex\lib

...and that should tell you what versions of VS are supported. I have x64_windows_vs2008, x64_windows_vs2010 and x64_windows_vs2012

If there isn't a copy of the library for VS2013, then I think you are going to have to go back to VS2012 or VS2010. There may be a way to configure VS2013 to make it work like VS2012 and trick it onto generating code that is compatible; but I am guessing that would not be a "supported configuration" from IBM's perspective.

The stuff about #define VS2005 is using the C++ pre-processor to define a symbol which can be used to turn on or off bits of your source code. Look for where in your source code that symbol is used. I am guessing that is entirely separate from your linking issue. You might choose to do something similar if you make changes in your code to make it work (or work better) with the newer version of the compiler and libraries.

这篇关于需要更多关于LNK2038不匹配的解释为'_MSC_VER'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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