Open
Description
I have a project setup with Bazel, it builds fine except for VC++. VC++ complains it can't find hwy::Abort(char const *,int,char const *,...)
:
primitives.lib(primitives.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl hwy::Abort(char const *,int,char const *,...)" (__imp_?Abort@hwy@@YAXPEBDH0ZZ) referenced in function "public: static float __cdecl hwy::N_SSE2::Dot::Compute<1,struct hwy::N_SSE2::Simd<float,4,0>,float>(struct hwy::N_SSE2::Simd<float,4,0>,float const * __restrict const,float const * __restrict const,unsigned __int64)" (??$Compute@$00U?$Simd@M$03$0A@@N_SSE2@hwy@@M@Dot@N_SSE2@hwy@@SAMU?$Simd@M$03$0A@@12@QEIBM1_K@Z)
bazel-out\x64_windows-fastbuild\bin\test\math\primitives_test.exe : fatal error LNK1120: 1 unresolved externals
Same project compiles/links fine with GCC and Clang on Mac and Linux.
I import Highway as a Bazel module:
bazel_dep(name = "highway", version = "1.2.0")
Dependencies:
cc_library(
name = "primitives",
srcs = ["primitives.cc"],
hdrs = ["primitives.h"],
deps = [
"@abseil-cpp//absl/log:log",
"@highway//:dot",
"@highway//:hwy",
],
)
Activity
eugeneo commentedon Nov 27, 2024
I tried the latest version, does not work.
jan-wassenberg commentedon Nov 27, 2024
Interesting.. I see that abort.cc is in the "hwy" target, and that we have HWY_DLLEXPORT annotations on both the declaration and definition, which are the usual causes of this.
We actually ask for a DLL build in the open source version: https://github.com/google/highway/blob/master/BUILD#L139C25-L139C42
But internally and in CI, this is disabled. Removing the
HWY_SHARED_DEFINE
should avoid the problem.hm, I suspect DLL builds are not worth the trouble for Highway, but it's probably worse to disable them now everywhere and cause confusion for projects already using them.
eugeneo commentedon Dec 2, 2024
Does this need a fix in highway or can I configure build in my project? My project is a library itself so I would rather link Highway statically.
jan-wassenberg commentedon Dec 2, 2024
You should be able to get a static build by setting the CMake variable HWY_FORCE_STATIC_LIBS, see
highway/CMakeLists.txt
Line 460 in 62c0a79
eugeneo commentedon Dec 2, 2024
I'm using Bazel... I will see if I can set that flag somehow in Bazel.
chinwobble commentedon Dec 8, 2024
I'm getting the same issue when installing highway using
vcpkg
as well.I tried adding the following to my CMakeLists.txt but it didn't work.
eugeneo commentedon Dec 23, 2024
I made it work for me by undefing the symbol before including the Highway. Could not figure out how to do it on the build level or what to adjust in Highway...
I believe there should be a better fix. I have Windows env setup now for Highway build so I would not mind working on this, if there's any suggestion on the direction.
jan-wassenberg commentedon Jan 6, 2025
@chinwobble is this the only
HWY_DLLEXPORT
symbol you are using and that is missing? Isn't there alsoAllocateAlignedBytes
?@eugeneo glad this workaround works, though I agree it's suboptimal. Bazel is a little strange with static builds. AFAIK it is not possible to ask for that within the BUILD file itself. Have you tried running Bazel with
--dynamic_mode=off
flag?jan-wassenberg commentedon Jul 10, 2025
Closing, feel free to reopen if you'd like to continue the discussion.