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

Building failed - lld: error: undefined symbol: __imp_TranslateMessage #3319

Closed
dawnarc opened this issue Sep 26, 2019 · 6 comments
Closed

Comments

@dawnarc
Copy link
Sponsor

dawnarc commented Sep 26, 2019

build.zig

const Builder = @import("std").build.Builder;

pub fn build(b: *Builder) void {
    const mode = b.standardReleaseOptions();
    const exe = b.addExecutable("glfw_test", "src/main.zig");
    exe.setBuildMode(mode);

    const run_cmd = exe.run();

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);

    b.default_step.dependOn(&exe.step);
    b.installArtifact(exe);

    exe.linkSystemLibrary("c");

    // glfw (local)
    exe.addIncludeDir("D:/sdk/OpenGL/glfw-3.3/include");
    exe.addLibPath("D:/sdk/OpenGL/glfw-3.3/src/Release");
    exe.linkSystemLibrary("glfw3");

    //vulkan
    exe.addIncludeDir("D:/sdk/VulkanSDK/1.1.121.2/Include");
    exe.addLibPath("D:/sdk/VulkanSDK/1.1.121.2/Lib");
    exe.linkSystemLibrary("vulkan-1");
}

main.zig

const std = @import("std");

const c = @cImport({
    @cInclude("vulkan/vulkan.h");
    @cInclude("GLFW/glfw3.h");
});

pub fn main() void {
    //std.debug.warn("Hello, world!\n");
    var ver_cstr = c.glfwGetVersionString();
    if (c.glfwInit() == c.GLFW_TRUE) {}
}

Command of building glfw3.3:

cmake -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF -G "Visual Studio 16 2019" -A x64
MSBuild GLFW.sln /p:Configuration=Release /p:Platform=x64

Output of zig build, I used the newest version of zig source master:

D:\workspace\zigdev\glfw_test>zig build
lld: error: undefined symbol: __imp_TranslateMessage
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)

lld: error: undefined symbol: __imp_DispatchMessageW
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)

lld: error: undefined symbol: __imp_PeekMessageW
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):($LN52)

lld: error: undefined symbol: __imp_RegisterDeviceNotificationW
>>> referenced by glfw3.lib(win32_init.obj):($LN40)

lld: error: undefined symbol: __imp_UnregisterDeviceNotification
>>> referenced by glfw3.lib(win32_init.obj):($LN17)

lld: error: undefined symbol: __imp_CreateWindowExW
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_DestroyWindow
>>> referenced by glfw3.lib(win32_init.obj):($LN17)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_ShowWindow
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_window.obj):($LN24)
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformIconifyWindow)
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformRestoreWindow)
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformMaximizeWindow)
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformShowWindow)
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformHideWindow)
>>> referenced by glfw3.lib(win32_window.obj):($LN40)

lld: error: undefined symbol: __imp_ToUnicode
>>> referenced by glfw3.lib(win32_init.obj):($LN16)
>>> referenced by glfw3.lib(win32_init.obj):($LN16)
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_init.obj):($LN40)

lld: error: undefined symbol: __imp_MapVirtualKeyW
>>> referenced by glfw3.lib(win32_init.obj):($LN16)
>>> referenced by glfw3.lib(win32_init.obj):($LN40)

lld: error: undefined symbol: __imp_SystemParametersInfoW
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_init.obj):($LN40)
>>> referenced by glfw3.lib(win32_init.obj):($LN17)
>>> referenced by glfw3.lib(win32_window.obj):(acquireMonitor)
>>> referenced by glfw3.lib(win32_window.obj):(acquireMonitor)
>>> referenced by glfw3.lib(win32_window.obj):(releaseMonitor)

lld: error: undefined symbol: __imp_CreateDCW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN7)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_DeleteDC
>>> referenced by glfw3.lib(win32_monitor.obj):($LN7)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_GetDeviceCaps
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN10)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN10)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_GetDeviceGammaRamp
>>> referenced by glfw3.lib(win32_monitor.obj):($LN7)

lld: error: undefined symbol: __imp_SetDeviceGammaRamp
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)

lld: error: undefined symbol: __imp_GetDC
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by glfw3.lib(wgl_context.obj):($LN13)
>>> referenced by glfw3.lib(wgl_context.obj):($LN61)

