trufanov-nok / scantailor-universal

ScanTailor Universal - a fork based on Enhanced+Featured+Master versions of ST
http://scantailor.org
Other
181 stars 16 forks source link

Restoring macOS builds #80

Closed joewiz closed 3 years ago

joewiz commented 3 years ago

@trufanov-nok Thank you so much for keeping this fantastic utility, ScanTailor, alive! I have been using your scantailor-universal v0.2.8 since its release last year. It still works for me and was a lifesaver just today.

I noticed that recent releases haven't included builds for macOS, and that the section of the wiki article on building ScanTailor for macOS is labeled "outdated".

I thought I would try to create a build of the current master branch for macOS if possible, and I made some progress, but I encountered a couple of roadblocks in adapting it to my environment: macOS 11.2.3 (Big Sur) + Homebrew (as opposed to MacPorts).

As to prerequisites, I installed:

As to configuration, I cloned the current master branch of the repository, and from the cloned directory, I ran the following build command:

cmake -DCMAKE_LIBRARY_PATH=/usr/local/Cellar/qt@5/5.15.2/lib -DCMAKE_INCLUDE_PATH=/usr/local/Cellar/qt@5/5.15.2/include -DQT_QMAKE_EXECUTABLE=/usr/local/Cellar/qt@5/5.15.2/bin/qmake -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt@5/5.15.2/lib/cmake .

This yielded a number of "CMake Warning (dev)" messages and ultimately this error:

-- Configuring done
CMake Error: Target scantailor-universal Info.plist template "/Users/joe/workspace/scantailor-universal/src/app/src/packaging/osx/Info.plist.in" could not be found.
-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Indeed, I don't see the Info.plist.in file at the path shown in the error message:

/Users/joe/workspace/scantailor-universal/src/app/src/packaging/osx/Info.plist.in

... but I do see one inside:

/Users/joe/workspace/scantailor-universal/src/packaging/osx/Info.plist.in

Is anyone successfully building ScanTailor on macOS, or does anyone have ideas for what to try? Thanks in advance!

joewiz commented 3 years ago

I just found a tap for qt4 at https://github.com/cartr/homebrew-qt4, so if qt4 is recommended, I could try this... But the error listed above doesn't directly point to the version of qt being a problem.

joewiz commented 3 years ago

p.s. Here's the full results of the cmake command, with the dev warnings suppressed:

% cmake -Wno-dev -DCMAKE_LIBRARY_PATH=/usr/local/Cellar/qt@5/5.15.2/lib -DCMAKE_INCLUDE_PATH=/usr/local/Cellar/qt@5/5.15.2/include -DQT_QMAKE_EXECUTABLE=/usr/local/Cellar/qt@5/5.15.2/bin/qmake -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt@5/5.15.2/lib/cmake .
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
-- Checking pthreads with CFLAGS="" and LIBS="" -- yes
-- Configuring done
CMake Error: Target scantailor-universal Info.plist template "/Users/joe/workspace/scantailor-universal/src/app/src/packaging/osx/Info.plist.in" could not be found.
-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
trufanov-nok commented 3 years ago

Hi Joe ! It would be great to revive Mac Os distribution. I have no Mac, but long time ago I managed to build the sources on some old Mac Os image in ViryalBox. I think I still have this image. But it looks like build process for Mac is broken again. I should take a look into the sources in a next couple of days to fix paths for Mac.

As for instructions - they are very outdated. In fact Scan Tailor Universal migrated to Qt5 long time ago and can't be build with Qt4 anymore. So you may not try to build it with Qt4 - this is impossible. Qt 5.15 is fine.

joewiz commented 3 years ago

That's great to hear, thank you, Alexander! I would be happy to perform any tests or provide any information that would help!

trufanov-nok commented 3 years ago

Great. I hope to finish Windows builds today (latest version deploys with libraries for jpeg2000, SVG icons support and couple example stylesheet files, so I have just refreshed my knowledge of buildscripts and how deeply I hate Windows OS) and will take a look on Mac just after that.

trufanov-nok commented 3 years ago

Hi, Ok, I was able to build the project on Mac OS 10.9 with Qt 5.8 The dmg image is uploaded to release: https://github.com/trufanov-nok/scantailor-universal/releases/tag/0.2.12 Pls let me know if it's working.

I'll submit the adjustments made to build the sources and fresh build instructions shortly.

One thing is worring me for now. I've STU on Mac wasn't able to open jp2 image (jpeg2000 extension) while openjp2 library is deployed and loaded properly. And it works well on Win and Linux. On the other side Mac OS 10.9 wasn't able to display such image in default image viewer. Could you please test if jp2 images can be opened with STU on your system? Probably me MacOS image is too old.

Just find some jp2 images, download them in some folder and try to create a new project, choosing this folder. I've tested with the image from this site: https://www.fnordware.com/j2k/jp2samples.html Direct link: https://www.fnordware.com/j2k/relax.jp2

Another problem is that it looks like clang compiler in MacOS 10.9 lacks OpenMP support and binary I generate won't be able to use some operations in parallel. But for STU 0.2.x it's not critical as only few operations are paralleled. That might become a problem for 0.3.x but looks like there is some magic that allows to get newer clang compiler for 10.9 machine. Will try it one day. So for now lack of OpenMP support is a know issue.

joewiz commented 3 years ago

@trufanov-nok That's amazing! I downloaded v0.2.12 and tested with the jp2 image you suggested. When I added the folder containing the jp2 file, I got this error:

Screen Shot 2021-04-26 at 8 44 12 AM

Other than this, in brief testing with a project using the previous release, everything appears to be working well.

Thank you so much, Alexander!

Is there anything else you'd like me to test? I'm on the current macOS, 11.2.3.

trufanov-nok commented 3 years ago

I've replaced the dmg file with a new one. Now jp2 image opening should be fixed. Could you confirm?

joewiz commented 3 years ago

@trufanov-nok The build in the updated dmg file no longer throws an error when creating a new project with a folder containing the test jp2 image you suggested. But it presents me with a "Needs fixes" dialog, and I'm not sure why. Here's the progression of dialogs:

1. Selecting the folder containing the test jp2 image

Screen Shot 2021-04-26 at 1 05 02 PM

2. The Needs Fixes dialog

(Note that the "Needs Fixes" title is obscured by what I guess is a QT rendering bug.)

Screen Shot 2021-04-26 at 1 05 11 PM

3. The Needs Fixes dialog expanded

Screen Shot 2021-04-26 at 1 05 25 PM

4. The Needs Fixes dialog, with my guessed values, and the Apply button now enabled

Screen Shot 2021-04-26 at 1 05 43 PM

5. The resulting project

Screen Shot 2021-04-26 at 1 05 57 PM

Is this the info you were hoping for? Should I try any other tests or provide any other info?

trufanov-nok commented 3 years ago

Well everything as expected except for the last picture. I have the same artifacts in my virtual macos image. Seems something is wrong with openjpeg lib or my integration of it on macos, bcs on Win and Linux there is no such artifacts. I'll ignore this problem for now as noone asked me for jp2 files support on any platform except Linux anyway.

joewiz commented 3 years ago

Sounds good! I think the macOS builds are now working, then!

trufanov-nok commented 3 years ago

Ok, I've posted a brief notes on building current sources for MAC as a separate discussion: https://github.com/trufanov-nok/scantailor-universal/discussions/81 I'm closing this issue.