I’ll start with an apology – I don’t post here often and I’m not familiar with the etiquette, so apologies if this is too much info. I’m just trying to be thorough…
Background to my knowledge level: I have programmed in C and C++ for many years, but mostly functional /object level, rarely having to worry about c-run time conflicts or library link conflicts. Also, most of my work is nearly a decade ago now although I still ‘dabble’. I have never used CMAKE or VCPKG up until last week.
I would really like to build/link/run mlpack on Windows from Visual Studio. I followed the install guide which brought me to VCPKG, which I used to successfully downloaded and built mlpack and all its dependencies. I then installed (from vcpkg) the libs/directories in Visual Studio as per mlpack documentation and could access the headers and write/build simple code.
This is where I came across my first (and main) issue, & why I am writing here. It appears that at compile time,
CMake for mlpack detected I could use “openmp” compile switch, and so used it.
CMake for Armadillo (a dependant) did not and built without openmp.
So, when I build my very simple code, at link time I get an mlpack pragma stating, “doom and disaster”. More specifically, the error is:
“
#ifdef MLPACK_ARMA_USE_OPENMP
#pragma message ("mlpack was compiled with OpenMP support, but you are
compiling without OpenMP support. This will almost certainly cause
irreparable disaster. Either enable OpenMP support in your application (e.g.,
add -fopenmp to your compiler command line), or, recompile mlpack without OpenMP support.")
“
This lead me to CMAKE (something I have not had to use before). In the CMakelists.txt, I can see the openmp / lack of openmp in the mplack / armadillo library CMakeLists.txt files, respectively.
So, that makes sense at least.
I think I ‘get’ the idea behind CMAKE, but to go into the CMakeLists.txt files (within VCPKG folder structure) and change the script there (in \vcpkg\buildtrees\l\src\xxxx.clean\ would feel like hacking.
Additionally, where the directory states ‘clean’ – I think the intention is for this to not be meddled with. (I don’t want to accidentally break either CMAKE or VCPKG!)
Also, I have a feeling that it wouldn’t stop there. Suppose I want to change Armadillo’s CMakeLists file to ensure compile with “openmp” option, there may be 100 dependencies to Armadillo that I have to go through to ensure they also have the correct ‘openmp’ compile flag in the CMakeLists.txt files.
^ Doesn’t seem like the way to achieve what I’m trying to achieve. It isn’t simple, or beautiful. (plus, I don’t yet know how to do that anyway)
So to my mind, there has got to be a “top-level” flag (in VCPKG?) I can set so that I can recompile mlpack and all dependencies with “openmp” specified for all.
As of this point in time, I’ve spent about 6 hours reading in-and-around VCPKG and CMAKE and still not sure how to tackle this (inlcuding lots of posts here).
VCPKG makes getting libraries and their dependencies very easy – but it’s opaque. CMAKE is the same (for me at least) – where CMakeLists.txt are hundreds of lines long and I have 165 libraries items in my \vcpkg\buildtrees\ folder, and all in a script that I am not familiar with.
It has got to be simpler than this, surely.
Aside: I came across flags and compile options in a CMake-like format for VCPKG. Files such as:
\vcpkg\scripts\toolchains\windows.cmake
\vcpkg\scripts\buildsystems\vcpkg.cmake
I also came across other posts referring to the use of CMAKE commands such as:
target_compile_options
add_compile_options
CMAKE_CXX_FLAGS
I think all are potentially relevant, but not certain what their definitions are, or what the parameters can be (if defined) – or, even, perhaps the parameters are not defined and simply passed to the compiler who knows what it means (?).
So, to the questions:
- Am I anywhere near the right train of thought? (Re, top-level vcpkg recompiling of everything)
- If so, how do I get vcpkg to recompile mlpack and all dependencies? (I don’t know how to kick-off the whole recompile thing, even without adding compile options)
- And also, how do I ensure that they are recompiled in a compatible manner (all with or without openmp)?
Otherwise, I guess I have probably got some misconceptions – if you read something in the above history that doesn’t seem to fit with standard views, please pull me up on it as I want to learn more about this.
Special thanks to anyone who has time to help.