Skip to content

Comments

Add bundled_proj_sqlite feature to support windows-msvc#245

Open
yutannihilation wants to merge 10 commits intogeorust:mainfrom
yutannihilation:feat/bundled-sqlite
Open

Add bundled_proj_sqlite feature to support windows-msvc#245
yutannihilation wants to merge 10 commits intogeorust:mainfrom
yutannihilation:feat/bundled-sqlite

Conversation

@yutannihilation
Copy link
Contributor

  • I agree to follow the project's code of conduct.
  • I added an entry to the project's change log file if knowledge of this change could be valuable to users.
    • Usually called CHANGES.md or CHANGELOG.md
    • Prefix changelog entries for breaking changes with "BREAKING: "

In order to make proj-sys work on Windows (more specifically, windows-msvc. I don't know well about windows-gnu), I found there are at least two options.

  1. Use vcpkg to install PROJ
  2. Bundle PROJ including SQLite

(I don't describe the details about first option, but here's what it looks like: MIERUNE/point-tiler#64)

For the second option, the proj crate and proj-sys crate already exposes bundled_proj, but I found it's not enough on Windows' case, where we usually doesn't have SQLite installed. So, this pull request adds a feature flag bundled_proj_sqlite to expose the libsqlite3-sys's bundled feature in order to bundle SQLite as well.

That's all of this pull request, but I have to explain about some tricky things:

  • PROJ uses the SQLite executable as well as the library (cf. https://proj.org/en/stable/install.html#build-requirements). So, even if we use bundled_proj_sqlite, we need to install SQLite on the GHA CI.
  • For some reason, cargo test requires some Windows system libraries, otherwise it fails with the following error. So, I added these in build.rs.
    = note: libproj_sys-119818f7f11b3538.rlib(filemanager.obj) : error LNK2019: unresolved external symbol __imp_CoTaskMemFree referenced in function proj_context_get_user_writable_directory␍
            libproj_sys-119818f7f11b3538.rlib(filemanager.obj) : error LNK2019: unresolved external symbol SHGetKnownFolderPath referenced in function proj_context_get_user_writable_directory␍
    
  • The proj::test::test_inverse_projection test reliably fails with STATUS_ACCESS_VIOLATION. I'm yet to figure out what this error is.

@yutannihilation
Copy link
Contributor Author

If I skip the test case, I still see STATUS_ACCESS_VIOLATION.

If I run the test case solely, it runs normally (and fails with a normal error).

❯ cargo test -- test_inverse_projection
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running unittests src\lib.rs (target\debug\deps\proj-e76bc29b00e44a55.exe)

running 1 test
test proj::test::test_inverse_projection ... FAILED

failures:

---- proj::test::test_inverse_projection stdout ----

thread 'proj::test::test_inverse_projection' (38996) panicked at src\proj.rs:1768:9:
assert_relative_eq!(t.y(), 0.8028510000110507)

    left  = 0.8028510000110513
    right = 0.8028510000110507


note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    proj::test::test_inverse_projection

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 25 filtered out; finished in 0.01s

error: test failed, to rerun pass `--lib`

@yutannihilation
Copy link
Contributor Author

It seems above was a real bug that affects all platforms, not only Windows.I pushed the fix, but I'm happy to create a separate pull request.

@urschrei
Copy link
Member

urschrei commented Feb 1, 2026

It seems above was a real bug that affects all platforms, not only Windows.I pushed the fix, but I'm happy to create a separate pull request.

I think pulling it out would be useful. It might be useful to combine it with the ASAN PR?

@yutannihilation
Copy link
Contributor Author

Thanks, I removed the commit from this pull request and pushed to #246

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.

2 participants