2016-05-18 46 views
2

我使用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生成的。两者都是相同的。

那么,怎么了? :/

回答

2

您已在主要功能中调换了argcargv。变化:

int main(int argv, char *argc[]) 

int main(int argc, char *argv[]) 

What does int argc, char *argv[] mean?

作为一个方面说明,我怀疑这是真的自制的Makefile工作。也许你并没有真正编译所有文件。