lld: error: undefined symbol: __imp_ReleaseDC
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_ChangeDisplaySettingsExW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN23)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN5)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN33)

lld: error: undefined symbol: __imp_EnumDisplaySettingsW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN33)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN33)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN4)
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_EnumDisplaySettingsExW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN6)

lld: error: undefined symbol: __imp_EnumDisplayDevicesW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN67)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN67)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN67)
>>> referenced by glfw3.lib(win32_monitor.obj):($LN67)

lld: error: undefined symbol: __imp_GetMonitorInfoW
>>> referenced by glfw3.lib(win32_monitor.obj):($LN8)
>>> referenced by glfw3.lib(win32_monitor.obj):(monitorCallback)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):(fitToMonitor)
>>> referenced by glfw3.lib(win32_window.obj):($LN111)

lld: error: undefined symbol: __imp_EnumDisplayMonitors
>>> referenced by glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_CreateBitmap
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_CreateRectRgn
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_DeleteObject
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_CreateDIBSection
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_TrackMouseEvent
>>> referenced by glfw3.lib(win32_window.obj):($LN137)

lld: error: undefined symbol: __imp_GetMessageTime
>>> referenced by glfw3.lib(win32_window.obj):($LN52)

lld: error: undefined symbol: __imp_SendMessageW
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_PostMessageW
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformPostEmptyEvent)

lld: error: undefined symbol: __imp_WaitMessage
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_DefWindowProcW
>>> referenced by glfw3.lib(win32_window.obj):(windowProc)
>>> referenced by glfw3.lib(win32_window.obj):($LN137)

lld: error: undefined symbol: __imp_UnregisterClassW
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_RegisterClassExW
>>> referenced by glfw3.lib(win32_window.obj):($LN6)

lld: error: undefined symbol: __imp_GetLayeredWindowAttributes
>>> referenced by glfw3.lib(win32_window.obj):($LN6)

lld: error: undefined symbol: __imp_SetLayeredWindowAttributes
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_FlashWindow
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformRequestWindowAttention)

lld: error: undefined symbol: __imp_MoveWindow
>>> referenced by glfw3.lib(win32_window.obj):($LN7)
>>> referenced by glfw3.lib(win32_window.obj):($LN7)

lld: error: undefined symbol: __imp_SetWindowPos
>>> referenced by glfw3.lib(win32_window.obj):($LN28)
>>> referenced by glfw3.lib(win32_window.obj):($LN31)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN4)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced by glfw3.lib(win32_window.obj):(fitToMonitor)
>>> referenced by glfw3.lib(win32_window.obj):($LN126)
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_IsWindowVisible
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformWindowVisible)

lld: error: undefined symbol: __imp_IsIconic
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformWindowIconified)

lld: error: undefined symbol: __imp_BringWindowToTop
>>> referenced by glfw3.lib(win32_window.obj):($LN24)
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_IsZoomed
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformWindowMaximized)

lld: error: undefined symbol: __imp_OpenClipboard
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN9)

lld: error: undefined symbol: __imp_CloseClipboard
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN9)
>>> referenced by glfw3.lib(win32_window.obj):($LN9)
>>> referenced by glfw3.lib(win32_window.obj):($LN9)

lld: error: undefined symbol: __imp_SetClipboardData
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_GetClipboardData
>>> referenced by glfw3.lib(win32_window.obj):($LN9)

lld: error: undefined symbol: __imp_EmptyClipboard
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_SetFocus
>>> referenced by glfw3.lib(win32_window.obj):($LN24)
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_GetActiveWindow
>>> referenced by glfw3.lib(win32_window.obj):($LN12)
>>> referenced by glfw3.lib(win32_window.obj):($LN4)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)

lld: error: undefined symbol: __imp_GetKeyState
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getKeyMods)

lld: error: undefined symbol: __imp_GetAsyncKeyState
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)
>>> referenced by glfw3.lib(win32_window.obj):(getAsyncKeyMods)

lld: error: undefined symbol: __imp_SetCapture
>>> referenced by glfw3.lib(win32_window.obj):($LN58)

lld: error: undefined symbol: __imp_ReleaseCapture
>>> referenced by glfw3.lib(win32_window.obj):($LN58)

lld: error: undefined symbol: __imp_MsgWaitForMultipleObjects
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_GetSystemMetrics
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_SetForegroundWindow
>>> referenced by glfw3.lib(win32_window.obj):($LN24)
>>> referenced by glfw3.lib(win32_window.obj):($LN4)

