Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. VS2012 & mismatch detected for '_MSC_VER'
Qt 6.11 is out! See what's new in the release blog

VS2012 & mismatch detected for '_MSC_VER'

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 25.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scarleton
    wrote on last edited by
    #1

    I am working on converting a VS2008/Qt 4.7 to VS2012/Qt5. I am down to a few linker errors that are a result of a mismatch detected for _MSC_VER:

    @1>qtmain.lib(qtmain_win.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in Action2TakeModel.obj
    1>qtmain.lib(qtmain_win.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xbad_alloc(void)" (...) referenced in function "char * __cdecl std::_Allocate<char>(unsigned int,char *)" (...)
    1>qtmain.lib(qtmain_win.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Syserror_map(int)" (...) referenced in function "public: virtual class std::error_condition __thiscall std::_System_error_category::default_error_condition(int)const " (...)
    1>qtmain.lib(qtmain_win.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (...) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::_System_error_category::message(int)const " (...)@

    I have compiled Qt5 with VS2012, any thoughts?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Code_ReaQtor
      wrote on last edited by
      #2

      @MSVC++ 11.0 _MSC_VER = 1700 (Visual Studio 2012)
      MSVC++ 10.0 _MSC_VER = 1600 (Visual Studio 2010)@

      @error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in Action2TakeModel.obj@

      your .obj was compiled with the wrong (VS2010) compiler, try to run clean and rebuild it.

      Please visit my open-source projects at https://github.com/Code-ReaQtor.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        scarleton
        wrote on last edited by
        #3

        Just did, same result. The question I have is: Which library was compiled with VS2010? Currently I don't have VS2010 on this machine. I have also gotten other projects to compile/link with VS2012, both Qt and some none Qt projects. So I am a bit stumped as to which library is being compiled with VS2010.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Action2TakeModel.obj is presumably on of yours.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Code_ReaQtor
            wrote on last edited by
            #5

            Recompile the library with VS2012.

            Program in VS2012 + library in VS2010 will NOT link/compile. AFAIK, both should be compiled on the same compiler version.

            Please visit my open-source projects at https://github.com/Code-ReaQtor.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              scarleton
              wrote on last edited by
              #6

              Code_ReaQtor, I fully understand what you are saying, but I don't know what library is being compiled with VS2010, that is the problem. Action2TakeModel.obj is my object file that is part of the VS2012 project, there is absolutely no way that is being compiled with VS2010, since I don't have VS2010 on that machine.

              I did install Qt 5.0.2 that was compiled with VS2010. But I am using a Qt 5.0.2 that I compiled with VS2012 and VS2012 is pointing to the correct version. Is there any way the VS2010 version of Qt 5.0.2 could be affecting things?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                scarleton
                wrote on last edited by
                #7

                Ok, I just tried commenting out all the code within the body of all the functions within Action2TakeModel.cpp, and I am still getting the same error. I am thinking there might be something with the actual code, so here is both the header file and the source code:

                Action2TakeModel.h
                @#ifndef ACTION2TAKEMODEL_H
                #define ACTION2TAKEMODEL_H

                #include <QStandardItemModel>

                class Action2TakeModel : public QStandardItemModel
                {
                Q_OBJECT

                public:
                Action2TakeModel(QObject *parent);
                ~Action2TakeModel();

                void refresh();

                int selectedAction() const;
                void setSelectedAction(int value);

                QString imgViewer() const;
                QString imgViewerArg(const QString& filepath) const;

                private:
                bool _inRefresh;
                QString _imgViewer;
                QString _imgViewerArgVar;
                QString _imgViewerArg;
                QString _imgViewerDefault;
                QString _defaultExecutable;
                };

                #endif // ACTION2TAKEMODEL_H
                @

                Action2TakeModel.cpp
                @#include "StdAfx.h"
                #include "Action2TakeModel.h"

                #define IMGVIEWERSELECTEDSTR "ImgViewerSelected"

                Action2TakeModel::Action2TakeModel(QObject *parent)
                : QStandardItemModel(0, 2, parent)
                , _inRefresh(false)
                {
                QSettings settings;
                QVariant value = settings.value(IMGVIEWERSELECTEDSTR);
                if( value.isNull())
                settings.setValue(IMGVIEWERSELECTEDSTR, 1);

                char path[_MAX_PATH];
                size_t requiredSize = _MAX_PATH;
                getenv_s( &requiredSize, &path[0], requiredSize, "windir");
                _defaultExecutable = QString("%1\explorer.exe").arg(path);
                }

                Action2TakeModel::~Action2TakeModel()
                {

                }

                int Action2TakeModel::selectedAction() const
                {
                QSettings settings;
                QVariant value = settings.value(IMGVIEWERSELECTEDSTR);
                if( value.isValid())
                {
                bool ok;
                int selectedAction = value.toInt(&ok);
                if(ok) {
                // if the selected action is great then the number of rows, make the last item selected.
                if( selectedAction > (rowCount() - 1))
                return rowCount() - 1;
                return selectedAction;
                }
                }
                return rowCount() - 1;
                }

                void Action2TakeModel::setSelectedAction(int value)
                {
                if( !_inRefresh)
                {
                QSettings settings;
                settings.setValue(IMGVIEWERSELECTEDSTR, value);
                }
                }

                void Action2TakeModel::refresh()
                {
                QSettings settings;
                bool change = false;

                QString settingsValue = settings.value("ImgViewer").toString();
                if( _imgViewer != settingsValue) {
                change = true;
                _imgViewer = settingsValue;
                }

                settingsValue = settings.value("ImgViewerArgVar").toString();
                if( _imgViewerArgVar != settingsValue) {
                change = true;
                _imgViewerArgVar = settingsValue;
                }

                _imgViewerArg = settings.value("ImgViewerArg").toString();
                _imgViewerDefault = settings.value("ImgViewerDefault").toString();

                if( change || rowCount() == 0)
                {
                _inRefresh = true;

                QFileInfo fiImgViewer(_imgViewer);

                bool isDefault = _imgViewer == _defaultExecutable;
                bool imgViewerSet = !_imgViewer.isEmpty() && !isDefault;

                QList<QStandardItem*> rowList;

                // four options: 1: not setup, 2: adding ImgViewer, 3: removing ImgViewer, 4: changing ImgViewer
                if( rowCount() == 0)
                {
                rowList.append(new QStandardItem(""));
                rowList.append(new QStandardItem(tr("Take No Action")));
                appendRow(rowList);
                rowList.clear();

                rowList.append(new QStandardItem(_imgViewerDefault));
                rowList.append(new QStandardItem(tr("Open in Windows Explorer")));
                appendRow(rowList);
                rowList.clear();
                }

                if( rowCount() == 2 && imgViewerSet)
                {
                rowList.append(new QStandardItem(_imgViewer));
                rowList.append(new QStandardItem(tr("Open with %1").arg(fiImgViewer.fileName())));
                appendRow(rowList);
                rowList.clear();
                }
                else if( rowCount() == 3 )
                {
                if(imgViewerSet)
                {
                QStandardItem *currentItem = item(2, 0);
                currentItem->setText(_imgViewer);
                currentItem = item(2, 1);
                currentItem->setText(tr("Open with %1").arg(fiImgViewer.fileName()));
                }
                else
                {
                removeRow(2);
                }
                }
                _inRefresh = false;
                }
                }

                QString Action2TakeModel::imgViewer() const
                {
                int selectedActionValue = selectedAction();
                if( selectedActionValue == 0)
                selectedActionValue = 1;

                QStandardItem * standardItem = item(selectedActionValue, 0);
                QString executable = standardItem->text();

                if( executable.isEmpty())
                return _defaultExecutable;

                return executable;
                }

                QString Action2TakeModel::imgViewerArg(const QString& filepath) const
                {
                QString output = _imgViewerArg;
                output.replace(_imgViewerArgVar, filepath);
                return output;
                }@

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  scarleton
                  wrote on last edited by
                  #8

                  Folks, I have had a lot of other things on my plate, so I have been slow to deal with this issue, but it is NOT going away.

                  It looks like to me that the issue was not in my code, Action2TakeModel.obj, but in the Qt code qtmain_win.obj. So I did some thinking and realized that I did have the Windows 7 (VS2010) WinDDK, so I went ahead and installed the Windows 8 (VS2012) WinDDK. I also looked at my environment and found some variables that pointed to VS2010, which it turns out I DO have installed. (I thought I didn't) So I removed the environment variables from the system, too. The I went back, extracted the Qt source code and recompiled it with:

                  configure -prefix

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    AdamInNVan
                    wrote on last edited by
                    #9

                    I am having the same problem.
                    @Code_ReaQtor, it is not the OP's code that is the problem, it is the QT library build that claims to be VS2012 x64. If you load the network-chat example from the QT examples folder into VS 2012 and build it, you get a manifest:embed error. If you change the project settings to turn off the manifest embedding, you get the _MSC_VER link error that the OP describes. It appears that some of the Qt libraries were built with VS 2010 and so you can't link with a VS 2012 application that references them. It is not all of them, as I have built and run a Qt 5 app with VS2012. That said, the network sockets class doesn't work as it should do under windows x64 (hence my interest in the network chat example). I am going to try again after we have rebuilt Qt ourselves using VS 2012.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved