LIBS += \ # -L"$$EXT_ROOT/google_protocol_buffer/bin_linux" -lprotobuf \ # -L"$$EXT_ROOT/boost/bin_linux" -lboost_thread \ # -L"$$OUTPUT_ROOT/bin" -lgccomm \ -L"$$PWD/../../../External/google_protocol_buffer/bin_linux" -lprotobuf \ -L"$$PWD/../../../External/boost/bin_linux" -lboost_thread \ -L"$$PWD/../../../UIH/bin" -lgccomm
时间: 2024-01-03 08:04:11 浏览: 36
这是一个 Qt 项目中的 .pro 文件中的 LIBS 变量的赋值语句,其中包含了多个库文件的链接选项。其中 -L 选项指定了库文件所在的路径,-l 选项指定了需要链接的库文件名。具体来说,这个 .pro 文件中包含了以下库文件的链接选项:
- google_protocol_buffer/bin_linux/libprotobuf.so
- boost/bin_linux/libboost_thread.so
- OUTPUT_ROOT/bin/libgccomm.so
- ../../../External/google_protocol_buffer/bin_linux/libprotobuf.so
- ../../../External/boost/bin_linux/libboost_thread.so
- ../../../UIH/bin/libgccomm.so
这些库文件的具体作用需要结合代码来判断。
相关问题
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../open cv/opencv/build/x64/vc15/lib/' -lopencv_world410 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../open cv/opencv/build/x64/vc15/lib/' -lopencv_world410d else:unix: LIBS += -L$$PWD/'../../../open cv/opencv/build/x64/vc15/lib/' -lopencv_world410这样链接会出现打包在别的电脑缺少这个库的情况吗,怎么解决或优化呢
是的,如果将Qt项目打包到另一台电脑上运行,但是另一台电脑上没有安装OpenCV库,那么程序就会出现链接库文件失败的错误。
为了解决这个问题,可以将OpenCV库一起打包到程序中。一种方法是将OpenCV库复制到Qt项目中,并在.pro文件中添加以下代码:
```
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/libs/opencv_world410 -lopencv_world410
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/libs/opencv_world410d -lopencv_world410d
else:unix: LIBS += -L$$PWD/libs/opencv_world410 -lopencv_world410
```
其中,$$PWD表示当前.pro文件所在的路径,libs是一个文件夹,用来存放库文件。这样,在打包程序时,将OpenCV库和程序一起打包即可。
另一种方法是使用Qt的插件机制,在程序启动时动态加载库文件。这样可以减小程序的体积。可以在程序中检查OpenCV库是否存在,如果不存在则自动下载并加载库文件。
#!/bin/bash # Assets TEST_IMG=demo.png SDK_ROOT=$PWD TEST_ROOT=$PWD BIN_NAME=test_demo DEVICE_TEST_PATH=/data/local/tmp/ts_ai_sdk_test MODEL_PATH=/sdcard/models RUSULT=/data/local/tmp/ts_ai_sdk_test/results/ RUNTIME=DSP adb root # Push test assets adb shell rm -rf $DEVICE_TEST_PATH # adb shell rm -rf $MODEL_PATH adb shell mkdir -p $DEVICE_TEST_PATH/jpgs adb shell mkdir -p $DEVICE_TEST_PATH/results/post_result adb shell mkdir -p $DEVICE_TEST_PATH/results/img_result #adb shell mkdir -p $MODEL_PATH adb push images/* $DEVICE_TEST_PATH/jpgs # Push SNPE libraries adb push ${SDK_ROOT}/libs/ $DEVICE_TEST_PATH adb push ${SDK_ROOT}/models/model.exf $DEVICE_TEST_PATH/ # Push executable adb push build/$BIN_NAME $DEVICE_TEST_PATH # Test adb shell "chmod +x $DEVICE_TEST_PATH/$BIN_NAME" echo "Running on Android device ..." echo "LD_LIBRARY_PATH='$DEVICE_TEST_PATH/libs' $DEVICE_TEST_PATH/$BIN_NAME $DEVICE_TEST_PATH/jpgs $RUSULT $DEVICE_TEST_PATH/model.exf" echo "Done." adb shell "LD_LIBRARY_PATH='$DEVICE_TEST_PATH/libs' $DEVICE_TEST_PATH/$BIN_NAME $DEVICE_TEST_PATH/jpgs $RUSULT $DEVICE_TEST_PATH/model.exf" # Pull result adb pull $DEVICE_TEST_PATH/results/ . sleep 1改为bat脚本
将该脚本转换为 Windows 的 batch 脚本,需要进行以下修改:
1. 更改第一行为 `@echo off`,表示关闭命令回显。
2. 将变量的赋值方式从 `$变量名=值` 改为 `set 变量名=值`。
3. 将 `adb` 命令行中的路径分隔符 `/` 改为 Windows 下的路径分隔符 `\`。
4. 在执行命令行时需要使用 `call` 命令。
修改后的 batch 脚本如下:
```
@echo off
REM Assets
set TEST_IMG=demo.png
set SDK_ROOT=%cd%
set TEST_ROOT=%cd%
set BIN_NAME=test_demo
set DEVICE_TEST_PATH=/data/local/tmp/ts_ai_sdk_test
set MODEL_PATH=/sdcard/models
set RESULT=/data/local/tmp/ts_ai_sdk_test/results/
set RUNTIME=DSP
REM Push test assets
adb root
adb shell rm -rf %DEVICE_TEST_PATH%
adb shell mkdir -p %DEVICE_TEST_PATH%/jpgs
adb shell mkdir -p %DEVICE_TEST_PATH%/results/post_result
adb shell mkdir -p %DEVICE_TEST_PATH%/results/img_result
adb push images\* %DEVICE_TEST_PATH%/jpgs
REM Push SNPE libraries
adb push %SDK_ROOT%\libs\ %DEVICE_TEST_PATH%
adb push %SDK_ROOT%\models\model.exf %DEVICE_TEST_PATH%\
REM Push executable
adb push build\%BIN_NAME% %DEVICE_TEST_PATH%\
REM Test
adb shell "chmod +x %DEVICE_TEST_PATH%\%BIN_NAME%"
echo Running on Android device ...
echo "LD_LIBRARY_PATH='%DEVICE_TEST_PATH%\libs' %DEVICE_TEST_PATH%\%BIN_NAME% %DEVICE_TEST_PATH%/jpgs %RESULT% %DEVICE_TEST_PATH%/model.exf"
echo Done.
call adb shell "LD_LIBRARY_PATH='%DEVICE_TEST_PATH%\libs' %DEVICE_TEST_PATH%\%BIN_NAME% %DEVICE_TEST_PATH%/jpgs %RESULT% %DEVICE_TEST_PATH%\model.exf"
REM Pull result
adb pull %DEVICE_TEST_PATH%/results/ .
timeout /t 1
```
相关推荐
![rpm](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)