So I've been wanting to learn C++, I have a student license for CLion and am familiar with other software from the company so I'd want to use it if possible. Using MSYS2 seemed like a good way to easily manage libraries, since that tends to be hellish anytime I tried working with C++.
MSYS2 seemed intuitive enough and I managed to install the OpenCV library as a test. However, I'm now entirely at a loss on how I'd link it with CLion.
I've been reading about CMake files, and this is what I figured should be mine:
cmake_minimum_required(VERSION 3.7)
project(letsee)
set(CMAKE_CXX_STANDARD 11)
find_package (OpenCV REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(letsee ${SOURCE_FILES})
target_link_libraries( letsee ${OpenCV_LIBS} )
The last line, however, is supposed to link to be an environment variable. I understand that MSYS2 should handle that somehow, or perhaps I should create my own windows environment variable? Either way I'm not even sure to where I'd link such variable. I'm just incredibly confused by this point. How can no one have created an intuitive way to handle this in windows in a 40 year old language.
I just downloaded and setup everything to try it. Here is how it works:
pacman -Syu
, pacman -Su
) - you probably did that alreadypacman -S mingw-w64-x86_64-toolchain
(you probably did this too)pacman -S mingw-w64-x86_64-cmake
This is the important step. We will use this CMake instead of the bundled one, because this CMake works with MSYS2 pacman librariesC:\msys64\mingw64
(or similiar), CMake: C:\msys64\mingw64\bin\cmake.exe
Edit: I actually also tested it with the bundled CMake right now and this worked too, out of the box. So no idea why it doesn't for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With