我使用Debian 8並已安裝libgtkmm-3.0(也是-dev)。現在我有使用gtkmm的一個非常簡單的程序,基本上是一個Hello World:與gtkmm CMake錯誤
main.cpp中:
#include "../include/BrowserWindow.class.hpp"
#include <gtkmm/application.h>
int main(int argv, char *argc[])
{
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
BrowserWindow helloworld;
//Shows the window and returns when it is closed.
return app->run(helloworld);
}
BrowserWindow.class.cpp:
#include "../include/BrowserWindow.class.hpp"
#include <iostream>
BrowserWindow::BrowserWindow()
: m_button("Hello World")
{
set_border_width(10);
m_button.signal_clicked().connect(sigc::mem_fun(*this, &BrowserWindow::on_button_clicked));
add(m_button);
m_button.show();
}
BrowserWindow::~BrowserWindow()
{
}
void BrowserWindow::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}
BrowserWindow.class.hpp:
#ifndef VB_BROWSERWINDOW_CLASS_H
#define VB_BROWSERWINDOW_CLASS_H
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class BrowserWindow : public Gtk::Window
{
public:
BrowserWindow();
virtual ~BrowserWindow();
protected:
void on_button_clicked();
Gtk::Button m_button;
};
#endif
現在,如果我手動編譯它或使用自制makefile,使用pkg-config gtkmm-3.0 --cflags an d pkg-config gtkmm-3.0 --libs,一切工作正常。但是,使用CMake我會編譯錯誤。運行cmake的是罰款:
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for module 'gtkmm-3.0'
-- found gtkmm-3.0, version 3.14.0
-- Configuring done
-- Generating done
-- Build files have been written to: bla/bla/build
運行make是現在的問題:其次是一些潛在的 「候選人」 的功能,我可能意味着
projectdir/hardsource/main.cpp: In function ‘int main(int, char**)’:
projectdir/hardsource/main.cpp:6:102: error: no matching function for call to ‘Gtk::Application::create(char**&, int&, const char [18])’
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
...
的的CMakeLists.txt :
cmake_minimum_required(VERSION 3.0.2)
project(myproject)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
link_directories(${GTKMM_LIBRARY_DIRS})
include_directories(include ${GTKMM_INCLUDE_DIRS})
file(GLOB SOURCES "hardsource/*.cpp")
add_executable(mybinary ${SOURCES})
target_link_libraries(mybinary ${GTKMM_LIBRARIES})
我比較了用手動pkg-conf生成的編譯器標誌(包括以及lib) ig和由cmake的pkg-config生成的。兩者都是相同的。
那麼,怎麼了? :/