[QScintilla] Dll linkage while compiling a custom lexer.

Nicolas Desprès nicolas.despres at gmail.com
Tue Mar 18 09:29:48 GMT 2008


Hi list,

I'm trying to write a custom lexer for QScintilla using
QScintilla-gpl-2-snapshot-20071117 and Qt-4.3.2 compiled with MSVC++
2005. I got this error:

C:\cygwin\home\build\despres\build\test-qsci\moc_mylexer.cxx(36) : warning C427\
3: 'staticMetaObject' : inconsistent dll linkage
        c:\cygwin\home\build\despres\build\test-qsci\../../src/test-qsci/mylexe\
r.h(6) : see previous definition of 'public: static QMetaObject const MyLexer::\
staticMetaObject'
C:\cygwin\home\build\despres\build\test-qsci\moc_mylexer.cxx(36) : error C2491:\
 'MyLexer::staticMetaObject' : definition of dllimport static data member not a\
llowed

Here the code I'm trying to compile:

/// mylexer.cpp
#include "mylexer.h"

MyLexer::MyLexer(QObject* p):
  QsciLexer(p)
{

}

/// mylexer.h

#define QSCINTILLA_DLL
#include <Qsci/qscilexer.h>
class QSCINTILLA_EXPORT MyLexer : public QsciLexer
{
Q_OBJECT

  public:

 MyLexer(QObject* p = 0);

};

/// CMakeLists.txt
# CMake configuration.
cmake_minimum_required(VERSION 2.4.0)
#set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)

find_package(Qt4 REQUIRED)
add_definitions(${QT_DEFINITIONS})
find_library(QSCINTILLA2_LIBRARY
    NAMES qscintilla2
    PATHS ${QT_LIBRARY_DIR})
find_path(QSCINTILLA2_INCLUDE_DIR
    NAMES Qsci/qsciapis.h
    PATHS ${QT_INCLUDE_DIR})

set(test_SRCS
  mylexer.cpp
  )
set(test_MOC_HDRS
  mylexer.h
  )
qt4_wrap_cpp(test_MOC_SRCS ${test_MOC_HDRS})
add_library(test SHARED
  ${test_SRCS}
  ${test_MOC_SRCS}
  ${test_MOC_HDRS}
  )
include_directories(
  ${QT_INCLUDE_DIR}
  ${QT_QTCORE_INCLUDE_DIR}
  ${QT_QTGUI_INCLUDE_DIR}
  ${QSCINTILLA2_INCLUDE_DIR}
  )
target_link_libraries(test
  ${QT_QTCORE_LIBRARY}
  ${QT_QTGUI_LIBRARY}
  ${QSCINTILLA2_LIBRARY}
  )

To reproduce the error run: cmake . -G 'NMake Makefiles'
-DCMAKE_VERBOSE_MAKEFILE=ON && nmake.exe

I could not work around this problem, I hope you guys have better idea.

Cheers,

-- 
Nicolas Desprès



More information about the QScintilla mailing list