cmake - Qt program does not link, no moc file generated -


i'm using qt, cmake, , vs2010 compiler. there seems problem when i'm linking small piece of test code. linkers gives following error:

plotter.cpp.obj : error lnk2001: unresolved external symbol "public: virtual str uct qmetaobject const * __thiscall plotter::metaobject(void)const " (?metaobject @plotter@@ubepbuqmetaobject@@xz)... 

(it goes on while)

the error occurs when i'm trying inherit qobject in following code:

class plotter : public qobject {         q_object public: 

if leave out q_object, program links, can't use class slots @ runtime. noticed no moc file generated plotter.h. cmakelists.txt:

 cmake_minimum_required (version 2.6)     project (ms)      set(cmake_build_type "release")      find_package(qt4)     include(${qt_use_file})     add_definitions(${qt_definitions})      link_libraries(         ${qt_libraries}     )      set(all_sources plotter.cpp main.cpp dialog.cpp)     qt4_automoc(${all_sources})     add_executable(ms ${all_sources})     target_link_libraries(ms ${link_libraries}) 

a moc file generated dialog.cpp, not plotter.cpp, how possible?

thanks!

first of all, ensure using qt4_automoc correctly. documentation points out, still need include mocced files in sources.

also notice qt4_automoc still marked experimental cmake, sure expect , correctly generates required files. if not, consider switching more robust classic solution using qt4_wrap_cpp:

# notice need pass *header* here, not source file qt4_wrap_cpp(my_moced_files plotter.hpp)  # optional: hide moced files in own source group # useful if using ide supports source_group(moc files ${my_moced_files})  # include moced files build add_executable(ms ${all_sources} ${my_moced_files}) 

apart that, cmake file seems fine.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -