I have problems on building OpenCV_HighGui220d.lib with QT support.
The problems are the unresolved symbols about QMetaObject, such as:
public: virtual struct QMetaObject const * __thiscall GuiReceiver::metaObject(void)const (?metaObject#GuiReceiver##UBEPBUQMetaObject##XZ)
My Environments:
- Visual Studio 2010
- OpenCV 2.2
- QT SDK Version:4.7.3
Below are my building steps:
1. use CMake to open C:\OpenCV2.2, check on WITH_QT and WITH_QT_OPENGL, generate vcxproj and sln files.2. add below macros in cvconfig.h:
#define HAVE_QT
#define HAVE_QT_OPENGL3. add window_QT.cpp into opencv_highgui.vcxproj file in VS2010, and add below macros in window_QT.cpp
#define QT_LARGEFILE_SUPPORT
#define QT_DLL
#define QT_GUI_LIB
#define QT_CORE_LIB
#define QT_HAVE_MMX
#define QT_HAVE_3DNOW
#define QT_HAVE_SSE
#define QT_HAVE_MMXEXT
#define QT_HAVE_SSE2
#define QT_THREAD_SUPPORT I also tried to replace QT_DLL with QT_NODLL, but did not succeed. 4. Add directory C:/QtSDK/Desktop/Qt/4.7.3/msvc2008/lib in Additional Library Directories in Linker Property pages. 5. Add below libraries in Additional Dependencies:
qtmain.lib
qtmaind.lib
QtGui4.lib
QtGuid4.lib
QtCore4.lib
QtCored4.lib
QtOpenGL4.lib
QtOpenGLd4.lib
Qt3Support4.lib
Qt3Supportd4.lib
QtHelp4.lib
QtHelpd4.lib
QtDesigner4.lib
QtDesignerd4.lib
QAxContainer.lib
QAxContainerd.lib
phonon4.lib
phonond4.lib
QAxServer.lib
QAxServerd.lib
QtDeclarative4.lib
QtDeclaratived4.lib
QtDesignerComponents4.lib
QtDesignerComponentsd4.lib
QtMultimedia4.lib
QtMultimediad4.lib
QtNetwork4.lib
QtNetworkd4.lib
QtScript4.lib
QtScriptd4.lib
QtScriptTools4.lib
QtScriptToolsd4.lib
QtSql4.lib
QtSqld4.lib
QtSvg4.lib
QtSvgd4.lib
QtTest4.lib
QtTestd4.lib
QtUiTools.lib
QtUiToolsd.lib
QtWebKit4.lib
QtWebKitd4.lib
QtXml4.lib
QtXmld4.lib
QtXmlPatterns4.lib
QtXmlPatternsd4.lib 6. Finally, the linker reports error:
------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
------ Build started: Project: opencv_highgui, Configuration: Debug Win32 ------
Creating library C:/OpenCV2.2/Build_QT/lib/Debug/opencv_highgui220d.lib and object C:/OpenCV2.2/Build_QT/lib/Debug/opencv_highgui220d.exp
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GuiReceiver::metaObject(void)const " (?metaObject#GuiReceiver##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GuiReceiver::qt_metacast(char const *)" (?qt_metacast#GuiReceiver##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GuiReceiver::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#GuiReceiver##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvTrackbar::metaObject(void)const " (?metaObject#CvTrackbar##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvTrackbar::qt_metacast(char const *)" (?qt_metacast#CvTrackbar##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvTrackbar::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvTrackbar##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvTrackbar::staticMetaObject" (?staticMetaObject#CvTrackbar##2UQMetaObject##B)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvButtonbar::metaObject(void)const " (?metaObject#CvButtonbar##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvButtonbar::qt_metacast(char const *)" (?qt_metacast#CvButtonbar##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvButtonbar::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvButtonbar##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvButtonbar::staticMetaObject" (?staticMetaObject#CvButtonbar##2UQMetaObject##B)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvPushButton::metaObject(void)const " (?metaObject#CvPushButton##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvPushButton::qt_metacast(char const *)" (?qt_metacast#CvPushButton##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvPushButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvPushButton##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvCheckBox::metaObject(void)const " (?metaObject#CvCheckBox##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvCheckBox::qt_metacast(char const *)" (?qt_metacast#CvCheckBox##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvCheckBox::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvCheckBox##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvRadioButton::metaObject(void)const " (?metaObject#CvRadioButton##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvRadioButton::qt_metacast(char const *)" (?qt_metacast#CvRadioButton##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvRadioButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvRadioButton##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvWinProperties::metaObject(void)const " (?metaObject#CvWinProperties##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvWinProperties::qt_metacast(char const *)" (?qt_metacast#CvWinProperties##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvWinProperties::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvWinProperties##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CvWindow::metaObject(void)const " (?metaObject#CvWindow##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall CvWindow::qt_metacast(char const *)" (?qt_metacast#CvWindow##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CvWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CvWindow##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const CvWindow::staticMetaObject" (?staticMetaObject#CvWindow##2UQMetaObject##B)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall ViewPort::metaObject(void)const " (?metaObject#ViewPort##UBEPBUQMetaObject##XZ)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall ViewPort::qt_metacast(char const *)" (?qt_metacast#ViewPort##UAEPAXPBD#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall ViewPort::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#ViewPort##UAEHW4Call#QMetaObject##HPAPAX#Z)
window_QT.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const ViewPort::staticMetaObject" (?staticMetaObject#ViewPort##2UQMetaObject##B)
C:\OpenCV2.2\Build_QT\bin\Debug\opencv_highgui220d.dll : fatal error LNK1120: 31 unresolved externals
========== Build: 1 succeeded, 1 failed, 8 up-to-date, 0 skipped ==========
The Qt MOC (meta-object compiler) is not being run on your Qt class files.
Since you're building from the OpenCV release, I'm assuming that the UI classes already have a Q_OBJECT line within the class declaration.
To generate a .vcproj file that has the necessary build instructions to run MOC, run this command:
qmake -tp vc -r <yourProFile.pro>
If that doesn't work, right-click one of the .h files that contains a Qt class. Under Properties->Custom Build Step->General, you should see something like:
Command Line "$(QTDIR)\bin\moc.exe" -I".\GeneratedFiles\." -I"$(QTDIR)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." .\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" "-fstdafx.h" "-f[YourQtFile.h]"
Description Moc'ing $(InputFileName)...
Outputs ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp"
Additional Dependencies "$(QTDIR)\bin\moc.exe";$(InputPath)
Hope this helps.
Add directory C:/QtSDK/Desktop/Qt/4.7.3/msvc2008/lib
in Additional Library Directories in
Linker Property pages
if you are building with vs2010, i suggest you should add dir with libraries compiled with vs2010... your path is probably refer to vs2008 libs.
This may help someone:
I encountered this error for a new QOBJECT class I made, and it went away after re-running qmake (Build->Run qmake), then rebuilding.
though very late response....
I followed the following steps to get rid of above error:
1) Install OpenSource QT Version or QT for Visual studio version.
2) Install visual studio QT addin in Visual Studio [http://qt.nokia.com/downloads/visual-studio-add-in].
3) create a project using QT and not as a normal visual studio project. Created QT project will automatically become a visual studio project.
FOR existign QT projects.....
1) Open the project from QT menu and not from the File menu of Visual Studio.
Hope this helpe...............I consumed 2 days to get this working.
I realize this question/answer is a bit old, but I ran into this as an exact hit for the same issue, so it's still around. We had an open source project that was a bit of a hydra; it used both WxWidgets AND QT5 (Open Source). Yet, nothing in it actually ran the moc compiler, so I got the subject error when I attempted to use some thread classes.
IF you install Qt5, this step 'might' be done for you, but I'd tried that and hadn't gotten past the link step. The source I was working with thoughtfully bundled everything with a batch file that would correctly run cmake - just didn't include the MOC. So, to retrofit what I had to do was the following.
The fix for me was:
Manually create an environment var called QtDir, and set it to the SDK that came with the open source project, or whatever Qt library you download.
Go to Visual Studio 2019, right click on the .H file. Go to Properties. You'll see something like this. What wasn't obvious to me at first was that "Item Type" can be clicked on.
Change to "Custom build step".
Go to the Project, and enter a "Custom Build Step" for all configurations if you've got more than one file, which is likely, or edit the build step right from that file.
Some nice macros which may be new:
$(GeneratedFileExtension) which is .g.cpp; but in practice, it seemed to be empty when the project built. So I typed in .g.cpp manually.
%(Identity)
%(Filename)
but use %(FullFilePath)
#Gnawme's answer got me part of the way there, but $(InputFileName) didn't work for VS2019. (Most likely MS moved forward ...). Also, The moc compliler didn't seem to take -f"filename.h" it just wanted filename.h
So what my final "Command Line" for the custom build step was:
$(QTDIR)bin\moc.exe -I".\GeneratedFiles\." -I"$(QTDIR)\include\." -I".\GeneratedFiles\$(ConfigurationName)\." -I"$(QTDIR)\include\QtCore\." -I"$(QTDIR)\include\QtGui\." -o".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).g.cpp" "%(FullPath)"
Note if you put quotes around the executable path, you'll get a weird error about invalid characters in the path.
Then you want a description of:
Moc'ing %(FileName) to produce %(Filename).g.cpp
Outputs will be:
.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).g.cpp
Now ... a tricksy thing I tried; Change "Add Outputs to Item Type" and then "C/C++ Compiler" from the drop down. This means the generated files will automatically be compiled, without having to 'add' them to the project.
.. except it didn't work. Sort of bone headed, but it only has to be done once. The docs actually mention this:
If you want the build system to operate on an output file generated by
the custom build tool, you must manually add it to the project. The
custom build tool will update the file during the build.
Ah well! It's easy though, the first time you do the build, it'll fail with a linker error, which is your clue to go find the .g.cpp file and add it. I added the ".g" so that it's obvious this is a generated file; if you try to edit file there are copious warnings. Still, that way you could .gitnore stuff, etc.
The custom step should look like this:
Now you even have a menu item for compiling that specific .h file which in practice seems ... weird. .h files aren't compiled, they are included. Except with Qt.
Related
I want to make two QObject libraries using cmake on windows: ProA & ProB, where ProB depend on ProA.
The code of ProA looks like:
class ProA_Export ProA: public QWidget
{
Q_OBJECT
public:
...
};
The ProB links ProA in CMake: target_link_libraries(ProB ProA).
Then, when I #include "ProA.h" in ProB, it reproted:
unresolved external symbol "public: static struct QMetaObject const ProA::staticMetaObject"
If I remove the Q_OBJECT from ProA, everything is OK except that the signal-slot of QT do not work.
So, how can I solve the unresolved external symbol problem caused by Q_OBJECT?
Any suggestion is appreciated~~~
--------------------- update --------------------
Finally, I find that it is connect cause the problem.
I change
connect(m_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChangeSlot(int)));
to
connect(m_combobox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ProA::indexChangeSlot)
Then, everything is OK. In addition, I find Q_OBJECT is not necessary.
Hope it can help somebody.
I have a problem subclassing a VTK class, but I think the problem could be linked to any kind of library.
I did a vtkInteractorStyleImage subclass, just overriding a method:
#ifndef dcmInteractorStyleImage_h
#define dcmInteractorStyleImage_h
#include "vtkInteractionStyleModule.h" // For export macro
#include "vtkInteractorStyleImage.h"
class VTKINTERACTIONSTYLE_EXPORT dcmInteractorStyle : public vtkInteractorStyleImage
{
public:
static dcmInteractorStyle *New();
vtkTypeMacro(dcmInteractorStyle, vtkInteractorStyleImage);
virtual void OnLeftButtonDown();
void PrintSelf(ostream& os, vtkIndent indent);
};
#endif
The thing is I use it in a Qt class. So I include this in my CMakeLists.txt (simplified):
set(GENERIC_VIEW_CPP
View/UI/dcminteractorstyle.cpp # my new class
)
SET(GENERIC_VIEW_H
View/UI/dcminteractorstyle.h # my new class
)
add_library(generic ${GENERIC_VIEW_CPP} ${GENERIC_VIEW_H})
...
add_library(ui_qt ${UI_QT_CXX}
${UI_FORM_HEADERS} ${UI_RESOURCES_RCC}
${MODEL_WRAPPED_HEADERS}
${GENERIC_VIEW_CPP} ${GENERIC_VIEW_H} #necesary here?
)
qt5_use_modules(ui_qt Core Gui Widgets)
----------------------------------------------------------
# VTK
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
# ITK
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
------------------------------------------------
set_source_files_properties(${UI_RESOURCES_RCC} PROPERTIES GENERATED ON)
add_executable(UtilidadDICOM WIN32 main.cpp ${UI_RESOURCES_RCC})
target_link_libraries(UtilidadDICOM
model
ui_qt
generic
${Glue}
${VTK_LIBRARIES}
${ITK_LIBRARIES}
)
The error trying to compile:
ui_qt.lib(viewerwidget.cpp.obj):-1: error: LNK2019: unresolved
external symbol "public: static class dcmInteractorStyle * __cdecl
dcmInteractorStyle::New(void)" (?New#dcmInteractorStyle##SAPAV1#XZ)
referenced in function "public: static class vtkSmartPointer __cdecl vtkSmartPointer::New(void)"
(?New#?$vtkSmartPointer#VdcmInteractorStyle####SA?AV1#XZ)
ui_qt is a library declared in CMake, as you can see above.
Any ideas? Thank you.
Short answer is that your class is not being linked. Try seeing the value in generic just before linking it to your executable. Do a message just before target_link_libraries:
MESSAGE(${generic})
and see if the generic.lib is actually being linked.
I'm having the famous linking error when trying to combine Qt and VTK. I've done all the steps of installing Qt with VTK correctly so I don't know what could possibly be wrong.
I'm using windows 8 with Qt5 and VTK 6.3 on visual studio.
Here is the error I get:
Drawing.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: __thiscall QVTKWidget::QVTKWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (__imp_??0QVTKWidget##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z) référencé dans la fonction "public: __thiscall Drawing::Drawing(void)" (??0Drawing##QAE#XZ)
1>Drawing.obj : error LNK2019: symbole externe non résolu "__declspec(dllimport) public: virtual __thiscall QVTKWidget::~QVTKWidget(void)" (__imp_??1QVTKWidget##UAE#XZ) référencé dans la fonction "public: __thiscall Drawing::~Drawing(void)" (??1Drawing##QAE#XZ)
And here is the code I use:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QVtk w;
w.show();
//start();
return a.exec();
}
I followed everything that was written here: Combining Qt 5.4.1 with vtk 6.2.0 (using CMake GUI 3.2.1) on windows but somehow I get this error.
Also, I've added: $(QTDIR)\lib to my additional libraries $(QTDIR)\include to my "other include directories" and the followings to my additional dependencies.
qtmaind.lib
C:\Users\Lonni\VTK\Build2012Qt\lib\MinSizeRel\QVTKWidgetPlugin.lib
Qt5Cored.lib
Qt5Guid.lib
Qt5Locationd.lib
Qt5Multimediad.lib
Qt5MultimediaWidgetsd.lib
Qt5Testd.lib
Qt5AxContainerd.lib
Qt5AxBased.lib
Qt5OpenGLd.lib
opengl32.lib
glu32.lib
Qt5Sensorsd.lib
Qt5Svgd.lib
Qt5Widgetsd.lib
EDIT:
I did not use CMake for the project as I have issues when using Cmake even with the small example provided on the wiki which gives the following error with the following CMakeLists.txt. NB: I use Visual Studio as a generator.
CMakeLists:
cmake_minimum_required(VERSION 2.8)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
PROJECT(RenderWindowNoUiFile)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
if(${VTK_VERSION} VERSION_GREATER "6" AND VTK_QT_VERSION VERSION_GREATER "4")
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets REQUIRED QUIET)
else()
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB UI_FILES *.ui)
file(GLOB QT_WRAP *.h)
file(GLOB CXX_FILES *.cxx)
if(${VTK_VERSION} VERSION_GREATER "6" AND VTK_QT_VERSION VERSION_GREATER "4")
qt5_wrap_ui(UISrcs ${UI_FILES} )
# CMAKE_AUTOMOC in ON so the MocHdrs will be automatically wrapped.
add_executable(RenderWindowNoUiFile MACOSX_BUNDLE
${CXX_FILES} ${UISrcs} ${QT_WRAP})
qt5_use_modules(RenderWindowNoUiFile Core Gui)
target_link_libraries(RenderWindowNoUiFile ${VTK_LIBRARIES})
else()
QT4_WRAP_UI(UISrcs ${UI_FILES})
QT4_WRAP_CPP(MOCSrcs ${QT_WRAP})
add_executable(RenderWindowNoUiFile MACOSX_BUNDLE ${CXX_FILES} ${UISrcs} ${MOCSrcs})
if(VTK_LIBRARIES)
if(${VTK_VERSION} VERSION_LESS "6")
target_link_libraries(RenderWindowNoUiFile ${VTK_LIBRARIES} QVTK)
else()
target_link_libraries(RenderWindowNoUiFile ${VTK_LIBRARIES})
endif()
else()
target_link_libraries(RenderWindowNoUiFile vtkHybrid QVTK vtkViews ${QT_LIBRARIES})
endif()
endif()
Error:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindQt4.cmake:1326 (message):
Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
CMakeLists.txt:18 (find_package)
I have installed Qt 4.8.4 for Visual Studio 2010.
qt-win-opensource-4.8.4-vs2010.exe
http://download.qt-project.org/archive/qt/4.8/4.8.4/
Qt project file:
LIBS += -lqaxserver \
-lqaxcontainer
In my Qt GUI application I am using QAxobject to access ms-excel.
When I compile my project in release mode, I do not get any error. And GUI is running as expected. I am able to generate excel files using QAxObject objects.
But I am getting the following 3 errors when doing a debug build:
file not found: qaxcontainer.lib(qaxbase.obj)
file not found: qaxcontainer.lib(qaxobject.obj)
file not found: qaxcontainer.lib(qaxtypes.obj)
Why does this happen only in debug builds? How do I solve it?
Edit :----
I commented LIBS & added CONFIG. Still no change release mode is compiling debug is giving error.
#LIBS += -lqaxserver \
# -lqaxcontainer
CONFIG += qaxserver
CONFIG += qaxcontainer
Now i am getting seven errors :----
AxServerd.lib(qaxtypes.obj) : error LNK2005: "class QColor __cdecl OLEColorToQColor(unsigned int)" (?OLEColorToQColor##YA?AVQColor##I#Z) already defined in QAxContainerd.lib(qaxtypes.obj)
QAxServerd.lib(qaxtypes.obj) : error LNK2005: "bool __cdecl QVariantToVARIANT(class QVariant const &,struct tagVARIANT &,class QByteArray const &,bool)" (?QVariantToVARIANT##YA_NABVQVariant##AAUtagVARIANT##ABVQByteArray##_N#Z) already defined in QAxContainerd.lib(qaxtypes.obj)
QAxServerd.lib(qaxtypes.obj) : error LNK2005: "bool __cdecl QVariantToVoidStar(class QVariant const &,void *,class QByteArray const &,unsigned int)" (?QVariantToVoidStar##YA_NABVQVariant##PAXABVQByteArray##I#Z) already defined in QAxContainerd.lib(qaxtypes.obj)
QAxServerd.lib(qaxtypes.obj) : error LNK2005: "class QVariant __cdecl VARIANTToQVariant(struct tagVARIANT const &,class QByteArray const &,unsigned int)" (?VARIANTToQVariant##YA?AVQVariant##ABUtagVARIANT##ABVQByteArray##I#Z) already defined in QAxContainerd.lib(qaxtypes.obj)
QAxServerd.lib(qaxtypes.obj) : error LNK2005: "void __cdecl clearVARIANT(struct tagVARIANT *)" (?clearVARIANT##YAXPAUtagVARIANT###Z) already defined in QAxContainerd.lib(qaxtypes.obj)
QAxServerd.lib(qaxserver.obj) : error LNK2019: unresolved external symbol "class QAxFactory * __cdecl qax_instantiate(void)" (?qax_instantiate##YAPAVQAxFactory##XZ) referenced in function "class QAxFactory * __cdecl qAxFactory(void)" (?qAxFactory##YAPAVQAxFactory##XZ)
debug\geny.exe : fatal error LNK1120: 1 unresolved externals
link /LIBPATH:"c:\Qt\4.8.4\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /MANIFEST /MANIFESTFILE:"debug\geny.intermediate.manifest" /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /OUT:debug\geny.exe #C:\Users\dguleria\AppData\Local\Temp\geny.exe.17776.15.jom
C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
That's because the libraries are named differently in the debug version. You shouldn't use LIBS for Qt libraries. You should be telling qmake to figure out the link options by doing:
CONFIG += qaxcontainer
This is documented here:
http://qt-project.org/doc/qt-4.8/activeqt-container.html
I am trying to connect to SQL Server 2008R2 with my qt application in windows but I am getting errors. Here's what I am doing:
#include "ui_test1.h";
#include "QtSql/QtSql";
void Test1::on_btnsnd_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("ODBC");
db.setHostName("ITPL_PC1");
db.setDatabaseName("Test");
db.setUserName("sa");
db.setPassword("insforia");
db.open();
QSqlQueryModel *model = new QSqlQueryModel;
QString query = "insert into qttable(PID) values('ARUP')";
model->setQuery(query, db);
db.close();
}
i am getting this error 27 times :
test1.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSqlDatabase::~QSqlDatabase(void)" (__imp_??1QSqlDatabase##QAE#XZ) referenced in function "private: void __thiscall Test1::on_btnsnd_clicked(void)" (?on_btnsnd_clicked#Test1##AAEXXZ)
I don't know how to do this (I found this in google.)
What should I do to fix it?
If you use MSVC, you should add %QTDIR%/lib/QtSql4.lib to Release configuration of your project and %QTDIR%/lib/QtSqld4.lib to Debug one. You should change 4 in file names to 500, if you use Qt 5.0. So, file names would be %QTDIR%/lib/QtSql500.lib and %QTDIR%/lib/QtSqld500.lib
If you use QtCreator you should add the next line into your .pro file
QT += sql
Upd: added description for QtCreator's .pro file