I am trying to run following example from MKL website.
#include <stdio.h>
#include "mkl_vsl.h"
int main()
{
double r[1000]; /* buffer for random numbers */
double s; /* average */
VSLStreamStatePtr stream;
int i, j;
/* Initializing */
s = 0.0;
vslNewStream( &stream, VSL_BRNG_MT19937, 777 );
/* Generating */
for ( i=0; i<10; i++ ) {
vdRngGaussian( VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, 1000, r, 5.0, 2.0 );
for ( j=0; j<1000; j++ ) {
s += r[j];
}
}
s /= 10000.0;
/* Deleting the stream */
vslDeleteStream( &stream );
/* Printing results */
printf( "Sample mean of normal distribution = %f\n", s );
return 0;
}
I am using following CMakeLists.txt file to compile the code.
cmake_minimum_required(VERSION 3.0.0)
project(rndGen VERSION 0.1.0)
add_executable(rndGen rndGenTest.cpp)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(MKLROOT "C:/Program\ Files\ (x86)/Intel/oneAPI/mkl/latest")
set(MKLLIB "${MKLROOT}/lib/intel64")
target_include_directories(rndGen
PUBLIC ${MKLROOT}/include
)
target_link_libraries(rndGen
PUBLIC ${MKLLIB}/mkl_intel_ilp64.lib
PUBLIC ${MKLLIB}/mkl_intel_thread.lib
PUBLIC ${MKLLIB}/mkl_core.lib
PUBLIC "C:/Program\ Files\ (x86)/Intel/oneAPI/compiler/latest/windows/compiler/lib/intel64_win/libiomp5md.lib"
)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
As stated in the title, the code crashes. The debugger output from VSCode is as following:
-------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code
with Visual Studio Code, Visual Studio or Visual Studio for Mac
software to help you develop and test your applications.
-------------------------------------------------------------------
Loaded 'C:\mklTest\build\Debug\rndGen.exe'. Symbols loaded.
Loaded 'C:\Windows\System32\ntdll.dll'.
Loaded 'C:\Windows\System32\kernel32.dll'.
Loaded 'C:\Windows\System32\KernelBase.dll'.
Loaded 'C:\Windows\System32\vcruntime140d.dll'.
Loaded 'C:\Windows\System32\ucrtbased.dll'.
The program '[16972] rndGen.exe' has exited with code -1073741515 (0xc0000135).
However, the code runs fine when compiled manually in cmd using following command.
cl /EHsc rndGenTest.cpp -I "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\include" "C:\Program Files (x86)\Intel\oneAPI\mkl\2021.1.1\lib\intel64\mkl_intel_ilp64.lib" "C:\Program Files (x86)\Intel\oneAPI\mkl\2021.1.1\lib\intel64\mkl_intel_thread.lib" "C:\Program Files (x86)\Intel\oneAPI\mkl\2021.1.1\lib\intel64\mkl_core.lib" "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\intel64_win\libiomp5md.lib"
The output of the code is
Sample mean of normal distribution = 4.985218
I am pretty sure I am missing something in the CMakeLists.txt file. Can someone point me in the right direction? Thanks in advance.
EDIT
Thanks for the comments and answers. I tried all of them and none worked. I tried to dig a little bit deeper to find the exact cause of problem. Apparently, the code compiles fine both ways. However, it doesn't work if the exe file is executed directly (executed in cmd directly). It works fine if I first open the oneAPI command prompt and then run the exe. My guess is that there is some environment variable or runtime library which is not available to the exe. If so, what should I change so that the exe can run on its own (without the need of running oneAPI command prompt)?
ninja -v
. Also, raise your minimum CMake version to 3.18, which is what ships with Visual Studio these days – Alex Reinking Feb 26 at 6:03Intel10_64ilp
– Alex Reinking Feb 26 at 6:05