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

gdal can not build with odbc on window #26210

Open
liyq0307 opened this issue Dec 17, 2024 · 5 comments
Open

gdal can not build with odbc on window #26210

liyq0307 opened this issue Dec 17, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@liyq0307
Copy link

What is your question?

gdal can not build with odbc on window,What should I do?

@liyq0307 liyq0307 added the question Further information is requested label Dec 17, 2024
@jcar87
Copy link
Contributor

jcar87 commented Dec 17, 2024

Hi @liyq0307 - which conan command are you running, on which platform/versions (see the issue template), and what is the output? Thanks!

@jcar87 jcar87 added the requires reporter action Waiting on issue reporter label Dec 17, 2024
@liyq0307
Copy link
Author

Hi @liyq0307 - which conan command are you running, on which platform/versions (see the issue template), and what is the output? Thanks!

When I compile the gdal library with the command "conan create . gdal/3.8.3@ -s compiler="Visual Studio" -s build_type=Release -s arch=x86_64 -s compiler.version=17", if "with_odbc": True is set, the error : "here are invalid packages (packages that cannot exist for this configuration):odbc/2.3.11: Invalid ID: odbc is a system lib on Windows will be thrown"; if "with_odbc": True is set and self.requires("odbc/2.3.11") is commented out:" CMake Error at src/cmake/helpers/CheckDependentLibraries.cmake:201 (message):Configured to use ODBC", but not found, what should I do in Windows?

@jcar87 jcar87 removed the requires reporter action Waiting on issue reporter label Dec 20, 2024
@SpaceIm
Copy link
Contributor

SpaceIm commented Dec 20, 2024

Indeed, it's an issue of gdal >= 3.5.0 recipe, it doesn't properly handle odbc on Windows. When host OS is Windows, it doesn't make sense to depend on odbc recipe (which is actually unixodbc), odbc library is a system library on Windows.

It can be fixed by using the same logic as gdal < 3.5.0 recipe:

if self.options.with_odbc and self.settings.os != "Windows":
self.requires("odbc/2.3.11")

elif self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["psapi", "ws2_32"])
if is_msvc(self):
self.cpp_info.system_libs.append("wbemuuid")
if self.options.with_odbc and not self.options.shared:
self.cpp_info.system_libs.extend(["odbc32", "odbccp32"])
if is_msvc(self):
self.cpp_info.system_libs.append("legacy_stdio_definitions")

@liyq0307
Copy link
Author

Indeed, it's an issue of gdal >= 3.5.0 recipe, it doesn't properly handle odbc on Windows. When host OS is Windows, it doesn't make sense to depend on odbc recipe (which is actually unixodbc), odbc library is a system library on Windows.

It can be fixed by using the same logic as gdal < 3.5.0 recipe:

if self.options.with_odbc and self.settings.os != "Windows":
self.requires("odbc/2.3.11")

elif self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["psapi", "ws2_32"])
if is_msvc(self):
self.cpp_info.system_libs.append("wbemuuid")
if self.options.with_odbc and not self.options.shared:
self.cpp_info.system_libs.extend(["odbc32", "odbccp32"])
if is_msvc(self):
self.cpp_info.system_libs.append("legacy_stdio_definitions")

Thanks for your reply!
I followed your method and used gdal < 3.5.0 to fix the script, but when setting with_odbc=True, the following error is still thrown:
-- Found ODBC: 0
-- ODBC_TARGET:
-- ODBC_LIBRARIES:
-- ODBC_INCLUDE_DIRS:
CMake Error at src/cmake/helpers/CheckDependentLibraries.cmake:201 (message):
Configured to use ODBC, but not found
Call Stack (most recent call first):
src/cmake/helpers/CheckDependentLibraries.cmake:274 (gdal_check_package)
src/gdal.cmake:265 (include)
src/CMakeLists.txt:264 (include)

@SpaceIm
Copy link
Contributor

SpaceIm commented Dec 23, 2024

I think patches in this recipe prevent to find system odbc on windows (injection of this cmake file specifically https://github.com/conan-io/conan-center-index/blob/master/recipes/gdal/post_3.5.0/cmake/ConanFindPackage.cmake).
I don't have the time to dig into this, you can try to ping maintainers of gdal >= 3.5.0 recipe.

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

No branches or pull requests

5 participants