Solved Compile with Visual Studio in Qt
-
Hi guys
I wonder something that compile with msvc.
First, you have to know I don't have an experience that and many things.
I'm a junior developer. ^^;;;I'm trying to build a project about OPC with OPC SDK made by Unified Automation.
However, there are many build error...T_Tunder is the .pro file
Qt Creator 2.4.1
Qt 4.8.1
QT += core
QT -= gui
TARGET = OPC_UA_ConsoleApp
CONFIG += console
CONFIG -= app_bundle
QMAKESPEC = win32-msvc2008TEMPLATE = app
DEFINES += _UA_STACK_USE_DLL
win32:DEFINES += UNICODE
win32:DEFINES += _UNICODE
win32:DEFINES += _CRT_SECURE_NO_WARNINGS
win32:DEFINES += _CRT_SECURE_NO_DEPRECATEINCLUDEPATH += include
include/uabase
include/uabase/arch
include/uabase/arch/windows
include/uabase/arch/gcc
include/uaclient
include/uamodels
include/uapki
include/uaserver
include/uastack
include/xmlparser
third-party/win32/vs2012sp4/openssl/inc32/openssl
third-party/win32/vs2012sp4/openssl/out32dll
third-party/win32/vs2012sp4/openssl/out32dll.dbg
third-party/win32/vs2012sp4/libxml2/include/libxml
third-party/win32/vs2012sp4/libxml2/out32dll
third-party/win32/vs2012sp4/libxml2/out32dll.dbg
examples/utilities
lib \DEPENDPATH += include
include/uabase
include/uabase/arch
include/uabase/arch/windows
include/uabase/arch/gcc
include/uaclient
include/uamodels
include/uapki
include/uaserver
include/uastack
include/xmlparser
third-party/win32/vs2012sp4/openssl/inc32/openssl
third-party/win32/vs2012sp4/openssl/out32dll
third-party/win32/vs2012sp4/openssl/out32dll.dbg
third-party/win32/vs2012sp4/libxml2/include/libxml
third-party/win32/vs2012sp4/libxml2/out32dll
third-party/win32/vs2012sp4/libxml2/out32dll.dbg
examples/utilities
lib \win32:CONFIG(release, debug|release): LIBS += -uastack -uabase -uapki -uaclient -xmlparser -lcrypt32 -lws2_32 -lrpcrt4 -uaclient -lOleAut32 -lOle32
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/third-party/win32/vs2012sp4/openssl/out32dll/ -llibeay32
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/third-party/win32/vs2012sp4/libxml2/out32dll/ -llibxml2win32:CONFIG(debug, debug|release): LIBS += -uastackd -uabased -uapkid -uaclientd -xmlparserd -lcrypt32 -lws2_32 -lrpcrt4 -lOleAut32 -lOle32
win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/third-party/win32/vs2012sp4/openssl/out32dll.dbg/ -llibeay32d
win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/third-party/win32/vs2012sp4/libxml2/out32dll.dbg/ -llibxml2dHEADERS +=
sampleclient.hSOURCES += main.cpp
sampleclient.cppThere are many error messages has "undefined reference to "class::method"
and collect2: Id returned 1 exit statusSo, I watched the Compile Output but I cannot find a key point or something.
anyway I saw some article in Google. He said about qmake, cmake, msvc, mingw... I don't know
what I need to complie that with Microsoft Visual C++ Compiler 10.0 ??
Please tell me your know-how.
Thanks.
-
"undefined reference" means that either a library is missing or a cpp file is not built. You need to check what exactly is undefined and then check where it is (in which library or cpp file).
You can post the errors here. And please post the compiler/linker call so we can see how it is called. -
Thanks your reply
follows are details of compile output
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
13:31:29: Running build steps for project OPC_UA_ConsoleApp...
13:31:29: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe" clean
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug clean
mingw32-make.exe[1]: Entering directoryC:/Users/SHLEE/Documents/OPC_UA_ConsoleApp' del debug\main.o debug\sampleclient.o mingw32-make.exe[1]: Leaving directory
C:/Users/SHLEE/Documents/OPC_UA_ConsoleApp'
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Release clean
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp\debug\main.o을(를) 찾을 수 없습니다.
mingw32-make.exe[1]: Entering directoryC:/Users/SHLEE/Documents/OPC_UA_ConsoleApp' del release\main.o release\sampleclient.o mingw32-make.exe[1]: Leaving directory
C:/Users/SHLEE/Documents/OPC_UA_ConsoleApp'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp\release\main.o을(를) 찾을 수 없습니다.
13:31:30: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited normally.
13:31:30: Configuration unchanged, skipping qmake step.
13:31:30: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directoryC:/Users/SHLEE/Documents/OPC_UA_ConsoleApp' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -D_UA_STACK_USE_DLL -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DQT_DLL -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"include" -I"include\uabase" -I"include\uabase\arch" -I"include\uabase\arch\windows" -I"include\uabase\arch\gcc" -I"include\uaclient" -I"include\uamodels" -I"include\uapki" -I"include\uaserver" -I"include\uastack" -I"include\xmlparser" -I"third-party\win32\vs2012sp4\openssl\inc32\openssl" -I"third-party\win32\vs2012sp4\openssl\out32dll" -I"third-party\win32\vs2012sp4\openssl\out32dll.dbg" -I"third-party\win32\vs2012sp4\libxml2\include\libxml" -I"third-party\win32\vs2012sp4\libxml2\out32dll" -I"third-party\win32\vs2012sp4\libxml2\out32dll.dbg" -I"examples\utilities" -I"lib" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\main.o main.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -D_UA_STACK_USE_DLL -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DQT_DLL -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"include" -I"include\uabase" -I"include\uabase\arch" -I"include\uabase\arch\windows" -I"include\uabase\arch\gcc" -I"include\uaclient" -I"include\uamodels" -I"include\uapki" -I"include\uaserver" -I"include\uastack" -I"include\xmlparser" -I"third-party\win32\vs2012sp4\openssl\inc32\openssl" -I"third-party\win32\vs2012sp4\openssl\out32dll" -I"third-party\win32\vs2012sp4\openssl\out32dll.dbg" -I"third-party\win32\vs2012sp4\libxml2\include\libxml" -I"third-party\win32\vs2012sp4\libxml2\out32dll" -I"third-party\win32\vs2012sp4\libxml2\out32dll.dbg" -I"examples\utilities" -I"lib" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"..\..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\sampleclient.o sampleclient.cpp g++ -Wl,-subsystem,console -mthreads -o debug\OPC_UA_ConsoleApp.exe debug/main.o debug/sampleclient.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -uastackd -uabased -uapkid -uaclientd -xmlparserd -lcrypt32 -lws2_32 -lrpcrt4 -lOleAut32 -lOle32 -LC:/Users/SHLEE/Documents/OPC_UA_ConsoleApp/third-party/win32/vs2012sp4/openssl/out32dll.dbg/ -llibeay32d -LC:/Users/SHLEE/Documents/OPC_UA_ConsoleApp/third-party/win32/vs2012sp4/libxml2/out32dll.dbg/ -llibxml2d -lQtCored4 mingw32-make.exe[1]: Leaving directory
C:/Users/SHLEE/Documents/OPC_UA_ConsoleApp'
debug/sampleclient.o: In functionHistoryReadDataResult': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference to
UaStatus::UaStatus()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference toUaByteString::UaByteString()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference to
UaDataValues::UaDataValues()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference toUaModificationInfos::UaModificationInfos()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference to
UaDataValues::~UaDataValues()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference toUaByteString::~UaByteString()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:852: undefined reference to
UaStatus::~UaStatus()'
debug/sampleclient.o: In function~HistoryReadDataResult': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference to
UaModificationInfos::~UaModificationInfos()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference toUaDataValues::~UaDataValues()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference to
UaDataValues::~UaDataValues()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference toUaByteString::~UaByteString()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference to
UaByteString::~UaByteString()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference toUaStatus::~UaStatus()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:854: undefined reference to
UaStatus::~UaStatus()'
debug/sampleclient.o: In functionUpdateDataDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:955: undefined reference to
UaNodeId::UaNodeId()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:955: undefined reference toUaDataValues::UaDataValues()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:958: undefined reference to
UaNodeId::~UaNodeId()'
debug/sampleclient.o: In function~UpdateDataDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:960: undefined reference to
UaDataValues::~UaDataValues()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:960: undefined reference toUaNodeId::~UaNodeId()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:960: undefined reference to
UaNodeId::~UaNodeId()'
debug/sampleclient.o: In functionDeleteRawModifiedDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:999: undefined reference to
UaNodeId::UaNodeId()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:999: undefined reference toUaDateTime::UaDateTime()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:999: undefined reference to
UaDateTime::UaDateTime()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1001: undefined reference toUaDateTime::~UaDateTime()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1001: undefined reference to
UaNodeId::~UaNodeId()'
debug/sampleclient.o: In function~DeleteRawModifiedDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1003: undefined reference to
UaDateTime::~UaDateTime()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1003: undefined reference toUaDateTime::~UaDateTime()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1003: undefined reference to
UaDateTime::~UaDateTime()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1003: undefined reference toUaNodeId::~UaNodeId()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1003: undefined reference to
UaNodeId::~UaNodeId()'
debug/sampleclient.o: In functionDeleteAtTimeDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1017: undefined reference to
UaNodeId::UaNodeId()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1017: undefined reference toUaDateTimeArray::UaDateTimeArray()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1017: undefined reference to
UaNodeId::~UaNodeId()'
debug/sampleclient.o: In function~DeleteAtTimeDetail': C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1019: undefined reference to
UaDateTimeArray::~UaDateTimeArray()'
C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1019: undefined reference toUaNodeId::~UaNodeId()' C:\Users\SHLEE\Documents\OPC_UA_ConsoleApp/include/uaclient/uaclientsdk.h:1019: undefined reference to
UaNodeId::~UaNodeId()'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\OPC_UA_ConsoleApp.exe] Error 1
mingw32-make.exe: *** [debug] Error 2
13:31:35: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project OPC_UA_ConsoleApp (target: Desktop)
When executing build step 'Make'/////////////////////////////////////////////////////////////////////////////////////////////////////////////
and I called just
#include "uabase.h"
#include "uaclientsdk.h"
in sampleclient.h file -
@Hyo. You're building with MinGW not VS!
C:/Users/SHLEE/Documents/OPC_UA_ConsoleApp' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -D_UA_STACK_USE_DLL -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DQT_DLL -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"........\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore"You cannot use libraries build with Visual C++ compiler with MinGW compiler! Use Visual C++ compiler.
-
Your libraries are build with vs2012.
That means you need VS2012 and Qt for VS2012. -
Hi,
To add to @jsulm, you have some other incoherences, you state that you are using Qt 4.8.1 but you seem to have installed 4.7.4 and your project tries to use the msvc-2008 mkspec…
As suggested by @jsulm, first cleanup your installation and use Qt's latest available versions. Either 4.8.7 if you're locked to Qt 4 or better Qt 5.6.1/5.7.0.
And also, you can't mix and match version of Visual Studio either i.e. you can't use MSVC2012 built libraries with another version of Visual Studio.
-
Thanks guys
I remember that some project to test the SDK in Visual Studio 2015, but I Changed the option Visual Studio 2012 (v110)
you guys genius?? how could you know it just that infomationhowever... I have 4.8.1 correctly. Just I missed the switch 4.7.4 or 4.8.1
그리고 MSVC2008은 2012도 해보고 이것저것 해보다가 그냥 2008인 채로 글 올린거니까 이해해줭
It's too difficult in english... sorry ^^;;;;So...
I have Visual Studio 2015, 2012, 2010.
And I must use Qt4.8.1... maybe after 1 year I can change the version, can't now.
Can't compile with msvc2012 in Qt4.8.1 ?? T_TPlease don't say NO
You are a genius !!!!! -
@Hyo. You need Qt 4.8.1 for msvc2012
-
@Hyo.
You can compile Qt 4.8.1 with msvc 21012. These two links will help you to do this.
http://doc.qt.io/qt-4.8/install-win.html
http://stackoverflow.com/questions/12113400/compiling-qt-4-8-x-for-visual-studio-2012
-
Thank you !!!!
You're the best to me.