Skip to content

Windows native-native-gnu can't find odbc32.lib #9124

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

Closed
mjoerussell opened this issue Jun 15, 2021 · 4 comments
Closed

Windows native-native-gnu can't find odbc32.lib #9124

mjoerussell opened this issue Jun 15, 2021 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Milestone

Comments

@mjoerussell
Copy link

Not sure if this is an issue with Zig or something else that Zig is depending on, but I've noticed some issues in 0.8/master regarding using and linking to odbc32.lib on Windows. I've also tested on macos with master and found no issues.

I've confirmed that none of the below issues are present on Zig 0.8.0-dev.2305+d228d8605.

  1. Importing C macro __MSABI_LONG(x) no longer works. I mentioned in the original issue Error when trying to import Windows SQL headers #9120 and was shown a fix that seems to work, but I'm still curious why it broke in the new release.
  2. The following C #define's are no longer present:
    • SQL_OV_ODBC3_80
    • SQL_CP_DRIVER_AWARE
    • SQL_PARAM_DATA_AVAILABLE
  3. The most pressing issue - I'm unable to link against odbc32.lib.

If I try to build a project which links against odbc32.lib in Zig version 0.9.0-dev.140+4173a2bc2, I get the following error:

error(link): DLL import library for -lodbc32 not found
error: DllImportLibraryNotFound
zdb...The following command exited with error code 1:
C:\Users\mjoer\Code\zig\build-release\bin\zig.exe build-exe C:\Users\mjoer\Code\zdb\src\main.zig -lc -lodbc32 --cache-dir C:\Users\mjoer\Code\zdb\zig-cache --global-cache-dir C:\Users\mjoer\AppData\Local\zig --name zdb --pkg-begin odbc C:\Users\mjoer\Code\zdb\zig-odbc\src\lib.zig --pkg-end --enable-cache
error: the following build command failed with exit code 1:
C:\Users\mjoer\Code\zdb\zig-cache\o\7d4fee359512fdc30a31bf8e390544fb\build.exe C:\Users\mjoer\Code\zig\build-release\bin\zig.exe C:\Users\mjoer\Code\zdb C:\Users\mjoer\Code\zdb\zig-cache C:\Users\mjoer\AppData\Local\zig 
run

The same code running on Zig 0.8.0-dev.2305+d228d8605 links with no issues, on the exact same Windows configuration.

@xackus
Copy link
Contributor

xackus commented Jun 15, 2021

This is probably why: #6565. Try setting the target to native-native-msvc.

@mjoerussell
Copy link
Author

I think I'm still missing something, once I specify that then the @cImport starts failing.

When I import this:

@cImport({
    @cDefine("__MSABI_LONG(x)", "(long)(x)");
    @cInclude("windows.h");
    @cInclude("sql.h");
    @cInclude("sqltypes.h");
    @cInclude("sqlext.h");
})

Then it can't seem to find the header files. Whichever one is listed first will be shown in the error message, so for example:

.\zig-odbc\src\c.zig:4:5: error: C import failed
    @cImport({
    ^
.\zig-cache\o\c7cfe15038263b66e244a7a456675868\cimport.h:2:10: note: 'windows.h' file not found
#include <windows.h>

@mjoerussell
Copy link
Author

Looks like this is the same issue as this: #9093

@mjoerussell mjoerussell changed the title odbc-related regressions in 0.8 Windows native-native-gnu can't find odbc32.lib Jul 1, 2021
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. os-windows bug Observed behavior contradicts documented or intended behavior and removed enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Jul 10, 2021
@andrewrk andrewrk added this to the 0.8.1 milestone Jul 10, 2021
andrewrk added a commit that referenced this issue Jul 10, 2021
@mjoerussell
Copy link
Author

Just tested on Windows native-native-gnu and this is working again. Closing this issue.

andrewrk added a commit that referenced this issue Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Projects
None yet
Development

No branches or pull requests

3 participants