Note that there are some explanatory texts on larger screens.

plurals
  1. PO'undefined reference to' with cmake
    text
    copied!<p>So, I am trying to write an applet for school, and part of it requires using cmake. I have two different classes contained in their own files, and I use them as part of the main class. I have included their headers as such in the main project header:</p> <pre><code>#include /path/to/header/1.h #include /path/to/header/2.h </code></pre> <p>The problem I have is that when I run make after I've run cmake, I get undefined reference errors for any instance in which I try to use one of the two libraries. I know that it has to do with linker errors, but since I'm new to cmake, I'm not exactly sure what the proper way to use TARGET_LINK_LIBRARIES would be.</p> <p>EDIT</p> <p>After linking/associating my libraries, I have the following:</p> <p>CMakeLists.txt:</p> <pre><code># A name for the project project(plasma-engine-gdrive) # Find the 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) # We 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}) # Now make sure all files get to the 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}) </code></pre> <p>There are also too many errors to put here. Here's a few:</p> <pre><code>/usr/include/c++/4.6/bits/stl_map.h:467: undefined reference to `Glib::ustring::ustring()' lib/libGData.a(atom_helper.o): In function `pair&lt;Glib::ustring, Glib::ustring, void&gt;': /usr/include/c++/4.6/bits/stl_pair.h:132: undefined reference to `Glib::ustring::ustring(Glib::ustring const&amp;)' /usr/include/c++/4.6/bits/stl_pair.h:132: undefined reference to `Glib::ustring::ustring(Glib::ustring const&amp;)' lib/libGData.a(atom_helper.o): In function `pair&lt;Glib::ustring, Glib::ustring&gt;': /usr/include/c++/4.6/bits/stl_pair.h:137: undefined reference to `Glib::ustring::ustring(Glib::ustring const&amp;)' /usr/include/c++/4.6/bits/stl_pair.h:137: undefined reference to `Glib::ustring::ustring(Glib::ustring const&amp;)' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload