1、libevent下载源码
https://github.com/libevent/libevent
github下载libevent.zip,放到vscode的linux docker中
2、libevent海思编译器下执行编译安装操作
./configure
./configure --prefix=/usr/local/libevent --host=arm-linux CC=arm-himix200-linux-gcc --enable-shared --enable-static --disable-openssl
--prefix:最终的生成的文件放在哪
make
问题:test/test_regress-tinytest.o: file not recognized: File format not recognized
解决:make clean
sudo make install
最终生成的内容:bin include lib
3、编译demo
arm-himix200-linux-gcc LibeventTest3.c -o TestLibeventConnect -L /usr/local/libevent_haisi/lib -levent_core_a -I /usr/local/libevent_haisi/include
注意:动态库和静态库同时存在时,优先使用动态库,这里的event_core_a是改过名字的.a文件
4、运行demo
将TestLibeventConnect5移到docker的work目录
cp TestLibeventConnect /work/nfsroot/yanlong/ (work是服务器的共享盘)
sync (同步一下)
cp /usr/local/libevent/lib/libevent-2.2.so.1* /work/nfsroot/yanlong/
sync
ll /usr/local/libevent/lib/
./TestLibeventConnect5
error while loading shared libraries: libevent-2.2.so.1: cannot open shared object file: No such file or directory
/home/yanlong # ln -s libevent-2.2.so.1.0.0 libevent-2.2.so.1 (链接)
/home/yanlong # ls -al
添加lib库环境变量:export LD_LIBRARY_PATH=/home/yanlong:$LD_LIBRARY_PATH
sync
实际开发:
编译源码:root@7fcebd264e66:/work/nfsroot/yanlong# arm-himix200-linux-gcc MDVRConnectClient.c -o MDVRConnect -L /usr/local/libevent_haisi/lib -levent_core_a -I /usr/local/libevent_haisi/include
在板子上运行:./MDVRConnect