未定义的引用TessBaseApi()和pixDestroy

时间:2017-04-14 08:11:33

标签: c++ dll tesseract leptonica

我正在尝试编译一个简单的example,以便在windows下使用tesseract api。

Leptonica 1.74.1是通过Cmake和msbuild通过以下步骤安装的:

mkdir build cd build cmake .. msbuild leptonica.sln

Tesseract从github下载并编译以构建库(CMAKE_PREFIX_PATH已修改为添加LeptonicaConfig.cmake的路径):

mkdir build cd build cmake .. msbuild tesseract.sln

完成这些步骤后,创建了dpt leptonica-1.74.1d.dll和tesseract400d.dll。 然后通过命令mingw32-make使用makefile编译简单的example

CPP64 = x86_64-w64-mingw32-g++
CPP32 = g++ -std=c++11
INC_DIR = -I"C:/OCR/tesseract/tesseract/api" -I"C:/OCR/leptonica-1.74.1/src" \
          -I"C:/OCR/tesseract/tesseract/ccutil" -I"C:/OCR/tesseract/tesseract/ccstruct" \
          -I "C:/OCR/tesseract/tesseract/ccmain" -I"C:/OCR/leptonica-1.74.1/build/src"
LINK_DIR = -L"C:/OCR/tesseract/tesseract/build/bin/Debug" -L"C:/OCR/leptonica-1.74.1/build/bin/Debug"
LINK_LIB = -lleptonica-1.74.1d -ltesseract400d
OBJECTS = main.o 
EXECUTABLES = main.exe

all: $(EXECUTABLES)

main.exe: main.o
    $(CPP32) -o $@ $< $(LINK_DIR) $(LINK_LIB)   

main.o: 
    $(CPP32) $(INC_DIR) -c main.cpp

clean:
    rm $(EXECUTABLES) $(OBJECTS)

但由于未定义的引用,编译失败:

main.o:main.cpp:(.text+0x29): undefined reference to `tesseract::TessBaseAPI::Te ssBaseAPI()' main.o:main.cpp:(.text+0x91): undefined reference to `pixRead' main.o:main.cpp:(.text+0xa4): undefined reference to `tesseract::TessBaseAPI::Se tImage(Pix*)' main.o:main.cpp:(.text+0xb1): undefined reference to `tesseract::TessBaseAPI::Ge tUTF8Text()' main.o:main.cpp:(.text+0xd1): undefined reference to `tesseract::TessBaseAPI::En d()' main.o:main.cpp:(.text+0xed): undefined reference to `pixDestroy' 我查看了问题#377#582,但他们没有帮助。似乎leptonica和tesseract dll都没有正确连接(pixDestroy函数来自leptonica而其他人来自tesseract)

0 个答案:

没有答案