Open mishaelnuh opened 5 years ago
Do you use the 64- or the 32-bit version of Matlab? If you use the 32-bit version, then I would guess that you need to compile the mex file as 32-bit version as well, by selecting a different compiler in step 4.
I’m using a 64-bit version of Matlab.
Ok, then unfortunately, I don't think I can help you. I think I have seen this error before. However, I don't recall how or even if I solved it, since I moved away from Matlab for quite some time now. Perhaps @alecjacobson can help.
Did you build cgal in x64?
I've left cmake to download cgal and the precompiled binaries. I'm not too familiar with cmake, but I'm assuming it all gets compiled at the same time along with the rest of the solution? I've set Visual Studio to compile in x64.
I think you have to build cgal first: https://www.cgal.org/download/windows.html
Couldn't get it to work in the end. Switched to working on a Mac and it compiled without any issues.
Thanks for all the help!
I don't work on Windows but some students have successfully got this to compile. @rarora7777 maybe you have a tip?
I looked at my compile notes from a couple of months ago, and I had to do the following for CGAL
.
libigl
myself and set the LIBIGL_ROOT
environment variable. This is my default setup and I prefer that gptoolbox
doesn't re-download libigl
anyway.gptoolbox_download_libigl()
in gptoolbox
's CMakeLists.txt
to force it to use the existing installation of libigl
.mpir
available on my system via the vcpkg
package manager (https://github.com/microsoft/vcpkg). mpir
is the Windows fork of gmp
, which CGAL
depends on.libigl
, I use the vcpkg
toolchain file and comment out igl_download_cgal_deps()
to use mpir
installed of libgmp
downloaded by this function call.eltopo
, but functions calling CGAL
work fine.tl;dr The main issue is that gptoolbox
forces gmp
, but I've only ever been able to use CGAL
with mpir
on my machines.
If it works with mpir, do think we can automate using mpir instead of gmp on Windows within the cmake?
I can confirm that it also works with gmp
. But I still had to make a couple of manual changes.
FindBLAS
included with CGAL was unable to find MKL on my system, even with the environment variables MKLROOT
and MKL_LIB_DIR
set. I just removed it and forced the use of FindBLAS
included with CMake. Note that CGAL no longer includes this module, but the version downloaded by libigl does../mex/Release
or ./mex/Debug
). MATLAB expects the mexw64
executables to be placed next to the .m
and .cpp
source, so the executables need to be copied to the parent folder ./mex
.mexw64
executables looks for mpfr.dll
and mpir.dll
instead of libmpfr-4.dll
and libgmp-10.dll
. Manually renaming the files does the trick, but there must be a way to make them refer to the correct filenames.@rarora7777 I used MINGW and CMake 3.20.5 to compile the /mex on Windows 10. The 'Configure' and 'Generate' in Cmake were both successful finally, but when I used 'make' of Mingw to make them ,the errors in the following picture occured. Do you know why? Can you help me , please. Thank you very much.
@babydu12138 I'm not even sure if MinGW is supported. I believe @alecjacobson has only ever built it for MSVC on Windows. Is it possible for you to switch to MSVC?
I have never built gptoolbox on windows personally.
@babydu12138 I'm not even sure if MinGW is supported. I believe @alecjacobson has only ever built it for MSVC on Windows. Is it possible for you to switch to MSVC?
Okay, I'll try it.
@babydu12138 I'm not even sure if MinGW is supported. I believe @alecjacobson has only ever built it for MSVC on Windows. Is it possible for you to switch to MSVC?
Okay, I'll try it.
@rarora7777 I have Configured and generated the codes in mex with CMake sucessfully, but I don't know what should I do the next step, please tell me, thank you very much.
Great! Now you just need to copy all the executables to the base folder, as that's where MATLAB requires them to be. That is, copy or move all mexw64
files from gptoolbox/mex/build/Release
to gptoolbox/mex
.
In addition, you need the dynamic library dependencies. Copy libgmp-10.dll
and libgmp-4.dll
from gptoolbox/mex/external/libigl/external/gmp/lib
to gptoolbox/mex
.
Great! Now you just need to copy all the executables to the base folder, as that's where MATLAB requires them to be. That is, copy or move all
mexw64
files fromgptoolbox/mex/build/Release
togptoolbox/mex
.In addition, you need the dynamic library dependencies. Copy
libgmp-10.dll
andlibgmp-4.dll
fromgptoolbox/mex/external/libigl/external/gmp/lib
togptoolbox/mex
.
Thank you very much! I have compiled them successfully!
Great! Now you just need to copy all the executables to the base folder, as that's where MATLAB requires them to be. That is, copy or move all
mexw64
files fromgptoolbox/mex/build/Release
togptoolbox/mex
.In addition, you need the dynamic library dependencies. Copy
libgmp-10.dll
andlibgmp-4.dll
fromgptoolbox/mex/external/libigl/external/gmp/lib
togptoolbox/mex
.
I copyed the "libgmp-10.dll" and "libgmp-10.lib" from "gptoolbox/mex/external/libigl/external/gmp/lib" and "libmpfr-4.dll" and "libmpfr-4.lib" from "gptoolbox/mex/external/libigl/external/mpfr/lib". It works.
I'm trying to use a few MEX functions, but am running into an error in MATLAB saying
XXX.mexw64 is not a valid Win32 application
. This happens with most of the functions needing CGAL, everything else seems to be fine. Followed the instructions below:Originally posted by @maxfrei750 in https://github.com/alecjacobson/gptoolbox/issues/78#issuecomment-441975232
Configuration:
Any help would be much appreciated!