Skip to content

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

Closed

Description

@ndabas

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:

	@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:

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:

	@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

Activity

  1. martin-frbg commented on Oct 1, 2026

    @martin-frbg
    Collaborator

    Ironic that this seems to have come from a PR labeled "Improve OpenBLASConfig.cmake contents" (#5035) - looks like I forgot to copypaste the redirect onto the individual echo statements in those four lines. :(
    I'll create a PR with your suggested fixes tomorrow, thank you.

  2. ndabas commented on Oct 1, 2026

    @ndabas
    ContributorAuthor

    Ah, thanks for confirming this -- I was a bit puzzled about why this was and the only reason I didn't submit a PR was that I wasn't sure if this was intentional or not!

  3. martin-frbg commented on Oct 2, 2026

    @martin-frbg
    Collaborator

    You can still submit a PR if you like - you're probably more familiar with CMake config file syntax than me...

  4. ndabas commented on Oct 2, 2026

    @ndabas
    ContributorAuthor

    Sure, I'll go ahead and submit a PR, I see a couple of other minor fixes to improve stability of CI on Windows -- I can probably add that in as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions