alecjacobson / gptoolbox

Matlab toolbox for Geometry Processing.
MIT License
626 stars 165 forks source link

Cannot find /export:mexFunction: No such file or directory #150

Open Alexisc54 opened 1 year ago

Alexisc54 commented 1 year ago

Hello everyone,

Following my issue (post #149), where I compiled with Cmake-gui software and VS 2015 (window 10 x64), I trying now to pass by Window PowerShell using MinGW compilator. First, I used this command to write build files : cmake -G "MinGW Makefiles" .. Generating done, It's ok. Then, I use this command to build the Makefile : mingw32-make. I got this error :

PS C:\dev2\gptoolbox\mex\build> mingw32-make [ 0%] Built target igl_restricted_matlab [ 0%] Built target igl_core [ 0%] Building CXX object CMakeFiles/aabb.dir/aabb.cpp.obj [ 2%] Linking CXX shared library C:\dev2\gptoolbox\mex\aabb.mexw64 c:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory collect2.exe: error: ld returned 1 exit status mingw32-make[2]: [CMakeFiles\aabb.dir\build.make:106: C:/dev2/gptoolbox/mex/aabb.mexw64] Error 1 mingw32-make[1]: [CMakeFiles\Makefile2:436: CMakeFiles/aabb.dir/all] Error 2 mingw32-make: *** [makefile:155: all] Error 2

Is anyone able to help me? #desperate

Thank you very much by advance !

Alexis

JingyiT commented 1 year ago

Have you solved this problem? I have the same problem.

Alexisc54 commented 1 year ago

Not yet sorry..

fengzex commented 6 months ago

Hello, I was wondering if you have resolved this issue? I’ve encountered the same problem. I would appreciate any help you could provide. Thank you!

nkh0472 commented 5 months ago

I am using Windows 10 10.0.19044.4170, MATLAB 2023b, MSYS2+MinGW64, gcc version 13.2.0 (Rev5, Built by MSYS2 project), same problem encountered.

MINGW64 /x/mex/build
$ cmake --build . --config Release
[1/291] Linking CXX shared library X:\mex\aabb.mexw64
FAILED: X:/mex/aabb.mexw64 X:/mex/libaabb.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\aabb.mexw64 -Wl,--out-implib,X:\mex\libaabb.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/aabb.dir/aabb.cpp.obj
 D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  D:/Office/MATLAB2023b/extern/lib/wi
n64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -lu
uid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[2/291] Linking CXX shared library X:\mex\angle_derivatives.mexw64
FAILED: X:/mex/angle_derivatives.mexw64 X:/mex/libangle_derivatives.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\angle_derivatives.mexw64 -Wl,--out-implib,X:\mex\libangle_derivatives.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFi
les/angle_derivatives.dir/angle_derivatives.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/min
gw64/libmat.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32
 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[3/291] Linking CXX shared library X:\mex\bone_visible.mexw64
FAILED: X:/mex/bone_visible.mexw64 X:/mex/libbone_visible.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\bone_visible.mexw64 -Wl,--out-implib,X:\mex\libbone_visible.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/bone_v
isible.dir/bone_visible.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  D:/
Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32 -lwinspool
-lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[4/291] Linking CXX shared library X:\mex\blue_noise.mexw64
FAILED: X:/mex/blue_noise.mexw64 X:/mex/libblue_noise.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\blue_noise.mexw64 -Wl,--out-implib,X:\mex\libblue_noise.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/blue_noise
.dir/blue_noise.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  D:/Office/M
ATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell3
2 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[5/291] Linking CXX shared library X:\mex\collapse_small_triangles.mexw64
FAILED: X:/mex/collapse_small_triangles.mexw64 X:/mex/libcollapse_small_triangles.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\collapse_small_triangles.mexw64 -Wl,--out-implib,X:\mex\libcollapse_small_triangles.dll.a -Wl,--major-image-version,0,--minor-image-ver
sion,0 CMakeFiles/collapse_small_triangles.dir/collapse_small_triangles.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATL
AB2023b/extern/lib/win64/mingw64/libmat.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/lib
mat.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[6/291] Linking CXX shared library X:\mex\decimate_libigl.mexw64
FAILED: X:/mex/decimate_libigl.mexw64 X:/mex/libdecimate_libigl.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\decimate_libigl.mexw64 -Wl,--out-implib,X:\mex\libdecimate_libigl.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/
decimate_libigl.dir/decimate_libigl.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/lib
mat.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32
 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[7/291] Linking CXX shared library X:\mex\dual_laplacian.mexw64
FAILED: X:/mex/dual_laplacian.mexw64 X:/mex/libdual_laplacian.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\dual_laplacian.mexw64 -Wl,--out-implib,X:\mex\libdual_laplacian.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/du
al_laplacian.dir/dual_laplacian.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.
lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32 -lw
inspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
[8/291] Linking CXX shared library X:\mex\exact_geodesic.mexw64
FAILED: X:/mex/exact_geodesic.mexw64 X:/mex/libexact_geodesic.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && X:\msys64\mingw64\bin\c++.exe -march=native -O3 -DNDEBUG  /export:mexFunction -shared -o X:\mex\exact_geodesic.mexw64 -Wl,--out-implib,X:\mex\libexact_geodesic.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/ex
act_geodesic.dir/exact_geodesic.cpp.obj  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.
lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmex.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmx.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libeng.lib  D:/Office/MATLAB2023b/extern/lib/win64/mingw64/libmat.lib  -lkernel32 -luser32 -lgdi32 -lw
inspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
X:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find /export:mexFunction: No such file or directory
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
nkh0472 commented 5 months ago

After some searching, I found this problem is caused by:

https://github.com/alecjacobson/gptoolbox/blob/55d3d1e0ef4fad6950be552aa820f89cde1dd065/mex/CMakeLists.txt#L116-L119

Some info about this flag: https://stackoverflow.com/questions/8552580/using-gcc-mingw-as-matlabs-mex-compiler https://stackoverflow.com/questions/25998442/mex-options-when-compiling-with-visual-studio

Some linkers cannot find the /export:mexFunction flag as they use different syntax for exporting symbols, lead to above error.

I tried to replace above lines to:

    if(MINGW)
      # Modify export symbol for MinGW
      set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
    endif()

or simply delete the 118 line in original code, could make this error disappear.

However, some new errors showed, but I believe it's not relative to the modified code.

X:/msys64/mingw64/include/gmpxx.h: In static member function 'static bool __gmp_binary_less::eval(mpz_srcptr, mpf_srcptr)':
X:/msys64/mingw64/include/gmpxx.h:1082:12: error: 'mpf_cmp_z' was not declared in this scope; did you mean 'mpf_cmp_d'?
 1082 |   { return mpf_cmp_z(f, z) > 0; }
      |            ^~~~~~~~~
      |            mpf_cmp_d
X:/msys64/mingw64/include/gmpxx.h: In static member function 'static void __gmp_primorial_function::eval(mpz_ptr, long unsigned int)':
X:/msys64/mingw64/include/gmpxx.h:1263:50: error: 'mpz_primorial_ui' was not declared in this scope
 1263 |   static void eval(mpz_ptr z, unsigned long l) { mpz_primorial_ui(z, l); }

more test needed...


Update: The absence of declarations for structures like mpf_cmp_z is noted in /cgal-src/include/gmpxx.h, whereas they are present in /mingw64/include/gmpxx.h. It appears there's an issue with the inclusion. Despite attempts to rectify it by modifying cmakelists.txt with set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I x:/gptoolbox-master/mex/build/_deps/cgal-src/include"), the problem persists. The cause remains unclear.

Notably, MSVC does not encounter this error.

alecjacobson commented 5 months ago

(I'm sorry I'm not a windows user so I'm not much help here)

nkh0472 commented 5 months ago

It appears that the MinGW toolchain isn't compatible with this project. Using MSVC, however, yields successful compile. See https://github.com/alecjacobson/gptoolbox/pull/140#issuecomment-2029375153