lld: error: undefined symbol: __imp_RedrawWindow
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_SetPropW
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_GetPropW
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):(windowProc)

lld: error: undefined symbol: __imp_RemovePropW
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_SetWindowTextW
>>> referenced by glfw3.lib(win32_window.obj):($LN5)

lld: error: undefined symbol: __imp_GetClientRect
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN8)
>>> referenced by glfw3.lib(win32_window.obj):($LN36)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):(updateClipRect)
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)

lld: error: undefined symbol: __imp_GetWindowRect
>>> referenced by glfw3.lib(win32_window.obj):($LN7)
>>> referenced by glfw3.lib(win32_window.obj):($LN7)

lld: error: undefined symbol: __imp_AdjustWindowRectEx
>>> referenced by glfw3.lib(win32_window.obj):($LN28)
>>> referenced by glfw3.lib(win32_window.obj):($LN31)
>>> referenced by glfw3.lib(win32_window.obj):($LN36)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):(applyAspectRatio)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced by glfw3.lib(win32_window.obj):($LN111)
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_SetCursorPos
>>> referenced by glfw3.lib(win32_window.obj):($LN4)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)

lld: error: undefined symbol: __imp_SetCursor
>>> referenced by glfw3.lib(win32_window.obj):($LN12)
>>> referenced by glfw3.lib(win32_window.obj):($LN12)
>>> referenced by glfw3.lib(win32_window.obj):($LN12)
>>> referenced by glfw3.lib(win32_window.obj):(updateCursorImage)
>>> referenced by glfw3.lib(win32_window.obj):(updateCursorImage)
>>> referenced by glfw3.lib(win32_window.obj):(updateCursorImage)
>>> referenced by glfw3.lib(win32_window.obj):(disableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)

lld: error: undefined symbol: __imp_GetCursorPos
>>> referenced by glfw3.lib(win32_window.obj):($LN7)
>>> referenced by glfw3.lib(win32_window.obj):(disableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)

lld: error: undefined symbol: __imp_ClientToScreen
>>> referenced by glfw3.lib(win32_window.obj):($LN4)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN33)
>>> referenced by glfw3.lib(win32_window.obj):(updateClipRect)
>>> referenced by glfw3.lib(win32_window.obj):(updateClipRect)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced 2 more times

lld: error: undefined symbol: __imp_ScreenToClient
>>> referenced by glfw3.lib(win32_window.obj):($LN7)
>>> referenced by glfw3.lib(win32_window.obj):(disableCursor)

lld: error: undefined symbol: __imp_WindowFromPoint
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)

lld: error: undefined symbol: __imp_ClipCursor
>>> referenced by glfw3.lib(win32_window.obj):(updateClipRect)

lld: error: undefined symbol: __imp_SetRect
>>> referenced by glfw3.lib(win32_window.obj):($LN36)

lld: error: undefined symbol: __imp_PtInRect
>>> referenced by glfw3.lib(win32_window.obj):(cursorInContentArea)

lld: error: undefined symbol: __imp_GetWindowLongW
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_SetWindowLongW
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN77)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):(updateWindowStyles)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)
>>> referenced by glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_GetClassLongPtrW
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_LoadCursorW
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN12)
>>> referenced by glfw3.lib(win32_window.obj):(updateCursorImage)
>>> referenced by glfw3.lib(win32_window.obj):(disableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)

lld: error: undefined symbol: __imp_DestroyIcon
>>> referenced by glfw3.lib(win32_window.obj):(_glfwPlatformDestroyCursor)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)
>>> referenced by glfw3.lib(win32_window.obj):($LN10)

lld: error: undefined symbol: __imp_LoadImageW
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN6)
>>> referenced by glfw3.lib(win32_window.obj):($LN17)

lld: error: undefined symbol: __imp_CreateIconIndirect
>>> referenced by glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_MonitorFromWindow
>>> referenced by glfw3.lib(win32_window.obj):($LN4)
>>> referenced by glfw3.lib(win32_window.obj):($LN111)
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_GetRawInputData
>>> referenced by glfw3.lib(win32_window.obj):($LN128)
>>> referenced by glfw3.lib(win32_window.obj):($LN128)

