I have just started learning swift and I am trying to use GLFW but am unable to link it
I am running
swift build -Xswiftc -IC:\glfw-338\include -Xlinker -LC:\glfw-338\lib-vc2022
and I get a bunch of undefined symbol errors. Some of these symbols seem to be private and are not in the header.
lld-link: error: undefined symbol: __declspec(dllimport) ShowWindow
>>> referenced by glfw3.lib(win32_init.obj):($LN42)
>>> referenced by glfw3.lib(win32_window.obj):($LN39)
>>> referenced by glfw3.lib(win32_window.obj):($LN39)
>>> referenced 6 more times
lld-link: error: undefined symbol: __declspec(dllimport) ToUnicode
>>> referenced by glfw3.lib(win32_init.obj):($LN16)
>>> referenced by glfw3.lib(win32_init.obj):($LN16)
>>> referenced by glfw3.lib(win32_init.obj):($LN42)
>>> referenced 1 more times
I think it is linking to the lib instead of the dll or something like that. How do I fix this?
package.swift
import PackageDescription
let package = Package(
name: "example",
targets: [
.executableTarget(
name: "example",
dependencies: ["CGLFW"],
path: "Sources"
),
.systemLibrary(
name: "CGLFW",
path: "External/CGFLW"
)
]
)
module.modulemap
module CGLFW [system] {
header "shim.h"
link "glfw3"
export *
}
3 posts - 2 participants