Open Frankieac opened 5 years ago
Hi Frank!
Thanks for leaving such a detailed message! I can see where it went wrong, you were almost there. It's just that the cmake command inside the build directory should be followed by ".." rather than "." to indeed refer to the directory that does include a CMakeLists.txt
The python script looks for the MSbuild files inside the build directory, that is why the list of files that it will patch is empty.
The visual studio errors that you receive are exactly the errors that the python script is intended to fix. So when you run cmake with .. at the end of the line inside the build directory and then run the Python script I think everything should work.
Please let me know if this solves your problem!
Best, Ben
Hi Ben,
Thanks for the quick reply I tried with .. and that worked fine. Then I tried the python file and it said that it was patching the expdist and mex_gausstransform vcxproj files and it showed the alot of .lib files
But when I tried to build again it gave me exactly the same errors as before and the same error in the Matlab code.
Frank
Hi Frank,
Oh that's unexpected! You do have a newer Visual Studio version than what I've been using. That was because CUDA was only compatible with older Visual Studio versions, but for you, that's not relevant. Could you copy one of the vcxproj files that's generated by cmake?
The idea of the Python script is that it patches the vcxproj files to include not only the libmex library but also the libmx library, which appears to contain the symbols needed to properly build the mex files on windows. It's a workaround to a bug in cmake. I'd think that either vcxproj file is different and the Python script patches the file incorrectly or (and that would be a bit harder to resolve) including libmx in not sufficient to solve the missing symbols error when building mex files in your setup.
Best, Ben
Hi Frank,
I've just pushed a patch for the python script. It seemed that the vcxproj files were a bit different from what the python script was expecting, which caused certain dependencies to be included multiple times. This could be the cause of errors, but I'm not entirely sure this fixes everything. Could you give it a try?
Also, could you check if there is a file called "libmx.lib" in the same directory as: C:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft\libmex.lib ?
If it doesn't work please give me the full output of the error that you get from visual studio.
Best, Ben
Hi Frank,
Have you been able to give the patched Python script a try?
Best, Ben
Hi Ben,
I tried the new Python script. I still get the same errors. Also I found the libmx.lib file in the specified directory here is the output of the program and the errors
Frank
Hi Frank,
Thank you for the detailed error report! I've have done some digging and it seems to be a recent issue with the FindMatlab.cmake module in CMake: https://gitlab.kitware.com/cmake/cmake/issues/19382
CMake explicitly exports certain functions related to the mex C++ API even if the mex file only uses C, these C++ functions later on cannot be found, resulting in linker errors.
I will try to implement the workaround suggested in the cmake issue.
Ben
Hi Frank,
I've added a couple of cmake modules that should contain the fixes we need for building mex files under Windows. I got these from the current development version of cmake. Unfortunately the changes to FindMatlab.cmake have not been included an official release yet, so this is the only way to use the fixed version.
I have not yet been able to test these changes under Windows myself, but on Linux it's working for me now. Could you give it a try?
Best, Ben
hi,
I got multiple issues. I try to run this on windows with CPU.
first when I try the command: cmake -G "Visual Studio 16 2019" -DUSE_GPU=OFF . inside the 'build' map it wont work because it doesn't contain CMakeList.txt. When I move one directory up there are no problems.
Then when I try the following command: python fix_msbuild_files.py I only get the message: patching files: [] and then just nothing
Then when I open Visual Studio and try to build ALL_BUILD and/or mex_gausstransform_cpu and mex_expdist_cpu I get multiple errors: 8 times LINK2001 error unresolved external symbol and 2 times LINK1120 error 4 unresolved externals
despite the errors it creates 2 mexw64 files However when I try to run the matlab code I get the error: invalid MEX-file mex_gausstransform_cpu.mexw64' is not a valid shared library..
and that is where I am stuck.
I hope someone knows what I am doing wrong
Frank