xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.04k stars 785 forks source link

debug模式下串口无法打开 #683

Closed wangzhankun closed 4 years ago

wangzhankun commented 4 years ago

注:提问题时若使用不能用/没效果/有问题/报错此类模糊表达,但又没有根据下面的模板给出任何相关辅助信息的,将绝对不会有任何反馈。

描述问题

在release模式下,程序可以正常运行打开串口,而在debug模式下运行程序无法打开串口。保证不是串口权限问题或者程序本身问题,因为大量测试结果都指向debug模式编译出的程序是有问题的。初期怀疑是vscode问题,后在gnome-terminal终端中运行发现相同问题。另外发现当debug模式程序按crtl c退出之后会保持对串口的占用。release退出之后系统可以正常释放串口。

image

image

image

期待的结果

debug模式运行的chengy程序也应当能够正常运行以便于调试串口。

错误信息

image

image

相关环境

其他信息

release模式下编译信息:

configure
{
    arch = x86_64
    ld = /usr/bin/g++
    mode = release
    ndk_stdcxx = true
    plat = linux
    ccache = true
    kind = static
    buildir = build
    cxx = /usr/bin/gcc
    host = linux
}
checking for the ccache ... /usr/bin/ccache
[  0%]: ccache compiling.release Infantry/src/InfantryPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryPictureManipulator.cpp.o Infantry/src/InfantryPictureManipulator.cpp
[ 24%]: ccache compiling.release Main/src/actions.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o Main/src/actions.cpp
[  4%]: ccache compiling.release Sentry/src/SentryPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryPictureManipulator.cpp.o Sentry/src/SentryPictureManipulator.cpp
[  9%]: ccache compiling.release Share/SerialPort/src/SerialPort.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/SerialPort/src/SerialPort.cpp.o Share/SerialPort/src/SerialPort.cpp
[ 14%]: ccache compiling.release Buff/src/BuffDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Buff/src/BuffDetector.cpp.o Buff/src/BuffDetector.cpp
[ 19%]: ccache compiling.release Share/Socket/src/Socket.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Socket/src/Socket.cpp.o Share/Socket/src/Socket.cpp
checking for the flags (-MMD -MF) ... ok
> gcc "-MMD" "-MF" "/dev/null"
[ 29%]: ccache compiling.release Share/Camera/src/VirtualCamera.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o Share/Camera/src/VirtualCamera.cpp
[ 34%]: ccache compiling.release Infantry/src/InfantryArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryArmorDetector.cpp.o Infantry/src/InfantryArmorDetector.cpp
Share/Socket/src/Socket.cpp: In member function ‘int Socket::recvMSGFromClient(socketfd)’:
Share/Socket/src/Socket.cpp:195:57: warning: passing NULL to non-pointer argument 3 of ‘socketfd Socket::acceptConnection(socketfd, sockaddr*, socklen_t)’ [-Wconversion-null]
     socketfd sock = acceptConnection(ser_skf, NULL, NULL);
                                                         ^
[ 39%]: ccache compiling.release Hero/src/HeroArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Hero/src/HeroArmorDetector.cpp.o Hero/src/HeroArmorDetector.cpp
[ 44%]: ccache compiling.release Main/src/main.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Main/src/main.cpp.o Main/src/main.cpp
[ 49%]: ccache compiling.release Buff/src/SolveAngle.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Buff/src/SolveAngle.cpp.o Buff/src/SolveAngle.cpp
[ 54%]: ccache compiling.release Sentry/src/SentryArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o Sentry/src/SentryArmorDetector.cpp
[ 59%]: ccache compiling.release Buff/src/BuffPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Buff/src/BuffPictureManipulator.cpp.o Buff/src/BuffPictureManipulator.cpp
[ 64%]: ccache compiling.release Sentry/src/SentryAngleCalculate.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o Sentry/src/SentryAngleCalculate.cpp
[ 69%]: ccache compiling.release Hero/src/HeroAngleCalculate.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Hero/src/HeroAngleCalculate.cpp.o Hero/src/HeroAngleCalculate.cpp
[ 74%]: ccache compiling.release Hero/src/HeroPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Hero/src/HeroPictureManipulator.cpp.o Hero/src/HeroPictureManipulator.cpp
[ 79%]: ccache compiling.release Share/Controller/src/Controller.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o Share/Controller/src/Controller.cpp
[ 84%]: ccache compiling.release Share/Camera/src/GxCamera.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o Share/Camera/src/GxCamera.cpp
[ 89%]: ccache compiling.release Share/Camera/src/RMVideoCapture.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o Share/Camera/src/RMVideoCapture.cpp
[ 94%]: ccache compiling.release Share/Camera/src/OrdinaryCapture.cpp
/usr/bin/ccache /usr/bin/gcc -c -fvisibility=hidden -O3 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o Share/Camera/src/OrdinaryCapture.cpp
[100%]: linking.release CV
/usr/bin/g++ -o build/linux/x86_64/release/CV build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffDetector.cpp.o build/.objs/CV/linux/x86_64/release/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/release/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/release/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/release/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/release/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/release/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/release/Share/Camera/src/OrdinaryCapture.cpp.o -s -fvisibility=hidden -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64 -L/usr/lib