lld: error: undefined symbol: __imp_RegisterRawInputDevices
>>> referenced by glfw3.lib(win32_window.obj):($LN14)
>>> referenced by glfw3.lib(win32_window.obj):($LN14)
>>> referenced by glfw3.lib(win32_window.obj):(disableCursor)
>>> referenced by glfw3.lib(win32_window.obj):(enableCursor)

lld: error: undefined symbol: __imp_DragQueryFileW
>>> referenced by glfw3.lib(win32_window.obj):($LN130)
>>> referenced by glfw3.lib(win32_window.obj):($LN130)
>>> referenced by glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragQueryPoint
>>> referenced by glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragFinish
>>> referenced by glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragAcceptFiles
>>> referenced by glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_GetRawInputDeviceInfoA
>>> referenced by glfw3.lib(win32_joystick.obj):(deviceCallback)
>>> referenced by glfw3.lib(win32_joystick.obj):(deviceCallback)

lld: error: undefined symbol: __imp_GetRawInputDeviceList
>>> referenced by glfw3.lib(win32_joystick.obj):(deviceCallback)
>>> referenced by glfw3.lib(win32_joystick.obj):(deviceCallback)

lld: error: undefined symbol: __imp_ChoosePixelFormat
>>> referenced by glfw3.lib(wgl_context.obj):($LN13)

lld: error: undefined symbol: __imp_DescribePixelFormat
>>> referenced by glfw3.lib(wgl_context.obj):($LN61)
>>> referenced by glfw3.lib(wgl_context.obj):(choosePixelFormat)
>>> referenced by glfw3.lib(wgl_context.obj):(choosePixelFormat)

lld: error: undefined symbol: __imp_SetPixelFormat
>>> referenced by glfw3.lib(wgl_context.obj):($LN13)
>>> referenced by glfw3.lib(wgl_context.obj):($LN61)

lld: error: undefined symbol: __imp_SwapBuffers
>>> referenced by glfw3.lib(wgl_context.obj):(swapBuffersWGL)

The following command exited with error code 1:
D:\workspace\zigdev\zig\build-release\bin\zig.exe build-exe D:\workspace\zigdev\glfw_test\src\main.zig --library c --library glfw3 --library vulkan-1 --cache-dir D:\workspace\zigdev\glfw_test\zig-cache --name glfw_test -isystem D:\sdk\OpenGL\glfw-3.3\include -isystem D:\sdk\VulkanSDK\1.1.121.2\Include -L D:/sdk/OpenGL/glfw-3.3/src/Release -L D:/sdk/VulkanSDK/1.1.121.2/Lib --cache on

Build failed. The following command failed:
D:\workspace\zigdev\glfw_test\zig-cache\o\N2tBKyq4SRm1p02LrOfrC1uOkcmKedQzobyJ6o51ChAJ_ZGG5kBYj9Gac3aSlqhq\build.exe D:\workspace\zigdev\zig\build-release\bin\zig.exe D:\workspace\zigdev\glfw_test D:\workspace\zigdev\glfw_test\zig-cache

@andrewrk andrewrk added this to the 0.6.0 milestone Sep 26, 2019
@andrewrk
Copy link
Member

andrewrk commented Sep 26, 2019

It looks like what's happening here is that glfw is picking up zig's generated User32.lib file from the current working directory, when really we want it to be picking up User32.lib from your msvc installation.

I think this can be fixed with:

    exe.linkSystemLibrary("user32");

The reason this will help is that, combined with linkSystemLibrary("c"), Zig knows to look for "user32.lib" from msvc rather than try to generate its own .lib (for cross compiling purposes).

If that doesn't work, try removing all the *.lib files from the current working directory and try again.

Let me know what happens, I think we can probably figure out a way to make this "just work" or at least have better error reporting.

@dawnarc
Copy link
Sponsor Author

dawnarc commented Sep 27, 2019

When I add User32.lib in build.zig

exe.addLibPath("D:/Program_Filesx86/Windows Kits/10/Lib/10.0.18362.0/um/x64");
exe.linkSystemLibrary("User32");

there were new errors in output:

D:\workspace\zigdev\glfw_test>zig build
lld: error: undefined symbol: __report_rangecheckfailure
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:166
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1136
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_joystick.c:241
>>>               glfw3.lib(win32_joystick.obj):(supportsXInput)

