AAA
发布于

链接glib库时一直提示找不到`g_dbus_proxy_new_for_bus_sync'?

为什么我在编译链接 glib 库时,有使用-l -L -l 指定头文件位置和库的路径,但是链接就是不通过呢?


#include <gio/gio.h>
#include <libnm/nm-dbus-interface.h>

int main()
{

	GDBusProxy *proxy = NULL;
    gboolean found = FALSE;

	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                   G_DBUS_PROXY_FLAGS_NONE,
                   NULL,
                   // "org.freedesktop.NetworkManager"
                   NM_DBUS_SERVICE,
                   //"/org/freedesktop/NetworkManager"
                   NM_DBUS_PATH,
                   //"org.freedesktop.NetworkManager"
                   //NM_DBUS_INTERFACE,
                   "org.freedesktop.DBus.Properties",
                   NULL, NULL);
	g_assert (proxy != NULL);

	g_object_unref (proxy);
	return 0;
}




wrx@ubuntu:~/Desktop$ gcc a.c -o a.out -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ 
-L/usr/lib/x86_64-linux-gnu -lglib-2.0
/tmp/ccSOt4vE.o: In function `main':
a.c:(.text+0x3c): undefined reference to `g_dbus_proxy_new_for_bus_sync'
a.c:(.text+0x76): undefined reference to `g_object_unref'
collect2: error: ld returned 1 exit status


wrx@ubuntu:~/Desktop$ gcc a.c -o a.out $(pkg-config --cflags --libs glib-2.0)
/tmp/ccOphBNT.o: In function `main':
a.c:(.text+0x3c): undefined reference to `g_dbus_proxy_new_for_bus_sync'
a.c:(.text+0x76): undefined reference to `g_object_unref'
collect2: error: ld returned 1 exit status


可问题是glib库明明就在路径下找得到。。。。
wrx@ubuntu:~$ ls /usr/lib/x86_64-linux-gnu/libglib*
/usr/lib/x86_64-linux-gnu/libglib-2.0.a
/usr/lib/x86_64-linux-gnu/libglib-2.0.so
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
/usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1
/usr/lib/x86_64-linux-gnu/libglibmm-2.4.so.1.3.0
/usr/lib/x86_64-linux-gnu/libglibmm_generate_extra_defs-2.4.so.1
/usr/lib/x86_64-linux-gnu/libglibmm_generate_extra_defs-2.4.so.1.3.0
/usr/lib/x86_64-linux-gnu/libglib.so
评论(2)