debug模式下编译信息:

configure
{
    plat = linux
    arch = x86_64
    ccache = true
    kind = static
    buildir = build
    host = linux
    mode = debug
    ndk_stdcxx = true
}
checking for the gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the c++ compiler (cxx) ... gcc
checking for the /usr/bin/gcc ... ok
checking for the flags (-O0) ... ok
> gcc "-O0"
checking for the ccache ... /usr/bin/ccache
[  0%]: ccache compiling.debug Infantry/src/InfantryPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryPictureManipulator.cpp.o Infantry/src/InfantryPictureManipulator.cpp
[  4%]: ccache compiling.debug Sentry/src/SentryPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryPictureManipulator.cpp.o Sentry/src/SentryPictureManipulator.cpp
[  9%]: ccache compiling.debug Share/SerialPort/src/SerialPort.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/SerialPort/src/SerialPort.cpp.o Share/SerialPort/src/SerialPort.cpp
[ 14%]: ccache compiling.debug Buff/src/BuffDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffDetector.cpp.o Buff/src/BuffDetector.cpp
[ 19%]: ccache compiling.debug Share/Socket/src/Socket.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Socket/src/Socket.cpp.o Share/Socket/src/Socket.cpp
[ 24%]: ccache compiling.debug Main/src/actions.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Main/src/actions.cpp.o Main/src/actions.cpp
checking for the flags (-MMD -MF) ... ok
> gcc "-MMD" "-MF" "/dev/null"
[ 29%]: ccache compiling.debug Share/Camera/src/VirtualCamera.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/VirtualCamera.cpp.o Share/Camera/src/VirtualCamera.cpp
[ 34%]: ccache compiling.debug Infantry/src/InfantryArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryArmorDetector.cpp.o Infantry/src/InfantryArmorDetector.cpp
[ 39%]: ccache compiling.debug Hero/src/HeroArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroArmorDetector.cpp.o Hero/src/HeroArmorDetector.cpp
[ 44%]: ccache compiling.debug Main/src/main.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Main/src/main.cpp.o Main/src/main.cpp
Share/Socket/src/Socket.cpp: In member function ‘int Socket::recvMSGFromClient(socketfd)’:
Share/Socket/src/Socket.cpp:195:57: warning: passing NULL to non-pointer argument 3 of ‘socketfd Socket::acceptConnection(socketfd, sockaddr*, socklen_t)’ [-Wconversion-null]
     socketfd sock = acceptConnection(ser_skf, NULL, NULL);
                                                         ^
