PDA

View Full Version : Qt5 Plugin: undefined symbol problem



travick
5th March 2013, 01:06
Hi,

Today I faced really strange problem. Every solution I found doesn't work...
My interfaces and plugins used to work with Qt4 but after migrating to Qt5 they don't work anymore.

after loading this error appears:


"libdialog.so" true "Cannot load library [...]/libdialog.so: ([...]/libdialog.so: undefined symbol: _ZTIN6editor10editorcore6ModuleE)"

I'm also using Cmake to build all stuff

here is My interface class


namespace editor {
namespace editorcore {

class Module {
public:
Module();
virtual ~Module();

void load(const QString& newFileName);
void save(const QString& newFileName);

virtual QString getModuleName() const =0;
const QString& getFileName() const;
QWidget* getQtWidget() const;

void setMainWindow(QMainWindow *mainWindow);

protected:
virtual void onLoad() =0;
virtual void onSave() =0;
virtual void onSetMainWindow() =0;

void setQtWidget(QWidget* newQWidget);

QMainWindow *_mainWindow;
private:
ScopedPtr<QString> _fileName;
QWidget* _qtWidget;
};
// class Module

}// namespace editorcore
} // namespace editor

Q_DECLARE_INTERFACE(editor::editorcore::Module, INTERFACE_NAME)

//////////////////////////////////////////////////////////
// implementation class:

namespace editor {
namespace dialogeditor {

class DialogEditorModule: public QObject, public editor::editorcore::Module {
Q_OBJECT

Q_INTERFACES(editor::editorcore::Module)
Q_PLUGIN_METADATA(IID "editor.DialogEditorModule" FILE "DialogEditorModule.json")

public:
DialogEditorModule();
virtual ~DialogEditorModule();
virtual QString getModuleName() const;

protected:
virtual void onLoad();
virtual void onSave();
virtual void onSetMainWindow();
};

} // namespace dialogeditor
} // namespace editor

////////////////////////////////////
//json file:
{
"Keys": [ "DialogEditorModule" ]
}




#####################
#main project file

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)

GET_FILENAME_COMPONENT(name "${CMAKE_CURRENT_SOURCE_DIR}" NAME)

PROJECT(${name} CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5Widgets REQUIRED)

include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
include_directories(${Qt5Quick_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})


add_subdirectory(app)
add_subdirectory(dialog)


#####################
# app project file

set (COMPILE_ARGS
${${PROJECT_NAME}_SRC_FILES}
${${PROJECT_NAME}_INC_FILES}
${${PROJECT_NAME}_MOC_FILES}
${${PROJECT_NAME}_FORMS}
)

add_executable(${PROJECT_NAME} ${COMPILE_ARGS})

INIT_LIBS()
qt5_use_modules(${PROJECT_NAME} Core)
qt5_use_modules(${PROJECT_NAME} Gui)
qt5_use_modules(${PROJECT_NAME} Widgets)


#####################
# plugin project file

ADD_LIBRARY(${PROJECT_NAME} MODULE
${${PROJECT_NAME}_SRC_FILES}
${${PROJECT_NAME}_INC_FILES}
${${PROJECT_NAME}_MOC_FILES}
)

qt5_use_modules(${PROJECT_NAME} Core)
qt5_use_modules(${PROJECT_NAME} Gui)
qt5_use_modules(${PROJECT_NAME} Widgets)


any idea? I'm totally puzzled...

travick
22nd March 2013, 17:37
The reason of that was

add_definitions(-fvisibility=hidden)
And I didn't export my plugin properly ...