lld: error: undefined symbol: strcpy
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:171
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:173
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:175
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:177
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:179
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:181
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:183
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:185
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:187
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:189
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced 3 more times

lld: error: undefined symbol: strlen
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:116
>>>               glfw3.lib(init.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:175
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:230
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\context.c:593
>>>               glfw3.lib(context.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\context.c:395
>>>               glfw3.lib(context.obj):($LN48)

lld: error: undefined symbol: calloc
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:199
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:117
>>>               glfw3.lib(init.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:187
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:736
>>>               glfw3.lib(input.obj):($LN6)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:766
>>>               glfw3.lib(input.obj):($LN6)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:432
>>>               glfw3.lib(input.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:433
>>>               glfw3.lib(input.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:434
>>>               glfw3.lib(input.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:400
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:428
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced 17 more times

lld: error: undefined symbol: free
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:82
>>>               glfw3.lib(init.obj):(terminate)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:86
>>>               glfw3.lib(init.obj):(terminate)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:99
>>>               glfw3.lib(init.obj):(terminate)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:469
>>>               glfw3.lib(window.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:811
>>>               glfw3.lib(input.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:449
>>>               glfw3.lib(input.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:450
>>>               glfw3.lib(input.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:451
>>>               glfw3.lib(input.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:452
>>>               glfw3.lib(input.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:406
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced 39 more times

lld: error: undefined symbol: __stdio_common_vsprintf
>>> referenced by D:\Program_Filesx86\Windows Kits\10\Include\10.0.18362.0\ucrt\stdio.h:1440
>>>               glfw3.lib(init.obj):($LN5)
>>> referenced by D:\Program_Filesx86\Windows Kits\10\Include\10.0.18362.0\ucrt\stdio.h:1390
>>>               glfw3.lib(win32_joystick.obj):($LN5)

lld: error: undefined symbol: _RTC_CheckStackVars
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:215
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:245
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1171
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:464
>>>               glfw3.lib(input.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:250
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:529
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:544
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:460
>>>               glfw3.lib(win32_init.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:514
>>>               glfw3.lib(win32_init.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:163
>>>               glfw3.lib(win32_init.obj):(loadLibraries)
>>> referenced 70 more times

lld: error: undefined symbol: _RTC_InitBase
>>> referenced by glfw3.lib(init.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(window.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(input.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(win32_init.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(win32_monitor.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(win32_time.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(win32_thread.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(monitor.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(vulkan.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced by glfw3.lib(context.obj):(_RTC_InitBase.rtc$IMZ)
>>> referenced 5 more times

lld: error: undefined symbol: _RTC_Shutdown
>>> referenced by glfw3.lib(init.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(window.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(input.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(win32_init.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(win32_monitor.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(win32_time.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(win32_thread.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(monitor.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(vulkan.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced by glfw3.lib(context.obj):(_RTC_Shutdown.rtc$TMZ)
>>> referenced 5 more times

lld: error: undefined symbol: __GSHandlerCheck
>>> referenced by glfw3.lib(init.obj):($unwind$_glfwInputError)
>>> referenced by glfw3.lib(window.obj):($unwind$glfwCreateWindow)
>>> referenced by glfw3.lib(input.obj):($unwind$glfwUpdateGamepadMappings)
>>> referenced by glfw3.lib(input.obj):($unwind$parseMapping)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$_glfwIsWindowsVersionOrGreaterWin32)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$_glfwIsWindows10BuildOrGreaterWin32)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$_glfwInputErrorWin32)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$_glfwUpdateKeyNamesWin32)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$loadLibraries)
>>> referenced by glfw3.lib(win32_init.obj):($unwind$createHelperWindow)
>>> referenced 39 more times

lld: error: undefined symbol: __security_check_cookie
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:215
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:245
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1171
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:250
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:529
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:544
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:460
>>>               glfw3.lib(win32_init.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:514
>>>               glfw3.lib(win32_init.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:163
>>>               glfw3.lib(win32_init.obj):(loadLibraries)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:378
>>>               glfw3.lib(win32_init.obj):(createHelperWindow)
>>> referenced 39 more times

lld: error: undefined symbol: __security_cookie
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\init.c:154
>>>               glfw3.lib(init.obj):($LN31)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:154
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1114
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:114
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:519
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:534
>>>               glfw3.lib(win32_init.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:444
>>>               glfw3.lib(win32_init.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:465
>>>               glfw3.lib(win32_init.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:68
>>>               glfw3.lib(win32_init.obj):(loadLibraries)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_init.c:333
>>>               glfw3.lib(win32_init.obj):(createHelperWindow)
>>> referenced 39 more times

lld: error: undefined symbol: strncpy
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:423
>>>               glfw3.lib(window.obj):($LN10)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:427
>>>               glfw3.lib(window.obj):($LN10)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:431
>>>               glfw3.lib(window.obj):($LN10)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:439
>>>               glfw3.lib(input.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_joystick.c:748
>>>               glfw3.lib(win32_joystick.obj):($LN4)

lld: error: undefined symbol: _wassert
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:416
>>>               glfw3.lib(window.obj):($LN10)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:160
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:161
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:162
>>>               glfw3.lib(window.obj):($LN18)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:475
>>>               glfw3.lib(window.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:484
>>>               glfw3.lib(window.obj):($LN5)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:493
>>>               glfw3.lib(window.obj):($LN6)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:494
>>>               glfw3.lib(window.obj):($LN6)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:504
>>>               glfw3.lib(window.obj):($LN7)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\window.c:505
>>>               glfw3.lib(window.obj):($LN7)
>>> referenced 186 more times

lld: error: undefined symbol: strcmp
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:52
>>>               glfw3.lib(input.obj):(findMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\vulkan.c:123
>>>               glfw3.lib(vulkan.obj):($LN17)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\vulkan.c:126
>>>               glfw3.lib(vulkan.obj):($LN17)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\context.c:716
>>>               glfw3.lib(context.obj):($LN16)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_joystick.c:745
>>>               glfw3.lib(win32_joystick.obj):($LN4)

lld: error: undefined symbol: strcspn
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1130
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1158
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:147
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:157
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:238
>>>               glfw3.lib(input.obj):(parseMapping)

lld: error: undefined symbol: strncmp
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:176
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:231
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\context.c:397
>>>               glfw3.lib(context.obj):($LN48)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\egl_context.c:336
>>>               glfw3.lib(egl_context.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\egl_context.c:677
>>>               glfw3.lib(egl_context.obj):($LN63)

lld: error: undefined symbol: strspn
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1159
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:239
>>>               glfw3.lib(input.obj):(parseMapping)

lld: error: undefined symbol: realloc
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:1146
>>>               glfw3.lib(input.obj):($LN22)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:440
>>>               glfw3.lib(win32_monitor.obj):($LN17)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:96
>>>               glfw3.lib(monitor.obj):($LN18)

lld: error: undefined symbol: strtoul
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:209
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:210
>>>               glfw3.lib(input.obj):(parseMapping)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\input.c:214
>>>               glfw3.lib(input.obj):(parseMapping)

lld: error: undefined symbol: wcscmp
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:180
>>>               glfw3.lib(win32_monitor.obj):($LN32)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:210
>>>               glfw3.lib(win32_monitor.obj):($LN32)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:50
>>>               glfw3.lib(win32_monitor.obj):(monitorCallback)

lld: error: undefined symbol: wcscpy
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:101
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:110
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: qsort
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:75
>>>               glfw3.lib(monitor.obj):(refreshVideoModes)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_joystick.c:433
>>>               glfw3.lib(win32_joystick.obj):(deviceCallback)

lld: error: undefined symbol: abs
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:233
>>>               glfw3.lib(monitor.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:235
>>>               glfw3.lib(monitor.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:237
>>>               glfw3.lib(monitor.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:239
>>>               glfw3.lib(monitor.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:245
>>>               glfw3.lib(monitor.obj):($LN15)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:87
>>>               glfw3.lib(win32_window.obj):(chooseImage)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:331
>>>               glfw3.lib(wgl_context.obj):(swapBuffersWGL)

lld: error: undefined symbol: powf
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\monitor.c:480
>>>               glfw3.lib(monitor.obj):($LN13)

lld: error: undefined symbol: strstr
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\context.c:589
>>>               glfw3.lib(context.obj):($LN11)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_joystick.c:242
>>>               glfw3.lib(win32_joystick.obj):(supportsXInput)

lld: error: undefined symbol: __stdio_common_vsscanf
>>> referenced by D:\Program_Filesx86\Windows Kits\10\Include\10.0.18362.0\ucrt\stdio.h:2176
>>>               glfw3.lib(context.obj):($LN3)

The following command exited with error code 1:
D:\workspace\zigdev\zig\build-release\bin\zig.exe build-exe D:\workspace\zigdev\glfw_test\src\main.zig --library User32 --library kernel32 --library user32 --library gdi32 --library winspool --library shell32 --library ole32 --library oleaut32 --library uuid --library comdlg32 --library advapi32 --library glfw3 --library vulkan-1 --cache-dir D:\workspace\zigdev\glfw_test\zig-cache --name glfw_test -isystem D:\sdk\OpenGL\glfw-3.3\include -isystem D:\sdk\VulkanSDK\1.1.121.2\Include -L D:/Program_Filesx86/Windows Kits/10/Lib/10.0.18362.0/um/x64 -L D:/sdk/OpenGL/glfw-3.3/src/Release -L D:/sdk/VulkanSDK/1.1.121.2/Lib --cache on

Build failed. The following command failed:
D:\workspace\zigdev\glfw_test\zig-cache\o\WHLIlzyCdaMw4BRzZh__WsNxxwNvKGqsO8qSKcWOzlTX_7oqU54DzvE4H-WTlmoR\build.exe D:\workspace\zigdev\zig\build-release\bin\zig.exe D:\workspace\zigdev\glfw_test D:\workspace\zigdev\glfw_test\zig-cache

@andrewrk
Copy link
Member

You shouldn't need the

exe.addLibPath("D:/Program_Filesx86/Windows Kits/10/Lib/10.0.18362.0/um/x64");

when you do linkSystemLibrary("c") zig adds this dir automatically. (The path above has a typo anyway).

A bunch of these, such as strcmp come from libc. Since you have linkSystemLibrary("c") in there, I'm confused by this. Can you add --verbose-link to your zig build line and show the output?

@dawnarc
Copy link
Sponsor Author

dawnarc commented Sep 27, 2019

build.zig

exe.linkSystemLibrary("c");
//exe.addLibPath("D:/Program_Filesx86/Windows Kits/10/Lib/10.0.18362.0/um/x64");
exe.linkSystemLibrary("User32");

Output:

D:\workspace\zigdev\glfw_test>zig build --verbose-link
lld -ERRORLIMIT:0 -NOLOGO -DEBUG -STACK:16777216 -MACHINE:X64 -OUT:D:\workspace\zigdev\glfw_test\zig-cache\o\lFSQqkLI4CoRVA4GtNJPWFYOGUahms5HVJCglFwrFSMvAdD8-PtoOyFyjyt1e3y7\glfw_test.exe -LIBPATH:D:\Program_Filesx86\Windows Kits\10\\Lib\10.0.18362.0\ucrt\x64\ -LIBPATH:D:\Program_Filesx86\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.23.28105\lib\x64\ -LIBPATH:D:\Program_Filesx86\Windows Kits\10\\Lib\10.0.18362.0\um\x64\ -LIBPATH:D:/sdk/OpenGL/glfw-3.3/src/Release -LIBPATH:D:/sdk/VulkanSDK/1.1.121.2/Lib D:\workspace\zigdev\glfw_test\zig-cache\o\lFSQqkLI4CoRVA4GtNJPWFYOGUahms5HVJCglFwrFSMvAdD8-PtoOyFyjyt1e3y7\glfw_test.obj -SUBSYSTEM:console libcmtd.lib libvcruntimed.lib libucrtd.lib legacy_stdio_definitions.lib kernel32.lib ntdll.lib C:\Users\Neil\AppData\Local\zig\stage1\o\WPFuu1YRt7AXgHgzUXS0wra8QL7bqJ3non68wsEeGZherWOo9Ppb0QdImo_gEWag\compiler_rt.lib User32.lib glfw3.lib vulkan-1.lib kernel32.lib NtDll.lib
lld: error: undefined symbol: __imp_CreateDCW
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:480
>>>               glfw3.lib(win32_monitor.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:509
>>>               glfw3.lib(win32_monitor.obj):($LN4)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:80
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_DeleteDC
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:482
>>>               glfw3.lib(win32_monitor.obj):($LN3)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:511
>>>               glfw3.lib(win32_monitor.obj):($LN4)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:93
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_GetDeviceCaps
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:321
>>>               glfw3.lib(win32_monitor.obj):($LN7)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:322
>>>               glfw3.lib(win32_monitor.obj):($LN7)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:84
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:85
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:89
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:90
>>>               glfw3.lib(win32_monitor.obj):(createMonitor)

lld: error: undefined symbol: __imp_GetDeviceGammaRamp
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:481
>>>               glfw3.lib(win32_monitor.obj):($LN3)

lld: error: undefined symbol: __imp_SetDeviceGammaRamp
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_monitor.c:510
>>>               glfw3.lib(win32_monitor.obj):($LN4)

lld: error: undefined symbol: __imp_CreateBitmap
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:141
>>>               glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_CreateRectRgn
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:387
>>>               glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_DeleteObject
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:146
>>>               glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:169
>>>               glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:170
>>>               glfw3.lib(win32_window.obj):(createIcon)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:415
>>>               glfw3.lib(win32_window.obj):(updateFramebufferTransparency)

lld: error: undefined symbol: __imp_CreateDIBSection
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:126
>>>               glfw3.lib(win32_window.obj):(createIcon)

lld: error: undefined symbol: __imp_DragQueryFileW
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1168
>>>               glfw3.lib(win32_window.obj):($LN130)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1177
>>>               glfw3.lib(win32_window.obj):($LN130)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1180
>>>               glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragQueryPoint
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1172
>>>               glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragFinish
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1192
>>>               glfw3.lib(win32_window.obj):($LN130)

lld: error: undefined symbol: __imp_DragAcceptFiles
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\win32_window.c:1307
>>>               glfw3.lib(win32_window.obj):(createNativeWindow)

lld: error: undefined symbol: __imp_ChoosePixelFormat
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:454
>>>               glfw3.lib(wgl_context.obj):($LN8)

lld: error: undefined symbol: __imp_DescribePixelFormat
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:567
>>>               glfw3.lib(wgl_context.obj):($LN65)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:125
>>>               glfw3.lib(wgl_context.obj):(choosePixelFormat)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:213
>>>               glfw3.lib(wgl_context.obj):(choosePixelFormat)

lld: error: undefined symbol: __imp_SetPixelFormat
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:454
>>>               glfw3.lib(wgl_context.obj):($LN8)
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:575
>>>               glfw3.lib(wgl_context.obj):($LN65)

lld: error: undefined symbol: __imp_SwapBuffers
>>> referenced by D:\sdk\OpenGL\glfw-3.3\src\wgl_context.c:338
>>>               glfw3.lib(wgl_context.obj):(swapBuffersWGL)

The following command exited with error code 1:
D:\workspace\zigdev\zig\build-release\bin\zig.exe build-exe D:\workspace\zigdev\glfw_test\src\main.zig --library c --library User32 --library glfw3 --library vulkan-1 --verbose-link --cache-dir D:\workspace\zigdev\glfw_test\zig-cache --name glfw_test -isystem D:\sdk\OpenGL\glfw-3.3\include -isystem D:\sdk\VulkanSDK\1.1.121.2\Include -L D:/sdk/OpenGL/glfw-3.3/src/Release -L D:/sdk/VulkanSDK/1.1.121.2/Lib --cache on

Build failed. The following command failed:
D:\workspace\zigdev\glfw_test\zig-cache\o\cOdR6s4Fc6lRU6afSyFyd_Fgoy68PxLRvrHFOWPHCkkYkmDWPb5lbzH_s1IqmbNc\build.exe D:\workspace\zigdev\zig\build-release\bin\zig.exe D:\workspace\zigdev\glfw_test D:\workspace\zigdev\glfw_test\zig-cache --verbose-link

@andrewrk
Copy link
Member

Looks like progress.

When you see undefined symbol: __imp_CreateDCW the trick is to look up what DLL that is in. A duck duck go search lands us at https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdcw which says at the bottom it is in Gdi32.dll. So you need addSystemLibrary("Gdi32").

@dawnarc
Copy link
Sponsor Author

dawnarc commented Sep 27, 2019

It worked fine when using following libraries. Thanks very much andrewrk! have a nice day~

exe.linkSystemLibrary("c");
exe.linkSystemLibrary("User32");
exe.linkSystemLibrary("Gdi32");
exe.linkSystemLibrary("shell32");

@dawnarc dawnarc closed this as completed Sep 27, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.5.0 Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants