我正在为BOINC客户端测试一些补丁,但是我收到错误消息
/usr/bin/ld: boinc_client-hostinfo_unix.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: multiple definition of `proxy'; boinc_client-user_idle_time_detection.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:6: first defined here
我曾经使用过包括警卫队,但我不知道这可能是什么问题。在这里,我附加了受影响的文件和makefile文件。 谢谢
#include "linux/user_idle_time_detection.h"
CUT
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
double user_idle_time;
double user_pref_idle_time_in_ms;
//user_idle_time = get_user_idle_time();
user_pref_idle_time_in_ms = (idle_time_to_run * 60000);
CUT
linux/user_idle_time_detection.h
#ifndef USER_IDLE_TIME_DETECTION_H
#define USER_IDLE_TIME_DETECTION_H
#include <gio/gio.h>
#include "gnome/gnome_dbus_interface.h"
GDBusProxy* proxy = NULL;
GDBusProxy* create_proxy();
double get_user_idle_time();
#endif /* USER_IDLE_TIME_DETECTION_H */
linux/user_idle_time_detection.c
#include <gio/gio.h>
#include "user_idle_time_detection.h"
GDBusProxy* create_proxy()
{
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
GNOME_DBUS_SERVICE,
GNOME_DBUS_PATH_SETTINGS,
GNOME_DBUS_INTERFACE_SETTINGS,
NULL, NULL);
return proxy;
}
double get_user_idle_time()
{
guint64 user_idle_time;
double user_idle_time_double;
GError* error = NULL;
GVariant* ret = NULL;
proxy = create_proxy();
ret = g_dbus_proxy_call_sync(proxy,
GNOME_DBUS_METHOD_SETTINGS,
NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_print ("GetIdletime failed: %s\n", error->message);
g_error_free (error);
return;
}
g_variant_get(ret, "(t)", &user_idle_time);
user_idle_time_double = (double)user_idle_time;
g_variant_unref (ret);
return user_idle_time_double;
}
linux/gnome/gnome_dbus_interface.h
#ifndef GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_SERVICE "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_PATH_SETTINGS "/org/gnome/Mutter/IdleMonitor/Core"
#define GNOME_DBUS_INTERFACE_SETTINGS "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_METHOD_SETTINGS "GetIdletime"
#endif /* GNOME_DBUS_INTERFACE_H */
## -*- mode: makefile; tab-width: 4 -*-
## $Id$
include $(top_srcdir)/Makefile.incl
if ENABLE_CLIENT_RELEASE
AM_LDFLAGS += -static-libtool-libs
## for an entirely statically linked library, you may want to try
## -all-static instead. There's a good chance it won't work properly,
## so we'll use the safer "-static-libtool-libs" by default.
else
if DYNAMIC_CLIENT
## if libtool starts to need flags for dynamic linking, add them here
else
AM_LDFLAGS += -static
endif
endif ## ENABLE_CLIENT_RELEASE
LIBS += $(CLIENTLIBS)
if OS_DARWIN
LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa -framework CoreServices
endif
bin_PROGRAMS = boinc_client boinccmd
if !OS_WIN32
bin_PROGRAMS += switcher
endif
boinccmd_SOURCES = boinc_cmd.cpp
boinccmd_DEPENDENCIES = $(LIBBOINC)
boinccmd_CPPFLAGS = $(AM_CPPFLAGS)
boinccmd_LDFLAGS = $(AM_LDFLAGS) -L$(top_srcdir)/lib
boinccmd_LDADD = $(LIBBOINC) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
boinc_client_SOURCES = \
acct_mgr.cpp \
acct_setup.cpp \
app.cpp \
app_config.cpp \
app_control.cpp \
app_start.cpp \
async_file.cpp \
check_state.cpp \
client_msgs.cpp \
client_state.cpp \
client_types.cpp \
coproc_sched.cpp \
cpu_sched.cpp \
cs_account.cpp \
cs_apps.cpp \
cs_benchmark.cpp \
cs_cmdline.cpp \
cs_files.cpp \
cs_notice.cpp \
cs_platforms.cpp \
cs_prefs.cpp \
cs_proxy.cpp \
cs_scheduler.cpp \
cs_statefile.cpp \
cs_trickle.cpp \
current_version.cpp \
dhrystone.cpp \
dhrystone2.cpp \
file_names.cpp \
file_xfer.cpp \
gpu_amd.cpp \
gpu_detect.cpp \
gpu_intel.cpp \
gpu_nvidia.cpp \
gpu_opencl.cpp \
gui_http.cpp \
gui_rpc_server.cpp \
gui_rpc_server_ops.cpp \
hostinfo_linux.cpp \
hostinfo_network.cpp \
http_curl.cpp \
log_flags.cpp \
mac_address.cpp \
main.cpp \
net_stats.cpp \
pers_file_xfer.cpp \
project.cpp \
project_list.cpp \
result.cpp \
rr_sim.cpp \
sandbox.cpp \
scheduler_op.cpp \
thread.cpp \
time_stats.cpp \
whetstone.cpp \
work_fetch.cpp \
linux/user_idle_time_detection.c
boinc_client_DEPENDENCIES = $(LIBBOINC)
boinc_client_CPPFLAGS = $(AM_CPPFLAGS) $(GIO_CFLAGS) $(GLIB_CFLAGS)
boinc_client_CXXFLAGS = $(AM_CXXFLAGS) $(SSL_CXXFLAGS)
boinc_client_LDFLAGS = $(AM_LDFLAGS) $(SSL_LDFLAGS) $(GIO_LIBS) $(GLIB_LIBS) -L$(top_srcdir)/lib
if OS_WIN32
boinc_client_CXXFLAGS += -I$(top_srcdir)/coprocs/NVIDIA/include
boinc_client_SOURCES += hostinfo_win.cpp \
hostinfo_wsl.cpp \
sysmon_win.cpp \
win/boinc_cli.rc \
win/res/boinc.ico
else
if OS_DARWIN
boinc_client_LDFLAGS += -Wl,-flat_namespace,-undefined,dynamic_lookup
else
boinc_client_SOURCES += hostinfo_unix.cpp
endif
endif
boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
boinc_clientdir = $(bindir)
if OS_ARM_LINUX
boinc_client_LDADD += libwhetneon.a libwhetvfp.a
noinst_LIBRARIES = libwhetneon.a libwhetvfp.a
libwhetneon_a_SOURCES = whetstone.cpp
libwhetneon_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon
libwhetvfp_a_SOURCES = whetstone.cpp
libwhetvfp_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_VFP -mfloat-abi=softfp -mfpu=vfp
endif
switcher_SOURCES = switcher.cpp
switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
switcher_LDADD = $(LIBBOINC)
## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly. The next two rules do that...
all-local: boinc$(EXEEXT)
boinc$(EXEEXT): boinc_client$(EXEEXT)
rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT)
$(LN) boinc_client$(EXEEXT) boinc$(EXEEXT)
if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi
install-exec-hook:
rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
$(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
## these source files need to be specified because no rule uses them.
EXTRA_DIST = *.h \
mac \
translation \
win
## -*- mode: make; tab-width: 4 -*-
## $Id$
include $(top_srcdir)/Makefile.incl
# (for a while we used "-static -static-libgcc" on linux, but this is obsolete
# now)
#STATIC_FLAGS=@STATIC_FLAGS@
client-bin: @CLIENT_BIN_FILENAME@
LIBS += @CLIENTLIBS@
bin_PROGRAMS = boinc_client
EXTRA_PROGRAMS = cpu_benchmark
boinc_client_SOURCES = \
acct_mgr.cpp \
acct_setup.cpp \
app.cpp \
app_control.cpp \
app_graphics.cpp \
app_start.cpp \
check_state.cpp \
client_msgs.cpp \
client_state.cpp \
client_types.cpp \
cs_account.cpp \
cs_apps.cpp \
cs_benchmark.cpp \
cs_cmdline.cpp \
cs_data.cpp \
cs_files.cpp \
cs_prefs.cpp \
cs_scheduler.cpp \
cs_statefile.cpp \
cs_trickle.cpp \
dhrystone.cpp \
dhrystone2.cpp \
file_names.cpp \
file_xfer.cpp \
gui_http.cpp \
gui_rpc_server.cpp \
gui_rpc_server_ops.cpp \
hostinfo_linux.cpp \
hostinfo_network.cpp \
hostinfo_unix.cpp \
http_curl.cpp \
log_flags.cpp \
main.cpp \
net_stats.cpp \
net_xfer_curl.cpp \
pers_file_xfer.cpp \
scheduler_op.cpp \
time_stats.cpp \
whetstone.cpp \
linux/user_idle_time_detection.c
boinc_client_DEPENDENCIES = $(LIBRSA)
boinc_client_CPPFLAGS = -D_USE_CURL -I../../curl-7.14.0/include -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_LDFLAGS = -static-libgcc
boinc_client_LDADD = -L/usr/local/ssl/lib -lssl -L../../curl-7.14.0/lib -lcurl -L../lib -lboinc $(RSA_LIBS) $(PTHREAD_LIBS)
#boinc_client_LDFLAGS = $(STATIC_FLAGS)
# the following don't do anything
cpu_benchmark_SOURCES = whetstone.cpp dhrystone.cpp
cpu_benchmark_CFLAGS = -O3 $(AM_CFLAGS)
all-local: client-bin
# make a hard link to the client name.
@CLIENT_BIN_FILENAME@: boinc_client
rm -f $@
@LN@ $? $@
@STRIP@ $@
## these source files need to be specified because no rule uses them.
EXTRA_DIST = *.h \
mac \
translation \
win
clean-local:
rm -f @CLIENT_BIN_FILENAME@
configure.ac 由于Stackoverflow字符限制,无法在此处插入。
答案 0 :(得分:3)
如果您打算将proxy
用作跨多个翻译单元的全局变量,则应使用extern
进行声明。