您的位置:首页 > 其它

ubuntu16.04 下dbus-cxx Library编译安装指南

2017-10-11 15:44 537 查看
下载去官网http://dbus-cxx.sourceforge.net/index.html

然后他说依赖几个库,

dbus: http://dbus.freedesktop.org -
Should be installed by default (runtime dependency) 
libsigc++ http://libsigc.sourceforge.net/ (compile
dependency) See the README file for more information on compile-time dependencies

前者我sudo apt-get install dbus* 估计装了一堆东西

后者可以直接sudo apt-get install libsigc++就行了

其实可能还依赖一堆东西,缺啥apt-get啥就行了。这个很烦……

然后去根目录下执行 configure,会生成makefile。

这个makefile八成是编译不过的……因为缺少2个文件。那2个文件,再官网找找,找到了放在根目录下。

然后再makefile就可以编译通过了。

然后sudo make install就可以安装了。

接着测试样例程序,样例程序的makefile很复杂,我很菜也看不懂。

然后我自己给改了。。。(2个程序原来的文件名我分别改为a.cpp和b.cpp)

CFLAGS += -I/usr/local/include/dbus-cxx-0.9/
CFLAGS += -I/usr/include/dbus-1.0/
CFLAGS += -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
CFLAGS += -I/usr/include/sigc++-2.0
CFLAGS += -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include

LIBS += -ldbus-1 -lsigc-2.0 -lpthread -lrt -ldbus-cxx -lpopt
CXX = g++ -std=c++14
aim : a b
a : a.o
$(CXX) -o a a.o $(CFLAGS) $(LIBS) $(LDFLAGS)
a.o : a.cpp
$(CXX) -c a.cpp $(CFLAGS) $(LIBS) $(LDFLAGS)
b : b.o
$(CXX) -o b b.o $(CFLAGS) $(LIBS) $(LDFLAGS)
b.o : b.cpp
$(CXX) -c b.cpp $(CFLAGS) $(LIBS) $(LDFLAGS)

那一堆依赖,缺啥装啥。特别是lpopt别忘了,不然其他库编译不过。

至此,dbus-cxx-0.9.0/examples/quick-start算是编译通过了。

现在dbus-cxx-0.9.0/examples/basics/methods里的makefile应该是编译不过去的。

手动打开里面的makefile,找到g++相关,加上-lpopt  (原来作者怎么编译过的)

同时源程序里一些函数也编译不过,打开程序加上std::   (难道原作者引用了某个using namespace std的东西?) 就可以编译过了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: