c++ - 'undefined reference to' with cmake -


so, trying write applet school, , part of requires using cmake. have 2 different classes contained in own files, , use them part of main class. have included headers such in main project header:

#include /path/to/header/1.h #include /path/to/header/2.h 

the problem have when run make after i've run cmake, undefined reference errors instance in try use 1 of 2 libraries. know has linker errors, since i'm new cmake, i'm not sure proper way use target_link_libraries be.

edit

after linking/associating libraries, have following:

cmakelists.txt:

# name project project(plasma-engine-gdrive)  # find required libaries find_package(kde4 required) include(kde4defaults)  add_definitions (${qt_definitions} ${kde4_definitions}, -std=c++0x) include_directories(    ${cmake_source_dir}    ${cmake_binary_dir}    ${kde4_includes}    ./include    ./lib    )  set (google_libs include/atom_helper.h include/util/string_utils.h include/client/doc_list_service.h include/client/service.h) set (google_srcs include/atom_helper.cc include/util/string_utils.cc include/client/doc_list_service.cc include/client/service.cc)  # add our source code here set(gdrive_engine_srcs gdriveengine.cpp)  add_library (datawrapper include/datawrapper.cpp include/datawrapper.h) add_library (gdata ${google_srcs} ${google_libs})  # make sure files right place kde4_add_plugin(plasma_engine_gdrive ${gdrive_engine_srcs}) target_link_libraries(plasma_engine_gdrive                       gdata                       datawrapper                       ${kde4_kdecore_libs}                       ${kde4_plasma_libs})  install(targets plasma_engine_gdrive         destination ${plugin_install_dir})  install(files plasma-engine-gdrive.desktop         destination ${services_install_dir}) 

there many errors put here. here's few:

/usr/include/c++/4.6/bits/stl_map.h:467: undefined reference `glib::ustring::ustring()' lib/libgdata.a(atom_helper.o): in function `pair<glib::ustring, glib::ustring, void>': /usr/include/c++/4.6/bits/stl_pair.h:132: undefined reference `glib::ustring::ustring(glib::ustring const&)' /usr/include/c++/4.6/bits/stl_pair.h:132: undefined reference `glib::ustring::ustring(glib::ustring const&)' lib/libgdata.a(atom_helper.o): in function `pair<glib::ustring, glib::ustring>': /usr/include/c++/4.6/bits/stl_pair.h:137: undefined reference `glib::ustring::ustring(glib::ustring const&)' /usr/include/c++/4.6/bits/stl_pair.h:137: undefined reference `glib::ustring::ustring(glib::ustring const&)' 

i working others , got compiled!

all needed provide name of library , put target_link_libraries so:

target_link_libraries(plasma_engine_gdrive                       datawrapper                       gdata                       xml++-2.6                       curl                       glibmm-2.4                       ${kde4_kdecore_libs}                       ${kde4_plasma_libs}) 

my dad, being unfamiliar cmake, went , dug out link.txt within cmake build structure. there, added following after -o flag:

-lxml++-2.6 -lcurl -lglibmm-2.4 

when saw that, thought might try linking through cmakelists.txt -- , worked.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -