Skip to content

Commit 7db5d13

Browse files
committed
try workaround for R 4.5.0 Windows
1 parent 56a6fec commit 7db5d13

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/Makevars.win

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,44 @@
22
RWINLIB = ../windows/tesseract
33
PKG_CPPFLAGS = -I${RWINLIB}/include -I${RWINLIB}/include/leptonica -fvisibility=hidden
44

5-
# Exclude unwanted symbols from DLL using more aggressive approach
5+
# Basic library configuration
66
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
1810
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++
2020
endif
2121

2222
# Set C++11 standard as required by Tesseract
2323
CXX_STD = CXX11
2424

2525
# Compile
26-
all: clean winlibs exports.map
26+
all: clean winlibs
2727

2828
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
3330

3431
winlibs:
3532
mkdir -p ../inst
3633
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" ${VERSION}
3734
cp -Rf ../windows/tessdata ../inst/ || true
3835
cp -Rf ${RWINLIB}/share/tessdata ../inst/ || true
3936

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
4143

4244
.PHONY: all winlibs clean
45+

0 commit comments

Comments
 (0)