|
2 | 2 | RWINLIB = ../windows/tesseract |
3 | 3 | PKG_CPPFLAGS = -I${RWINLIB}/include -I${RWINLIB}/include/leptonica -fvisibility=hidden |
4 | 4 |
|
5 | | -# Exclude unwanted symbols from DLL using more aggressive approach |
| 5 | +# Basic library configuration |
6 | 6 | PKG_LIBS = -L${RWINLIB}/lib${subst gcc,,${COMPILED_BY}}${R_ARCH} \ |
7 | | - -L${RWINLIB}/lib \ |
8 | | - -Wl,--whole-archive \ |
9 | | - -ltesseract \ |
10 | | - -Wl,--no-whole-archive \ |
11 | | - -lleptonica \ |
12 | | - -ltiff -lopenjp2 -lwebp -lwebpmux -lwebpdemux -lsharpyuv -ljpeg -lgif -lpng16 -lz \ |
13 | | - -lws2_32 -lgdi32 \ |
14 | | - -Wl,--exclude-all-symbols \ |
15 | | - -static-libgcc -static-libstdc++ |
16 | | - |
17 | | -# For R 4.5.0 compatibility - using --version-script for symbol control |
| 7 | + -L${RWINLIB}/lib |
| 8 | + |
| 9 | +# R 4.5.0 requires special handling for symbol visibility |
18 | 10 | ifeq ($(shell ${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe -e 'cat(as.numeric(R.version$$major) + as.numeric(R.version$$minor)/10)'),4.5) |
19 | | - PKG_LIBS += -Wl,--version-script=../tools/exports.map |
| 11 | + # For R 4.5.0, use explicit DEF file and extra symbol hiding |
| 12 | + PKG_LIBS += -ltesseract -lleptonica -ltiff -lopenjp2 -lwebp -lwebpmux -lwebpdemux -lsharpyuv -ljpeg -lgif -lpng16 -lz \ |
| 13 | + -lws2_32 -lgdi32 -Wl,--exclude-all-symbols -static-libgcc -static-libstdc++ \ |
| 14 | + -Wl,--output-def,cpp11tesseract.def |
| 15 | +else |
| 16 | + # For earlier R versions, use the standard approach |
| 17 | + PKG_LIBS += -Wl,--whole-archive -ltesseract -Wl,--no-whole-archive \ |
| 18 | + -lleptonica -ltiff -lopenjp2 -lwebp -lwebpmux -lwebpdemux -lsharpyuv -ljpeg -lgif -lpng16 -lz \ |
| 19 | + -lws2_32 -lgdi32 -Wl,--exclude-all-symbols -static-libgcc -static-libstdc++ |
20 | 20 | endif |
21 | 21 |
|
22 | 22 | # Set C++11 standard as required by Tesseract |
23 | 23 | CXX_STD = CXX11 |
24 | 24 |
|
25 | 25 | # Compile |
26 | | -all: clean winlibs exports.map |
| 26 | +all: clean winlibs |
27 | 27 |
|
28 | 28 | clean: |
29 | | - rm -Rf $(OBJECTS) $(SHLIB) exports.map cpp11tesseract.def |
30 | | - |
31 | | -exports.map: clean |
32 | | - @echo "{ global: R_init_cpp11tesseract; local: *; };" > ../tools/exports.map |
| 29 | + rm -f $(OBJECTS) $(SHLIB) cpp11tesseract.def cpp11tesseract.exp |
33 | 30 |
|
34 | 31 | winlibs: |
35 | 32 | mkdir -p ../inst |
36 | 33 | "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" ${VERSION} |
37 | 34 | cp -Rf ../windows/tessdata ../inst/ || true |
38 | 35 | cp -Rf ${RWINLIB}/share/tessdata ../inst/ || true |
39 | 36 |
|
40 | | -$(SHLIB): $(OBJECTS) |
| 37 | +# Special handling for R 4.5.0 |
| 38 | +$(SHLIB): $(OBJECTS) exports.def |
| 39 | + |
| 40 | +exports.def: |
| 41 | + @echo EXPORTS > exports.def |
| 42 | + @echo R_init_cpp11tesseract >> exports.def |
41 | 43 |
|
42 | 44 | .PHONY: all winlibs clean |
| 45 | + |
0 commit comments