Hello everyone, hope you are having a great day.
I’m pretty new to CMake and I have some questions that I’d greatly appreciate if you could lend me a helping hand.
Basically, I’m trying to build Pytorch from source on Windows and I want to build it using /MT
flag instead of the /MD
which is the default.
I noticed if I use cmake-gui
inside Pytorch’s root I am faced with something like this :
As you can see there are build Options under the CMAKE group which I have already changed all MDs to MTs.
This will create a visual studio project which I can use to build the libs and all is fine.
However, I want to find out the exact files that these variables have come from (are defined inside) So that I can set the
MT
flag by default in them (for example set a variable that when enabled change the MDs to MTs and vice versa).Is there a way to know this? How should I go about this?
Previously I went ahead and tried to change all cmake files that I find with snippets like :
# -- MT
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
spuriously everywhere! and I got it to build but on debug configuration, I faced the 0xc0000142
error which I believe may have something to do with the way I’m changing the flags from MD
to MT
. Since when I changed the MD
s to MT
s from the options you can see above, I no more get that exception but a different error pops up at runtime (some linker like error :
The procedure entry point ?mutable_grad@AutogradMeta@autograd@torch@@UEAAAEAVTensor@at@@XY could not be located in the dynamic link library
to be exact )
Anyway being able to change that in the respective files would be a great help as I can further investigate this with the devs and they may be able to replicate this using Pytorch’s own script that builds the libraries (build_libtorch.py which builds the libs without visual studio)
I appreciate any kind of help and thank you all a lot in advance