I have an empty project, and I added a QAxWidget in Qt Designer. The project compiled before adding the QAxWidget, but now it fails with this linker error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall QAxWidget::QAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0QAxWidget##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z) referenced in function "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi#Ui_MainWindow##QAEXPAVQMainWindow###Z)
Should I change something in my .pro file, add some module perhaps?
Found the answer after some searching, it turned out I need to add this to my .pro file:
LIBS += qaxcontainer.lib
Related
I am trying to use QSoundEffect from QtMultimedia. I have included the file like so:
#include <QtMultimedia/QSoundEffect>
and used QSoundEffect in my project.
When I try to compile my project after this, I get LNK2019 errors:
1>chatwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QSoundEffect::QSoundEffect(class QObject *)" (__imp_??0QSoundEffect##QEAA#PEAVQObject###Z) referenced in function "public: __cdecl ChatWindow::ChatWindow(class QWidget *)" (??0ChatWindow##QEAA#PEAVQWidget###Z)
1>chatwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QSoundEffect::~QSoundEffect(void)" (__imp_??1QSoundEffect##UEAA#XZ) referenced in function "int `public: __cdecl ChatWindow::ChatWindow(class QWidget *)'::`1'::dtor$3" (?dtor$3#?0???0ChatWindow##QEAA#PEAVQWidget###Z#4HA)
1>chatwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QSoundEffect::setSource(class QUrl const &)" (__imp_?setSource#QSoundEffect##QEAAXAEBVQUrl###Z) referenced in function "public: __cdecl ChatWindow::ChatWindow(class QWidget *)" (??0ChatWindow##QEAA#PEAVQWidget###Z)
1>mainwidget.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QSoundEffect::play(void)" (__imp_?play#QSoundEffect##QEAAXXZ) referenced in function "private: void __cdecl MainWidget::process_received_forever(void)" (?process_received_forever#MainWidget##AEAAXXZ)
How can I tell Visual Studio about the existence of QtMultimedia related files? Qt include and library paths are handled by the Qt VS Tools extension in Visual Studio, so I'm a bit confused.
For some weird reason, it worked when I manually added Qt5's libpath to library paths and Qt5Multimedia.lib to included libraries manually.
I use Qt Add-in in my project. But i dont understand , what i do uncorrect.
My .pro file:
QT += core gui network
TEMPLATE = app
TARGET = MMworker
DESTDIR = ../Debug
CONFIG += debug
LIBS += -L"../../../../boost_1_70_0/stage/lib"
DEPENDPATH += .
MOC_DIR += .
OBJECTS_DIR += debug
UI_DIR += .
RCC_DIR += .
Get a lot of errors. For example
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::QHostAddress(void)" (__imp_??0QHostAddress##QAE#XZ) referenced in function...
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __thiscall QHostAddress::setAddress(class QString const &)" (__imp_?setAddress#QHostAddress##QAE_NABVQString###Z) referenced in function ...
Error LNK2019 unresolved external symbol "public: void __thiscall TcpServer::connectToServer(class QHostAddress,int)" (?connectToServer#TcpServer##QAEXVQHostAddress##H#Z) referenced in function...
Error LNK2019 unresolved external symbol "public: bool __thiscall MainTimer::timeAfterMomentExceeds(__int64,__int64)" (?timeAfterMomentExceeds#MainTimer##QAE_N_J0#Z) referenced in function ...
Error LNK2019 unresolved external symbol "private: __int64 __thiscall MainTimer::getMilliseconds(void)" (?getMilliseconds#MainTimer##AAE_JXZ) referenced in function "public: __int64 __thiscall MainTimer::time_ms(void)" (?time_ms#MainTimer##QAE_JXZ)...
Error LNK2019 unresolved external symbol "public: void __thiscall Channel::readData(class QString &)" (?readData#Channel##QAEXAAVQString###Z) referenced in function ...
Error LNK2001 unresolved external symbol "public: virtual void * __thiscall SimpleDevice::qt_metacast(char const *)" (?qt_metacast#SimpleDevice##UAEPAXPBD#Z)...
P.S.: Also I look in qt simple tcp communication with ui projects . I dont understand how I can "You need to enable modules you're using in Qt Project Settings".
UPD1: compile was sucsess, but build still falling.
Error was in inlcude additional dependensies(removed) and included dirs(added)
I'm new and trying to use Quazip under qt 5.5. So I just downloaded project sources from http://quazip.sourceforge.net/ and opened .pro file. When I try to build project I 've got multiple errors:
C1083: Cannot open include file: 'zlib.h': No such file or directory
To avoid building zlib on windows I just installed (from here: http://gnuwin32.sourceforge.net/packages/zlib.htm) complete pack for windows in C:\GnuWin32. Then I added this line in .pro file:
INCLUDEPATH += C:\GnuWin32\include
This generated another error:
Cannot open include file: 'unistd.h': No such file or directory
But changing this line
#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */
into this fixed the problem.
#if HAVE_UNISTD_H
Unfortunately now I get 25 unresolved external symbols, some of them:
quaadler32.obj:-1: error: LNK2019: unresolved external symbol adler32 referenced in function "public: virtual unsigned int __cdecl QuaAdler32::calculate(class QByteArray const &)" (?calculate#QuaAdler32##UEAAIAEBVQByteArray###Z)
quacrc32.obj:-1: error: LNK2019: unresolved external symbol crc32 referenced in function "public: virtual unsigned int __cdecl QuaCrc32::calculate(class QByteArray const &)" (?calculate#QuaCrc32##UEAAIAEBVQByteArray###Z)
unzip.obj:-1: error: LNK2001: unresolved external symbol crc32
quagzipfile.obj:-1: error: LNK2019: unresolved external symbol gzopen referenced in function "private: void * __cdecl QuaGzipFilePrivate::open(class QString const &,char const *)" (?open#QuaGzipFilePrivate##AEAAPEAXAEBVQString##PEBD#Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol deflateInit_ referenced in function "public: virtual bool __cdecl QuaZIODevice::open(class QFlags<enum QIODevice::OpenModeFlag>)" (?open#QuaZIODevice##UEAA_NV?$QFlags#W4OpenModeFlag#QIODevice#####Z)
quaziodevice.obj:-1: error: LNK2019: unresolved external symbol inflate referenced in function "protected: virtual __int64 __cdecl QuaZIODevice::readData(char *,__int64)" (?readData#QuaZIODevice##MEAA_JPEAD_J#Z)
I tries adding this line:
LIBS += -LC:\GnuWin32\lib
But that didn't solve the problem. WHat is the easiest way to use Quazip under Qt?
Download quazip source from quzip site
Open by Qt Creator quazip.pri
Replace all strings #include "zlib.h" or "#include < zlib.h>"
to
#include <QtZlib/zlib.h>
Build project and run unit tests.
I am trying to build a qt project using cmake. As a startinng point, I started off by just writing a simple code in qt creator, which contains main.cpp, mainwindow.cpp & mainwindow.h. Below are my CMakeLists.txt configuration.
cmake_minimum_required(VERSION 2.8.11)
project(testproject)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5Widgets)
find_package(Qt5Core)
get_target_property(QtCore_location Qt5::Core LOCATION)
# Tell CMake to create the executable
add_executable(testproject WIN32 main.cpp mainwindow.cpp)
# Use the Widgets module from Qt 5.
target_link_libraries(testproject Qt5::Widgets)
Cmake did successfully generate the VS Project files. However, when I try to build them in visual studio, it gives me linking errors. Some of the errors are listed below. I could not post the whole error list as it is too long.
>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QWidget::show(void)" (__imp_?show#QWidget##QEAAXXZ) referenced in function main
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication##QEAA#AEAHPEAPEADH#Z) referenced in function main
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QApplication::~QApplication(void)" (__imp_??1QApplication##UEAA#XZ) referenced in function main
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec#QApplication##SAHXZ) referenced in function main
2>mainwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QMetaObject::Connection::~Connection(void)" (__imp_??1Connection#QMetaObject##QEAA#XZ) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow##QEAA#PEAVQWidget###Z)
2>mainwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QString::~QString(void)" (__imp_??1QString##QEAA#XZ) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow##QEAA#PEAVQWidget###Z)
2>testproject_automoc.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual int __cdecl QMainWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (__imp_?qt_metacall#QMainWindow##UEAAHW4Call#QMetaObject##HPEAPEAX#Z) referenced in function "public: virtual int __cdecl MainWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#MainWindow##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
2>testproject_automoc.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const QMainWindow::staticMetaObject" (__imp_?staticMetaObject#QMainWindow##2UQMetaObject##B) referenced in function "void __cdecl `dynamic initializer for 'public: static struct QMetaObject const MainWindow::staticMetaObject''(void)" (??__E?staticMetaObject#MainWindow##2UQMetaObject##B##YAXXZ)
2>MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol WinMain referenced in function __tmainCRTStartup
I am using Qt5.3.1, cmake 3.0.2 and visual studio 2012.
In order to fix this issue you have to remove the WIN32 statement from
add_executable(testproject WIN32 main.cpp mainwindow.cpp).
Possible causes:
Check the source file names in the add_executable command inside your CMakeLists.txt for spelling errors. File names in the source list that do not exist will produce the linker error error LNK2019: unresolved external symbol main referenced.
What does your entry point function look like?
WinMain requires add_executable(testproject WIN32 main.cpp mainwindow.cpp)
main requires add_executable(testproject main.cpp mainwindow.cpp)
Note: I suggest using int main(int argc, char *argv[]), as it will be portable to linux, while using WinMain won't.
I just ran into this error, I was using the x64-Debug configuration in Visual Studio, but the variable CMAKE_PREFIX_PATH in CMake was the path of x86 Qt, so the linker tried to link the x86 Qt libraries to the x64 program and the error occurred.
The solution is correcting the Visual Studio configuration and the Qt path to the same architecture.
You have to link against QtCore, you only link against Qt5::Widgets. Add Qt5::Core to your link libraries. At least for me, the CMake files don't include transitive dependencies (so linking against Qt5::Widgets is not enough.)
I am creating an torrent application using libtorrent in VS 2008. I tried the example given in the link http://www.rasterbar.com/products/libtorrent/examples.html
BUt it is showing me these error....how to solve them?
Linking...
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::~torrent_info(void)" (??1torrent_info#libtorrent##QAE#XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::torrent_info(struct libtorrent::lazy_entry const &)" (??0torrent_info#libtorrent##QAE#ABUlazy_entry#1##Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,struct libtorrent::lazy_entry const &)" (??6libtorrent##YAAAV?$basic_ostream#DU?$char_traits#D#std###std##AAV12#ABUlazy_entry#0##Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "int __cdecl libtorrent::lazy_bdecode(char const *,char const *,struct libtorrent::lazy_entry &,int)" (?lazy_bdecode#libtorrent##YAHPBD0AAUlazy_entry#1#H#Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall libtorrent::lazy_entry::clear(void)" (?clear#lazy_entry#libtorrent##QAEXXZ) referenced in function "public: __thiscall libtorrent::lazy_entry::~lazy_entry(void)" (??1lazy_entry#libtorrent##QAE#XZ)
main.obj : error LNK2019: unresolved external symbol "void __cdecl libtorrent::to_hex(char const *,int,char *)" (?to_hex#libtorrent##YAXPBDHPAD#Z) referenced in function "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,class libtorrent::big_number const &)" (??6libtorrent##YAAAV?$basic_ostream#DU?$char_traits#D#std###std##AAV12#ABVbig_number#0##Z)
main.obj : error LNK2019: unresolved external symbol "public: struct libtorrent::peer_request __thiscall libtorrent::file_storage::map_file(int,__int64,int)const " (?map_file#file_storage#libtorrent##QBE?AUpeer_request#2#H_JH#Z) referenced in function "public: struct libtorrent::peer_request __thiscall libtorrent::torrent_info::map_file(int,__int64,int)const " (?map_file#torrent_info#libtorrent##QBE?AUpeer_request#2#H_JH#Z)
C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\Debug\Lib2.exe : fatal error LNK1120: 7 unresolved externals
The .lib is not included in your project. Make sure you are linking it in;
Configuration Properties -> Linker -> Input -> Additional Dependencies
Another altnerative is to simply copy the .lib to your project folder but don't, it's bound to create problems later on.
Sometimes the .lib is not shipped with the library, so you need to compile it yourself.
The README will tell you this. If this is the case, they usually ship with a .sln file you can open and the just compile it into a .lib file which you then reference in your main application, as I wrote above
Have you added the path of header files in the "Configuration Properties" --> "C/C++“ --> "General" --> "Additional Include Directories"?
The link gives you only the sources (including headerfiles) of libtorrent. You should compile this sources to get a .lib file. Add this .lib file to your client:
Configuration Properties/Linker/Input -> Additional Dependencies: libtorrent-rasterbar.lib
The best starting point for compiling should be the README file.
public: isn't the unresolved symbol. It's just there because the linker it trying to tell you that (most) of the unresolved symbols are public member functions.
It looks like you've included the header for "libtorrent", but not linked to the "libtorrent" library.
You have probably not linked with the torrent library or specified the wrong path to it so that the linker cannot find it.
If the input libraries are of 32bit and your are using them in building a 64bit it might be one of the reasons
For me, I had it included in my project, but it turned out that it was a plugin that was designed to not create an instance of in my unit test.