一、ALLJOYN在linux下的编译
1.环境:
ubuntu12.04下的 virtualbox 安装的ubuntu10.04虚拟机(ubuntu-10.04.3-desktop-amd64.iso)
alljoyn代码:从官网下载即可--https://allseenalliance.org/developers/download alljoyn-14.12.00b-src.tar.gz
运行命令:
2.编译结果路径
编译后会生成alljoyn/build目录,该目录下存放编译结果
3. error && solution
(1).error:junit4.9.jar: error in opening zip file
solution:版本问题,需下载---junit/junit-4.9.jar.zip( 217 k)
http://www.java2s.com/Code/Jar/j/Downloadjunit49jar.htm
(2). alljoyn_c/src/BusAttachment.cc:456: error: 'nullptr' was not declared in this scope
analysis:nullptr是C++11引入的新特性,解决C和C++中NULL的定义不一致所带来的编译器兼容问题。
C中NULL是指向0地址的指针(void *)0,c++中则是定义为整数0.
!!!在ndk中解决这个问题的办法就是添加对C++11的支持
(最后GNU GCC编译器的问题)
solution:
http://sourceforge.net/p/ngrt4n/tickets/8/
This means that nullptr (from c++11) is not supported by the compilator.
To fix that, edit the related file and replace any occurrence of 'nullptr' with 'NULL'
(3). sys/capability.h no such file directory.....
locate xxx :查看文件的位置,替换文件
solution:(将gcc4.6.3中的/sys/capability.h文件拷贝到sys/下即可)
cp xx/387debug/my-ap/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/sys/capability.h /home/tonylau/2-shared-files/xxxxx/0--allseen--refer
(4)./usr/bin/ld: cannot find -lcap
analysis:查看libcap.so(初步分析是缺少指向该库的链接)
tonylau2010@tonylau2010-desktop:/usr/lib$ locate libcap.so
/lib/libcap.so.2
/lib/libcap.so.2.17
/lib32/libcap.so
/lib32/libcap.so.2
/lib32/libcap.so.2.17
solution:在/usr/lib目录下建立一个指向libcap.so.2的软链接libcap.so
tonylau2010@tonylau2010-desktop:/usr/lib$ sudo ln -sv /lib/libcap.so.2 libcap.so
tonylau2010@tonylau2010-desktop:/usr/lib$ ls -al libcap.so
lrwxrwxrwx 1 root root 16 2015-04-28 15:38 libcap.so -> /lib/libcap.so.2
(5).scons: Building targets ...
[CXX]alljoyn_core/samples/eventaction/SimpleRulesEngine/posix/MyAllJoynCode.cc
cc1plus: warnings being treated as errors
/把Makefile中的FLAG_WERROR = -Werror这一项注释掉,重新make
//solution:使用gcc4.4.6版本进行编译.(待解决)--后续升级ubuntu版本后在重试
//临时解决方案:不编译出错的samples:eventaction,即/home/tonylau2010/alljoyn/alljoyn_core/samples下的eventaction===>>>>>>直接将eventaction重命名为 xx--eventaction
(6).[ws] Error 1
/home/tonylau2010/alljoyn/common/unit_test/CryptoECCTest.cc
WS total run time: 5.27 seconds
scons: *** [ws] Error 1
scons: building terminated because of errors.
solution:不做 Whitespace policy checker :编译命令中添加WS=off
详情可参见allseen官网:https://allseenalliance.org/developers/develop/building/linux/build-source如下部分:
Whitespace policy checker
By default, the whitespace policy checker runs every time. If you continually get build errors associated with the whitespace.py script, it can be shut off using this command:
$ scons WS=off
If the whitespace policy checker reports a whitespace policy violation, it lists which files have the violation. To see the lines of code that are violating the AllJoyn whitespace policy, run:
$ scons WS=detail
Uncrustify can automatically fix your files to adhere to the whitespace policy.
$ scons WS=fix
(7)./alljoyn-daemon: error while loading shared libraries
analysis:可执行文件缺少库文件,可以查看到在/home/tonylau2010/alljoyn/build/linux/TARGET_CPU/debug/dist/cpp/lib下有相应的库文件liballjoyn.so,所以应该是系统没有找到这个库文件。
solution:
在每一个cmd窗口打开后要设置库文件的路径:(可以参考--https://allseenalliance.org/developers/develop/run-sample-apps/basic/linux下官方说明)
export TARGET_CPU=x86_64
export LD_LIBRARY_PATH=/home/tonylau2010/alljoyn/build/linux/TARGET_CPU/debug/dist/cpp/lib #:$LD_LIBRARY_PATH
(8).其他compile error可参见如下部分:
1). http://blog.csdn.net/baiwfg2/article/details/33823403
【AllJoyn框架-02】ubuntu下编译测试AllJoyn
2). http://www.ithao123.cn/content-1904329.html
Ubuntu下编译AllJoyn源码及遇到的问题
二、ALLJOYN在linux下的samples 运行
详细内容可以参见allseen官网:https://allseenalliance.org/developers/develop/run-sample-apps/basic/linux
1.打开两个shell 并分别执行如下脚本,source run-env.sh,其内容如下://作用是加载lib库文件的inlude 路径
export AJ_ROOT=`pwd`
# <TARGET CPU> can be either x86_64, x86, or whatever value you set for "CPU=" when running SCons.
export TARGET_CPU=x86
export LD_LIBRARY_PATH=$AJ_ROOT/core/alljoyn/build/linux/$TARGET_CPU/debug/dist/cpp/lib:$LD_LIBRARY_PATH
2.然后分别在两个window下分别进入客户端、服务器端可执行程序的目录,并分别启动 客户端basic_client
以及服务器端basic_service
(1)
basic_service
端
$AJ_ROOT/core/alljoyn/build/linux/$TARGET_CPU/debug/dist/cpp/bin/samples/basic_service
(2)
basic_client
端
$AJ_ROOT/core/alljoyn/build/linux/$TARGET_CPU/debug/dist/cpp/bin/samples/basic_client