Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tesseract] Link executable to libarchive to fix linker error #27307

Merged
merged 4 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ports/tesseract/fix-depend-libarchive.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd2649d..c1801a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -792,7 +792,8 @@ if(OpenCL_FOUND)
Expand All @@ -10,3 +12,12 @@
endif(LibArchive_FOUND)
if(CURL_FOUND)
if(NOT CURL_LIBRARIES)
@@ -854,7 +855,7 @@ endif()
# ##############################################################################

add_executable(tesseract src/tesseract.cpp)
-target_link_libraries(tesseract libtesseract)
+target_link_libraries(tesseract libtesseract LibArchive::LibArchive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is the correct fix instead of changing

target_link_libraries(libtesseract PRIVATE LibArchive::LibArchive)

to

target_link_libraries(libtesseract PUBLIC LibArchive::LibArchive)

?

That is is the expectation that:

  • Using tesseract implies using libarchive, so people who link with libtesseract should also link to libarchive, or
  • The tesseract exe just happens to also use libarchive and libtesseract's use of it is entirely internal.

(I'm genuinely asking because I don't know which of these is correct and want to make sure it's been considered, but that upstream didn't say this suggests that the former is expected)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my thinking is that my change is correct because the tesseract binary explicitly uses a libarchive function call (specifically archive_version_details). Adding it as a public dep to libtesseract to me would imply that any use of libtesseract would imply the need to link to libarchive, or that libarchive is included in some of libtesseract's headers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tesseract binary explicitly uses a libarchive function call

In that case I agree, thanks!

if(HAVE_TIFFIO_H AND WIN32)
target_link_libraries(tesseract ${TIFF_LIBRARIES})
endif()
2 changes: 1 addition & 1 deletion ports/tesseract/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tesseract",
"version": "5.2.0",
"port-version": 2,
"port-version": 3,
"description": "An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.",
"homepage": "https://github.com/tesseract-ocr/tesseract",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7278,7 +7278,7 @@
},
"tesseract": {
"baseline": "5.2.0",
"port-version": 2
"port-version": 3
},
"tfhe": {
"baseline": "1.0.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/tesseract.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "106efd2adc79ebdcf63488c2cc930b035f01535d",
"version": "5.2.0",
"port-version": 3
},
{
"git-tree": "9d9b7d5ba2e222ee4fb62d4d5f03992e9232a97d",
"version": "5.2.0",
Expand Down