这个代码是xfce4-mcs-plugins-extra中关于menueditor的源代码(menueditor.c),即系统中/usr/lib/xfce4/mcs-plugins/menueditor_plugin.so就是它生成的,从而可以在xfce4桌面的xfce-mcs-manager配置面板中加载“菜单编辑器“设置工具。问题是menueditor_plugin.so是如何利用下面的代码编译的?下面是我的尝试,请大家赐教究竟如何操作?
gcc menueditor.c -fPIC -shared -o menueditor.so
终端获得的输出:
代码:
menueditor.c:30:39: 错误: libxfce4util/libxfce4util.h:没有该文件或目录
menueditor.c:31:37: 错误: libxfcegui4/libxfcegui4.h:没有该文件或目录
menueditor.c:32:37: 错误: libxfce4mcs/mcs-manager.h:没有该文件或目录
menueditor.c:33:45: 错误: xfce-mcs-manager/manager-plugin.h:没有该文件或目录
menueditor.c:39: 错误: expected ‘)’ before ‘*’ token
menueditor.c:44: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mcs_plugin_init’
menueditor.c:74: 错误: expected ‘)’ before ‘*’ token
menueditor.c的源码:
代码:
/*
* Copyright (C) 2007-2008 Gauvain Pocentek <gpocentek@linutop.com>
*
* Mostly taken from the gsynaptics mcs plugin
* Copyright (c) 2004 Danny Milosavljevic <danny_milo@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; You may only use version 2 of the License,
* you have no option to use any other version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxfce4util/libxfce4util.h>
#include <libxfcegui4/libxfcegui4.h>
#include <libxfce4mcs/mcs-manager.h>
#include <xfce-mcs-manager/manager-plugin.h>
#define EXE "xfce4-menueditor"
#define ICON "xfce4-menueditor"
/* static prototypes */
static void run_dialog (McsPlugin *);
/*
*/
McsPluginInitResult
mcs_plugin_init (McsPlugin * plugin)
{
gchar *where = NULL;
xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
plugin->plugin_name = g_strdup ("menueditor");
plugin->caption = g_strdup (Q_("Button Label|Menu editor"));
plugin->run_dialog = run_dialog;
plugin->icon = xfce_themed_icon_load (ICON, 32);
if (plugin->icon)
g_object_set_data_full (G_OBJECT (plugin->icon),
"mcs-plugin-icon-name",
g_strdup (ICON),
g_free);
where = g_find_program_in_path (EXE);
if (where)
{
g_free (where);
return (MCS_PLUGIN_INIT_OK);
}
g_free (where);
return (MCS_PLUGIN_INIT_ERROR);
}
/*
* */
static void
run_dialog (McsPlugin * plugin)
{
xfce_exec(EXE, FALSE, FALSE, NULL);
}