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

Add missing defines for PCRE2 (on Windows) #2168

Closed
wants to merge 1 commit into from

Conversation

geographika
Copy link
Contributor

Following the updates in #2138 I've been testing the CMake install steps on Windows.

When trying to build (with static linking to the PCRE2 library so not requiring a pcre.dll to be on the system path), I was getting the following errors:

misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_config_8 referenced in function Swig_pcre_version [C:\
swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_compile_8 referenced in function Swig_string_regex [C:
\swig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_compile_8 [C:\swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_code_free_8 referenced in function Swig_string_regex [
C:\swig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_code_free_8 [C:\swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_match_data_create_from_pattern_8 referenced in functio
n Swig_string_regex [C:\swig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_match_data_create_from_pattern_8 [C:\swig\build\swig
.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_match_8 referenced in function Swig_string_regex [C:\s
wig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_match_8 [C:\swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_match_data_free_8 referenced in function Swig_string_r
egex [C:\swig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_match_data_free_8 [C:\swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_get_ovector_pointer_8 referenced in function Swig_stri
ng_regex [C:\swig\build\swig.vcxproj]
misc.obj : error LNK2019: unresolved external symbol __imp_pcre2_get_error_message_8 referenced in function Swig_string
_regex [C:\swig\build\swig.vcxproj]
naming.obj : error LNK2001: unresolved external symbol __imp_pcre2_get_error_message_8 [C:\swig\build\swig.vcxproj]
C:\swig\build\Release\swig.exe : fatal error LNK1120: 8 unresolved externals [C:\swig\build\swig.vcxproj]

This was resolved by adding in the defines in this pull request as noted at https://stackoverflow.com/a/67233379/179520

@wsfulton
Copy link
Member

This forces all users to statically link to PCRE2, so another way needs to be found. I think you want to use -DCMAKE_C_FLAGS="/WX /DPCRE_STATIC" -DCMAKE_CXX_FLAGS="/WX /DPCRE2_STATIC" as is done in our CI testing:

- if "%BUILDSYSTEM%"=="cmake" cmake --version && cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/WX /DPCRE_STATIC" -DCMAKE_CXX_FLAGS="/WX /DPCRE2_STATIC" -DPCRE2_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE2_LIBRARY=%PCRE_ROOT%/lib/pcre2-8-static.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit

It's also shown in the docs in Windows.html. Maybe the docs should be clearer about this or the CMakeLists.txt file should offer some easier to understand option to use? ping @jschueller

@geographika
Copy link
Contributor Author

@wsfulton - ah ok thanks. The Windows docs were missing the C++ flag -DCMAKE_CXX_FLAGS="/DPCRE2_STATIC". Adding that in and the builds are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants