I am using CMake and CLion on windows, with the MinGW compiler. I have been trying to add the onnxruntime library to my project. I have installed the windows x64 1.14.1 release from the onnxruntime github and unpacked it. In my root CMakeLists.txt, I have temporarily set ONNX_DIR to the download location.
find_library(ONNX_LIB NAMES onnxruntime HINTS ${ONNX_DIR}/lib)
if (NOT ONNX_LIB)
message(FATAL_ERROR "onnxruntime not found!")
endif ()
add_executable(${PROJ_NAME} main.cpp uci.cpp uci.hpp)
target_include_directories(${PROJ_NAME} PRIVATE ${ONNX_DIR}/include)
target_link_libraries(${PROJ_NAME} PRIVATE movegen boardstate ${ONNX_LIB})
When I try to build my project, I get the following error messages:
C:\PROGRA~1\JETBRA~1\CLION2~1.3\bin\mingw\bin\G__~1.EXE -DVERSION_MAJ=\"1\" -DVERSION_MIN=\"0\" -DVERSION_PATCH=\"0\" -IC:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include -g -fdiagnostics-color=always -std=gnu++20 -MD -MT CMakeFiles/polaris.dir/main.cpp.obj -MF CMakeFiles\polaris.dir\main.cpp.obj.d -o CMakeFiles/polaris.dir/main.cpp.obj -c C:/Users/[name]/CLionProjects/polaris/src/main.cpp
In file included from C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_cxx_api.h:26,
from C:/Users/[name]/CLionProjects/polaris/src/neural/network.hpp:3,
from C:/Users/[name]/CLionProjects/polaris/src/main.cpp:5:
C:/Users/[name/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:135:62: error: '_Frees_ptr_opt_' has not been declared
135 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
| ^~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:1764:3: note: in expansion of macro 'ORT_CLASS_RELEASE'
1764 | ORT_CLASS_RELEASE(Env);
| ^~~~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:135:85: error: expected ',' or '...' before '*' token
135 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
| ^
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:1764:3: note: in expansion of macro 'ORT_CLASS_RELEASE'
1764 | ORT_CLASS_RELEASE(Env);
| ^~~~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:135:62: error: '_Frees_ptr_opt_' has not been declared
135 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
| ^~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:1768:3: note: in expansion of macro 'ORT_CLASS_RELEASE'
1768 | ORT_CLASS_RELEASE(Status);
| ^~~~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:135:85: error: expected ',' or '...' before '*' token
135 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
| ^
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:1768:3: note: in expansion of macro 'ORT_CLASS_RELEASE'
1768 | ORT_CLASS_RELEASE(Status);
| ^~~~~~~~~~~~~~~~~
C:/Users/[name]/Downloads/onnxruntime/onnxruntime-win-x64-1.14.1/include/onnxruntime_c_api.h:135:62: error: '_Frees_ptr_opt_' has not been declared
135 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
| ^~~~~~~~~~~~~~~
which continues on.
I have redacted my name for privacy reasons.
The CMake build itself seems to be working, but I think something went wrong with find_library and it's not locating the proper files.
I inspected the output of find_library using message(${ONNX_LIB})
. find_library correctly identifies the onnxruntime lib file. However, the directory also contains the following:
onnxruntime.dll
onnxruntime.lib
onnxruntime.pdb
onnxruntime_providers_shared.dll
onnxruntime_providers_shared.lib
onnxruntime_providers_shared.pdb
I have tried using find_libraries to search for onnxruntime_providers_shared. It is also successfully able to find onnxruntime_providers_shared.lib. Unfortunately, it does not fix the errors.
Any help is appreciated!