Sicos1977 / TesseractOCR

A .net library to work with Google's Tesseract
169 stars 22 forks source link

Failed to find library 'leptonica-1.83.0.dll' for platform ×86 on Framework 4.8 #38

Closed benquan closed 1 year ago

benquan commented 1 year ago

Reltated to https://github.com/Sicos1977/TesseractOCR/issues/6

Creating a clean Console Project using:

It is a barebones console project, just using the sample code, also manually added tessdata for english.

var engine = new Engine(@"./tessdata", Language.English, EngineMode.Default); var img = TesseractOCR.Pix.Image.LoadFromFile("c:\\test.jpg");
 var page = engine.Process(img);
Console.WriteLine("Mean confidence: {0}", page.MeanConfidence);
Console.WriteLine("Text: \r\n{0}", page.Text);

Console.ReadKey();

When run through the debugger, the project runs fine. But if I try to package the project and install it in a new Win11 computer, It gives the error:

Unhandled Exception: System. Reflection. TargetInvocationException: Exception has ben thrown by the target of an invocat:
- - - > System .DLL NotFoundExcention. Failed to find library 'leptonica-1.83.0.dll' for platform ×86

The workaround is to manually add a x86 directory with the bundled leptonica-1.83.0.dll. But this is a workaround, why is it not included in the deployed package?

Edit: I tried same sample project on .NET 7 and the folders get created by the Nuget package, so this problem only applies to Framework Projects.

Sicos1977 commented 1 year ago

I have no idea, the library is in the package. I also use it in a .NET 4.8 project and the leptonica dll gets deployed without any problems.

Everything seems to be in the package.

image