[ 49%]: ccache compiling.debug Buff/src/SolveAngle.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Buff/src/SolveAngle.cpp.o Buff/src/SolveAngle.cpp
[ 54%]: ccache compiling.debug Sentry/src/SentryArmorDetector.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryArmorDetector.cpp.o Sentry/src/SentryArmorDetector.cpp
[ 59%]: ccache compiling.debug Buff/src/BuffPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffPictureManipulator.cpp.o Buff/src/BuffPictureManipulator.cpp
[ 64%]: ccache compiling.debug Sentry/src/SentryAngleCalculate.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryAngleCalculate.cpp.o Sentry/src/SentryAngleCalculate.cpp
[ 69%]: ccache compiling.debug Hero/src/HeroAngleCalculate.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroAngleCalculate.cpp.o Hero/src/HeroAngleCalculate.cpp
[ 74%]: ccache compiling.debug Hero/src/HeroPictureManipulator.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroPictureManipulator.cpp.o Hero/src/HeroPictureManipulator.cpp
[ 79%]: ccache compiling.debug Share/Controller/src/Controller.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Controller/src/Controller.cpp.o Share/Controller/src/Controller.cpp
[ 84%]: ccache compiling.debug Share/Camera/src/GxCamera.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/GxCamera.cpp.o Share/Camera/src/GxCamera.cpp
[ 89%]: ccache compiling.debug Share/Camera/src/RMVideoCapture.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/RMVideoCapture.cpp.o Share/Camera/src/RMVideoCapture.cpp
[ 94%]: ccache compiling.debug Share/Camera/src/OrdinaryCapture.cpp
/usr/bin/ccache /usr/bin/gcc -c -g -O0 -std=c++11 -IMain/include -IShare/Camera/include -IShare/Controller/include -IShare/SerialPort/include -IShare/Socket/include -IShare/Interface -IInfantry/include -ISentry/include -IHero/include -IBuff/include -I/usr/local/include/opencv -I/usr/local/include -m64 -I/usr/include -o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/OrdinaryCapture.cpp.o Share/Camera/src/OrdinaryCapture.cpp
checking for the g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
[100%]: linking.debug CV
/usr/bin/g++ -o build/linux/x86_64/debug/CV build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Share/SerialPort/src/SerialPort.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Socket/src/Socket.cpp.o build/.objs/CV/linux/x86_64/debug/Main/src/actions.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/VirtualCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Infantry/src/InfantryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Main/src/main.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/SolveAngle.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryArmorDetector.cpp.o build/.objs/CV/linux/x86_64/debug/Buff/src/BuffPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Sentry/src/SentryAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroAngleCalculate.cpp.o build/.objs/CV/linux/x86_64/debug/Hero/src/HeroPictureManipulator.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Controller/src/Controller.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/GxCamera.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/RMVideoCapture.cpp.o build/.objs/CV/linux/x86_64/debug/Share/Camera/src/OrdinaryCapture.cpp.o -g -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -lssl -lcrypto -lz -lpthread -lgxiapi -lcjson -m64 -L/usr/lib
wangzhankun commented 4 years ago

xmake脚本如下:

add_syslinks("pthread","gxiapi","cjson")
add_requires("opencv")

includes("Main")
includes("Interface")
includes("Share")
includes("Detector")
includes("Infantry")
includes("Sentry")
includes("Hero")
includes("Buff")

target("CV")
    set_kind("binary")
    set_rules("mode.debug", "mode.release")
    --  set_optimize("fastest")
    add_packages("opencv")

set_languages("cxx11")
waruqi commented 4 years ago

这跟xmake有啥关系? xmake也是调用的gcc编译的,即使真是debug下有问题,那也是 compile flags有差异,或者代码里面 部分macro别动导致走到了不同的逻辑,如果都不是,那顶多是gcc有bug了

这种你自行对比下 前后的 compile flags,排查下那个flags给干扰了,自己查下呗。

或者 xmake f --ccache=n 禁用下,然后 xmake -r 重构下 排除cache的干扰。

wangzhankun commented 4 years ago

本来以为可能是xmake在debug里面可能加了优化。后来去查API发现没有优化。目前的测试各种问题可能都有,难以确定。因为我把cczche=n禁用之后重新编译,debug模式下的程序运行可能运行正确,也可能运行错误。但是release模式下编译之后的结果倒是一定是正确的,目前没有发现release下有错误发生。

waruqi commented 4 years ago

本来以为可能是xmake在debug里面可能加了优化。后来去查API发现没有优化。目前的测试各种问题可能都有,难以确定。因为我把cczche=n禁用之后重新编译,debug模式下的程序运行可能运行正确,也可能运行错误。但是release模式下编译之后的结果倒是一定是正确的,目前没有发现release下有错误发生。

xmake不会自动加各种flags,初始都是空的,大部分flags都是在用户的xmake.lua里面自己配置的。mode.debug rules里面也是加的基础设置,也是用户自己控制是否生效debug rules

而且即使追加了,上面的verbose命令行输出的也是完整的flags了。。稍微对比下就行,不会有隐含其他的flags

waruqi commented 4 years ago

如果觉得还是有隐含的flags存在,你可以通过 xmake project -k makefile生成makefile,然后调用make来编译,makefile里面 的flags肯定是完整全的,然后在里面自己增删Flags,尝试下 是哪个flags干扰了

wangzhankun commented 4 years ago

找到问题了,程序运行结束之后,系统仍然保持了对串口的占用,增加了线程终止机制解决了问题。抱歉。