2

When I try to compile my test app it fails.

CMakeLists.txt:

cmake_minimum_required( VERSION 2.8.8 )
project( webkit-test )

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package( Qt5Core )
find_package( Qt5Gui )
find_package( Qt5OpenGL )
find_package( Qt5Network )
find_package( Qt5WebKit )
find_package( Qt5Widgets )

add_executable( webkit-test main.cpp )

qt5_use_modules( webkit-test Core Gui OpenGL Network WebKit Widgets )

C++ code:

#include <QtWidgets/QApplication>
#include <QtWebKit/QWebView>

int main( int argc, char *argv[] )
{
        QString file;
        if ( argc >= 2 )
                file = argv[1];

        QApplication a( argc, argv );

        return a.exec();
}

I generate makefile by cmake -G "NMake Makefiles" (3) and then use nmake (4).

After I received that I used dumpbin /EXPORTS QtWebKit5.dll > QtWebKit5.dll.exports.txt and dumpbin /EXPORTS QtWebKit5.lib > QtWebKit5.lib.exports.txt for seeing to exporting symbols: (5) and (6).

By using Ctrl+F you can find in these files "unresolved" external symbols:

?staticMetaObject@QWebPage@@2UQMetaObject@@B (public: static struct QMetaObject const QWebPage::staticMetaObject)

?staticMetaObject@QWebView@@2UQMetaObject@@B (public: static struct QMetaObject const QWebView::staticMetaObject)

If symbols are in QtWebKit5.lib, why I have these errors when linking?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
zodiac
  • 353
  • 3
  • 18
  • 1
    I've replaced your links and improved some of the markup, but you should really consider putting at least the code from (1) and (2) directly in your question, the files are tiny and it will make it much more likely people will look at them than if they have to follow links to pastebin – Jonathan Wakely Jul 21 '12 at 13:49
  • How do you link with QtWebKit5.lib? – stark Jul 21 '12 at 13:49
  • It looks like you have a header included but it can't find the associated library. – N_A Jul 21 '12 at 14:02
  • stark, cmake finds that library and use this path in makefile. – zodiac Jul 21 '12 at 14:09
  • mydogisbox, nmake knows where is QtWebKit5.lib. I tried show the path to that lib in CMakeLists.txt for confidence. Error were the same. – zodiac Jul 21 '12 at 14:10
  • I was just saying what the error was. I don't know why you're getting it. – N_A Jul 21 '12 at 14:11

2 Answers2

2

some reasons affect to this,

if you use Qt with version greater than 4.7, add this namespace to your project's ".pro" file:

QT += webkitwidgets

and if less equals than 4.7:

QT += webkit

and change your QWebView library to (if gets a warning about "No such file or directory" do not worry!)

#include <QwebView>
Reza Ebrahimi
  • 3,623
  • 2
  • 27
  • 41
1

I added add_definitions(-DQT_DLL) to my CMakeLists.txt and now it's compiled.

zodiac
  • 353
  • 3
  • 18