分类 Linux软件开发 下的文章

1、下载(linuxdeploy-x86_64.AppImage) https://github.com/linuxdeploy/linuxdeploy 2、下载(appimagetool-x86_64.AppImage) https://github.com/AppImage/AppImageKit 3、准备两个文件(应用程序可执行文件和Logo图片文件) 此处加入两个文件分别为: demo 和 demo.png 4、生成打包文件夹 ./linuxdeploy-x86_64.AppImage --appdir=APPDIR -e demo -l /lib/x86_64-linux-gnu/libm.so.6 --create-desktop-file --icon-file=demo.png 执行完该命令后,生成打包文件夹: APPDIR 5、打包 ./appimagetool-x86_64.AppImage ./APPDIR/ 执行完该命令后,在当前目录生成: demo.AppImage

intsetlflag(int flags, int enable) { structtermiosattr; tcgetattr(STDIN_FILENO, &attr); if (enable) { attr.c_lflag |= flags; // 使能标志位 } else { attr.c_lflag &= ~flags; // 清除标志位 } return tcsetattr(STDIN_FILENO, TCIFLUSH, &attr); } intmain(int argc, char* argv[]) { ... printf("enter password: "); fflush(stdout); setlflag(ECHO | ICANON, 0); // 关闭回显及常规模式 for (int i = 0; i < sizeof(password) && password[i-1] != '\n'; i++) { password[i] = getchar(); printf("*"); fflush(stdout); } printf("\n"); setlflag(ECHO | ICANON, 1); // 恢复回显及常规模式 printf("%s\n", strcmp(username, password) ? "✖️" : "✔️"); return0; } 在禁用回显的同时还要实现将每个输入字符回显为*样式,我们就必须在每次keypress的时候打印一个星号,但如果直接调用getchar读输入时就会发现必须在用户敲下回车键才能读到,如何免回车读取一个字符呢——答,禁用ICANON。 Canonical(常规模式)即前文提到的ICANON标志位,它同样受控于c_lflag字段。此模式下的输入处理都是line-by-line在缓存中的,这也就是为什么我们在调用fgets时总需要回车才能读到,只要你没回车就可以在行内进行简单编辑,如删除字符、清行、复制粘贴等操作。一旦关闭后,输入的处理就会变成byte-by-byte,行内编辑也失效了,什么删除符、箭头、TAB、^Y、^U、^X、F1-F12等特殊键统统被当作输入字符处理,且立即生效。

\#!/bin/bash EXE_BIN="lidar_perception_viewer" EXE_FILE="build/$EXE_BIN" LOG_FILE="./icons/${EXE_BIN}.png" LINUX_DEPLOY="/home/flmxi/Desktop/PC_Tool/AppImageTool/linuxdeploy-x86_64.AppImage" APPIMAGE_TOOL="/home/flmxi/Desktop/PC_Tool/AppImageTool/appimagetool-x86_64.AppImage" if test -f "$EXE_FILE"; then echo "" else echo "Error: file [$EXE_FILE] does not exist." exit fi if test -f "$LOG_FILE"; then echo "" else echo "Error: file [$LOG_FILE] does not exist." exit fi if test -f "$LINUX_DEPLOY"; then echo "" else echo "Error: file [$LINUX_DEPLOY] does not exist." exit fi if test -f "$APPIMAGE_TOOL"; then echo "" else echo "Error: file [$APPIMAGE_TOOL] does not exist." exit fi rm -rf ./build/APPDIR $LINUX_DEPLOY --appdir=./build/APPDIR -e $EXE_FILE --create-desktop-file --icon-file=$LOG_FILE APP_OUT_BIN=$EXE_BIN APP_OUT_BIN+='-x86_64.AppImage' rm -f ${APP_OUT_BIN} \# special case for ROS rm -f build/APPDIR/AppRun touch build/APPDIR/AppRun chmod a+x build/APPDIR/AppRun \#cp -rf /opt/ros ./build/APPDIR/usr/ #modify /opt/ros according to your Linux env. echo '#!/bin/bash' > build/APPDIR/AppRun echo 'RUNTIME_DIR="$(dirname "$(readlink -f "${0}")")"' >> build/APPDIR/AppRun echo 'source "${RUNTIME_DIR}/usr/ros/noetic/setup.bash"' >> build/APPDIR/AppRun \#echo 'exec "${RUNTIME_DIR}/usr/bin/lidar_perception_viewer" "$@"' >> build/APPDIR/AppRun CMD='exec "${RUNTIME_DIR}/usr/bin/' CMD+=${EXE_BIN} CMD+='"' CMD+=' "$@"' echo ${CMD} >> build/APPDIR/AppRun $APPIMAGE_TOOL ./build/APPDIR