Problème avec le linker de MinGW (TDM-GCC-64) et OpenMP sur Windows
Bonjour,
Après avoir écumé le web pendant des jours pour compiler des fichiers mex, j'appelle à l'aide !
Je souhaite travailler avec ces codes Matlab ici. Ca contient des fichiers en cpp, que j'ai besoin de compiler à l'aide d'une fonction fournie.
N'ayant pas de compiler sur mon ordinateur, j'ai commencé par installer TDM-GCC-64, car j'ai besoin d'utiliser openmp, j'ai utilisé gnumex pour pouvoir indiquer à Matlab d'utiliser ce compiler, j'ai modifié le path, enfin bref je pense avoir installé le truc correctement.
J'ai ensuite dû modifier le fichier mexopts.bat comme expliqué ici pour faire fonctionner la compilation d'un fichier exemple tout simple : yprime.c fourni avec Matlab. Ca marche pour ce fichier là mais pour le code que j'essaie de compiler, j'obtiens l'erreur suivante :
Code:
1 2 3 4 5
| collect2.exe: error: ld returned 1 exit status
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'C:\Users\Elise\Desktop\AFIS\CSH_code_v3\C_and_Mex\votemex.mexw64' failed.
Unable to complete successfully. |
J'ai modifié mon fichier mexopts.bat en m'inspirant de ce lien. Ca n'a rien changé... J'obtiens toujours cette même erreur et je suis à court d'idées pour solutionner ça.
J'ai bien trouvé cette discussion sur ce forum http://www.developpez.net/forums/d14...w-erreur-link/ Je ne comprends pas les réponses malheureusement, un peu trop technique pour moi... J'ai l'impression que le problème vient de Mingw ou de mon fichier mexopts.bat.
Quelqu'un a-t-il une idée ?
J'utilise Matlab 2013b sous Windows 8.1.
La commande Matlab utilisée :
Code:
1 2
| mex OPTIMFLAGS="-DNDEBUG -DMEX_MODE -fopenmp" knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp
simnn.cpp allegro_emu.cpp -output ../votemex |
Le .bat :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @echo off
:: Set this to your Mingw64 top folder, where you extracted the above
set MINGWPATH=C:\TDM-GCC-64
:: Leave these alone unless you know what you're doing.
set PATH=C:\TDM-GCC-64\x86_64-w64-mingw32\bin;%PATH%
set PRELINK_CMDS=echo.>%TEMP%\mexstaticlibs
:: You can have MEX run some commands before calling the linker.
:: The two examples below will cause gcc to output the full path to some
:: static libraries so you can link statically to them (see the
:: LINGFLAGSPOST special var below). You can set any command here, however.
rem set PRELINK_CMDS1=gcc -print-file-name=libwinpthread.a >> %TEMP%\mexstaticlibs
rem set PRELINK_CMDS2=gcc -print-file-name=libquadmath.a >> %TEMP%\mexstaticlibs
rem set PRELINK_CMDS3=...
:: You can have MEX run some commands also after calling the linker
:: (e.g. upx compress the output .mex)
rem set POSTLINK_CMDS1=upx -9 "%OUTDIR%%MEX_NAME%%MEX_EXT%"
rem set POSTLINK_CMDS2=...
:: You can change these if you really need to.
set COMPILER=g++
set COMPFLAGS=-c -I"%MATLAB%\extern\include" -DMATLAB_MEX_FILE
set OPTIMFLAGS=-O3 -funroll-loops -DNDEBUG
set DEBUGFLAGS=-g
set NAME_OBJECT=-o
set LINKER=x86_64-w64-mingw32-g++
set LINKFLAGS=-shared -static-libstdc++ -static-libgcc -L"%MATLAB%\bin\win64" -L"%MATLAB%\extern\lib\win64\microsoft" -leng -lmwlapack -lmwblas
set LINKFLAGSPOST=@%TEMP%\mexstaticlibs -lmx -lmex -lmat
set LINKOPTIMFLAGS=-O2
set LINKDEBUGFLAGS=-g
set NAME_OUTPUT=-o "%OUTDIR%%MEX_NAME%%MEX_EXT%" |