#6084·OpenBLAS

OpenBLASConfig.cmake from the Makefile build on Windows has no OpenBLAS::OpenBLAS target: echo lines are missing the redirect

Author: ndabasCreated Oct 1, 2026Updated Oct 1, 2026

On Windows (WINNT/CYGWIN_NT), make install writes an OpenBLASConfig.cmake that has no OpenBLAS::OpenBLAS imported target. OpenBLAS_LIBRARIES points at the DLL, so MSVC can't link against it.

The cause is in Makefile.install. The lines that are meant to define the imported target, including its IMPORTED_IMPLIB, are @echoed without the >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)" redirect that every other line in that block has. They go to the build log instead of the config file:

make
	@echo "add_library(OpenBLAS::OpenBLAS SHARED IMPORTED)"
	@echo "target_include_directories(OpenBLAS::OpenBLAS INTERFACE \$${OpenBLAS_INCLUDE_DIRS})"
ifeq ($(OSNAME), $(filter $(OSNAME),WINNT CYGWIN_NT))
	@echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_LOCATION \$${OpenBLAS_LIBRARIES})"
	@echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB \$${_OpenBLAS_ROOT_DIR}/lib/libopenblas.lib)"
endif

Observed

lib/cmake/openblas/OpenBLASConfig.cmake in the OpenBLAS-0.3.34-x64.zip release asset (and identically, apart from the version, in OpenBLAS-0.3.33-x64.zip) contains only:

cmake
SET(OpenBLAS_VERSION "0.3.34")
file(REAL_PATH "../../.." _OpenBLAS_ROOT_DIR BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} )
SET(OpenBLAS_INCLUDE_DIRS ${_OpenBLAS_ROOT_DIR}/include)
SET(OpenBLAS_LIBRARIES ${_OpenBLAS_ROOT_DIR}/bin/libopenblas.dll)

The same archive ships a valid x64 MSVC import library at lib/libopenblas.lib (dumpbin /headers shows machine 8664, DLL name libopenblas.dll), but nothing in the config refers to it.

Impact

  • target_link_libraries(foo OpenBLAS::OpenBLAS) fails because the target doesn't exist.
  • Tools that use OpenBLAS_LIBRARIES (for example, Meson's CMake dependency lookup) pass the DLL to link.exe, which fails with:
    bin\libopenblas.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x480
  • MinGW consumers aren't affected, because GNU ld can link directly against a DLL.

The woa64 assets are built with CMake and are unaffected: their config exports OpenBLAS::OpenBLAS with IMPORTED_IMPLIB set to lib/openblas.lib.

Suggested fix

Add the missing redirect to the four @echo lines above:

make
	@echo "add_library(OpenBLAS::OpenBLAS SHARED IMPORTED)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)"
	@echo "target_include_directories(OpenBLAS::OpenBLAS INTERFACE \$${OpenBLAS_INCLUDE_DIRS})" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)"
ifeq ($(OSNAME), $(filter $(OSNAME),WINNT CYGWIN_NT))
	@echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_LOCATION \$${OpenBLAS_LIBRARIES})" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)"
	@echo "set_property(TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB \$${_OpenBLAS_ROOT_DIR}/lib/libopenblas.lib)" >> "$(DESTDIR)$(OPENBLAS_CMAKE_DIR)/$(OPENBLAS_CMAKE_CONFIG)"
endif

On non-Windows platforms the target would then also need IMPORTED_LOCATION set, or the add_library/target_include_directories lines could be moved inside the Windows conditional.

Side note

The surrounding block is guarded by ifneq ($(origin _OpenBLAS_ROOT_DIR),"undefined"). $(origin ...) returns the bare word undefined, never the quoted string, so this condition is always true and the else branch never runs. It may not matter in practice, but it looks unintended.

Environment

  • OpenBLAS release assets OpenBLAS-0.3.34-x64.zip and OpenBLAS-0.3.33-x64.zip
  • The same code is present in Makefile.install on develop.
  • Consumer: MSVC 19.51, Meson 1.11