I am trying to create an executable that links to a static library (on Windows), called mkl.lib in the CMakeLists below.
I had a look at this question and tried the suggestions in this one but for me they didn't work.
I have tried two different approaches to get the *.exe to link against the *.lib I have but every time I run it, I get the error message requiring the mkl.dll file (which I don't have).
My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.15)
project(MKLLink)
add_executable(MKL main.cpp)
find_library(MKLLIB NAMES mkl.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/external/lib/")
target_link_libraries(MKL PUBLIC ${MKLLIB})
target_include_directories(MKL PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/include")
and my main.cpp looks like:
#include "mkl/mkl_service.h"
#include <iostream>
int main( int argc, char** argv)
{
// Correct version is
MKLVersion pVersion;
mkl_get_version(&pVersion);
std::cout << "Major: " << pVersion.MajorVersion << std::endl;
std::cout << "Minor: " << pVersion.MinorVersion << std::endl;
std::cout << "Update: " << pVersion.UpdateVersion << std::endl;
return 0;
}
Using CMake I can create the project files for VSStudio and open the solution there. The Properties look correct and he solution compiles fine and does not complain about linking. When I run the executable, I see the error requiring mkl.dll.
Independently, I have tried starting from scratch and created a VS Project but I get exactly the same issue. Compilation and Linkage are good but running crashes asking for *.dll. Generally, it seems to me that I should just be able to link against a *.lib file but maybe I am missing some flags.
Thank you