c++ - 如何在我的笔记本电脑中使用 c++ 从 asprise ocr 代码运行示例?
问题描述
我正在使用示例代码来运行 asprise 库,但是当我编译时显示一个我不理解的错误,请有人可以帮助我吗?
我是在 C++ 中使用外部库的新手
#include <iostream>
#include "asprise_ocr_api.h"
using namespace std;
void testOcr() {
// CHANGE TO THE ACTUAL PATH to the folder where the aocr.dll or aocr.so locates in
const char * libFolder = "/home/jesus/Descargas/LIB_FOLDER/libaocr_x64.so";
// CHANGE TO THE ACTUAL PATH to the input image, can be jpeg, gif, png, tiff or pdf.
const char * fileImg = "/home/jesus/Descargas/out.tiff";
LIBRARY_HANDLE libHandle = dynamic_load_aocr_library(libFolder);
// one time setup
int setup = c_com_asprise_ocr_setup(false);
if (setup != 1) {
cerr << "Failed to setup. code: " << setup << endl;
return;
}
// starts the ocr engine; the pointer must be of long long type
long long ptrToApi = c_com_asprise_ocr_start("eng", OCR_SPEED_FAST, NULL, NULL, NULL);
if (ptrToApi == 0) {
cerr << "Failed to start." << endl;
return;
}
char * s = c_com_asprise_ocr_recognize(ptrToApi, fileImg, -1, -1, -1, -1, -1,
OCR_RECOGNIZE_TYPE_ALL, OCR_OUTPUT_FORMAT_PDF,
"PROP_PDF_OUTPUT_FILE=result.pdf|PROP_PDF_OUTPUT_TEXT_VISIBLE=true|\
PROP_PDF_OUTPUT_RETURN_TEXT=text", "|", "=");
cout << "Returned: " << s << endl;
// do more recognition here ...
// finally, stops the OCR engine.
c_com_asprise_ocr_stop(ptrToApi);
cout << "Unload: " << (dynamic_unload_aocr_library(libHandle) ? "OK" : "Failed") << endl;
}
int main() { // Entry point
testOcr();
std::cout << "Press ENTER to exit: ";
std::cin.ignore();
return 0;
}
错误是:
/tmp/ccqY74eR.o: En la función `dynamic_load_aocr_library(char const*)':
aspr.cpp:(.text+0x1c5): referencia a `dlopen' sin definir
aspr.cpp:(.text+0x1db): referencia a `dlerror' sin definir
aspr.cpp:(.text+0x20f): referencia a `dlsym' sin definir
aspr.cpp:(.text+0x22c): referencia a `dlsym' sin definir
aspr.cpp:(.text+0x249): referencia a `dlsym' sin definir
aspr.cpp:(.text+0x266): referencia a `dlsym' sin definir
aspr.cpp:(.text+0x283): referencia a `dlsym' sin definir
/tmp/ccqY74eR.o:aspr.cpp:(.text+0x2a0): más referencias a `dlsym' sin definir a continuación
/tmp/ccqY74eR.o: En la función `dynamic_unload_aocr_library(void*)':
aspr.cpp:(.text+0x493): referencia a `dlclose' sin definir
collect2: error: ld returned 1 exit status
解决方案
推荐阅读
- c - 格式说明符“%02x”和“%3o”在这段代码中有什么作用?
- c++ - 复制剪辑中的环境结构?
- python - 使用 ipywidgets 制作单位转换器
- c++ - 如何从长度为 9 的文本文件中获取单词?
- python - 更新期间的Django rest序列化程序验证错误
- reactjs - 如何修复:React fetch Post 方法使用 FormData 和 Flask API 失败
- svelte - 如何在 sapper/svelte 中使用多个 URL 参数
- c# - 如何通过关系子/父的 2 个字段排序。对其进行排序以使子项在排序列表中跟随其父项?
- confluent-schema-registry - Debezium 发件箱模式 | 如果我们使用 debezium,架构是用 SMT/发件箱表固定的吗
- python - 使用 multiLine 选项和编码选项读取 CSV