我正在Windows上写一个OpenGL程序。
我想链接预编译的GLEW32.lib,但是失败了,失败了几个小时。
在WORKSPACE中,http_archive使用下载GLEW32.lib
http_archive(
name = "glew",
build_file = "@//:thirdparty/glew.BUILD",
sha256 = "ea6b14a1c6c968d0034e61ff6cb242cff2ce0ede79267a0f2b47b1b0b652c164",
strip_prefix = "glew-2.2.0",
urls = ["https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0-win32.zip"],
)
GLEW.构建如下
package(default_visibility=["//visibility:public"])
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_import(
name = "glew_lib",
static_library = "lib/Release/x64/glew32s.lib",
hdrs = glob([
"include/GL/*.h"
]),
)
cc_library(
name = "glew"
includes = ["include"],
deps = ["glew_lib"]
)
依赖二进制如下
cc_binary(
name = "window",
srcs = [
"window.cc",
],
deps = [
"//engine:debug",
"//engine:gl",
"//playground:playground",
"@fmt",
"@glew",
"@glfw",
"@glm",
"@imgui",
],
linkstatic = 1
)
链接参数文件C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\link.exe @bazel-out/x64_windows-fastbuild/bin/playground/window.exe-2.params
的GLEW库很奇怪。我不知道external/glew/lib/Release/x64/glew32s.lib
是怎么生成的。但是GLEW.lib没有join链接。
/nologo
/OUT:bazel-out/x64_windows-fastbuild/bin/playground/window.exe
bazel-out/x64_windows-fastbuild/bin/playground/_objs/window/window.obj
bazel-out/x64_windows-fastbuild/bin/playground/playground.lib
bazel-out/x64_windows-fastbuild/bin/playground/scene/scenes.lib
bazel-out/x64_windows-fastbuild/bin/playground/pass.lib
bazel-out/x64_windows-fastbuild/bin/playground/object/object.lib
bazel-out/x64_windows-fastbuild/bin/engine/framebuffer/framebuffer.lib
bazel-out/x64_windows-fastbuild/bin/playground/context.lib
bazel-out/x64_windows-fastbuild/bin/engine/repo/repo.lib
bazel-out/x64_windows-fastbuild/bin/engine/engine.lib
bazel-out/x64_windows-fastbuild/bin/engine/primitive/primitive.lib
bazel-out/x64_windows-fastbuild/bin/engine/mesh.lib
bazel-out/x64_windows-fastbuild/bin/engine/gl.lib
bazel-out/x64_windows-fastbuild/bin/external/assimp/assimp.lib
bazel-out/x64_windows-fastbuild/bin/engine/util.lib
bazel-out/x64_windows-fastbuild/bin/engine/proto/config_proto.lib
bazel-out/x64_windows-fastbuild/bin/external/com_github_protocolbuffers_protobuf/protobuf.lib
bazel-out/x64_windows-fastbuild/bin/external/com_github_protocolbuffers_protobuf/protobuf_lite.lib
bazel-out/x64_windows-fastbuild/bin/external/com_github_google_glog/glog.lib
bazel-out/x64_windows-fastbuild/bin/external/com_github_gflags_gflags/gflags.lib
bazel-out/x64_windows-fastbuild/bin/external/fmt/fmt.lib
external/glew/lib/Release/x64/glew32s.lib
bazel-out/x64_windows-fastbuild/bin/external/imgui/imgui.lib
bazel-out/x64_windows-fastbuild/bin/external/glfw/glfw_src.lib
/SUBSYSTEM:CONSOLE
-ignore:4221
-ignore:4221
-DEFAULTLIB:user32.lib
-DEFAULTLIB:gdi32.lib
-DEFAULTLIB:shell32.lib
/MACHINE:X64
/DEFAULTLIB:msvcrt.lib
/DEBUG:FASTLINK
/INCREMENTAL:NO
有人能帮我链接到已经存在的GLEW32.lib成功吗?非常感谢。
1条答案
按热度按时间bksxznpy1#
我的错。这不是bazel的问题,也不是glew的问题。GLEW的意思是OpenGL扩展管理员库。它不包含原始OpenGL函数实现。
在将
linkopts = ["-DEFAULTLIB:opengl32.lib"]
添加到glew cc_library之后,每一个都可以。链接错误如下。它们都是原始的OpenGL函数。