IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

probleme avec mex C++ [MEX]


Sujet :

MATLAB

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 2
    Points
    2
    Par défaut probleme avec mex C++
    Bonjour,
    J’ai un fichier .cpp qui inclue une librairie définie par l’utilisateur matrix.hpp. Le fichier compile correctement en C++ et Matlab. Par contre si j’essaye de créer un mex file en Matlab pour multiply3D.cpp j’obtiens l’erreur suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    >> mex -c multiply3D.cpp
    >> mex multiply3D.cpp
       Création de la bibliothèque D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_VY~1\templib.x et de l'objet D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_VY~1\templib.exp 
    multiply3D.obj : error LNK2019: symbole externe non résolu _dgemm référencé dans la fonction "void __cdecl mexFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const)" (?mexFunction@@YAXHQAPAUmxArray_tag@@H0@Z) 
    multiply3D.mexw32 : fatal error LNK1120: 1 externes non résolus 
     
      C:\PROGRA~1\MATLAB\R2008B\BIN\MEX.PL: Error: Link of 'multiply3D.mexw32' failed. 
     
    ??? Error using ==> mex at 213
    Unable to complete successfully.

    J’utilise Matlab 7.7 version 2008b et le compilateur [2] Microsoft Visual C++ 2008 Express in C:\Program Files\Microsoft Visual Studio 9.0. Je devrais mentionner aussi que tous les autres fichiers .cpp qui incluent que des librairies standard s’exécutent correctement. Aussi, si j’utilise la function multiply3D dans un script Matlab il retourne pas des erreurs mais il retourne un résultat erroné : multiply3D(a,b) =a, pour tous a,b.

    Comment je pourrais résoudre cette erreur ?

    je vous remercie beaucoup !

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 62
    Points : 73
    Points
    73
    Par défaut
    Ta fonction appelle dgemm qui fait partie de l'API BLAS.
    Pour compiler sous windows, tu devrais rajouter ca en entête

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    #if defined(__OS2__)  || defined(__WINDOWS__) || defined(WIN32) || defined(_MSC_VER)
    #define BLASCALL(f) f
    #else
    #define BLASCALL(f) f ##_
    #endif

    et remplacer l'appel la fonction "dgemm" dans ton .cpp par "BLASCALL(dgemm)".


    Après compiles ton mex file par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    mex multiply3D.cpp C:\Program Files\MATLAB\R2008b\extern\lib\win32\microsoft\libmwlapack.lib

    et ca devrait passer ....

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    Merci beacoup, mais en fait meme apres ta solution, j'ai toujours le meme erreur...

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 62
    Points : 73
    Points
    73
    Par défaut
    Citation Envoyé par sharon_cheev Voir le message
    Merci beacoup, mais en fait meme apres ta solution, j'ai toujours le meme erreur...

    Rajoute l'option -v et fait un copy/paste du log pour que je vois ...

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    This is mex, Copyright 1984-2007 The MathWorks, Inc. 
     
    -> Default options filename found in D:\Documents and Settings\ib224157\Application Data\MathWorks\MATLAB\R2008b 
    ---------------------------------------------------------------- 
    ->    Options file           = D:\Documents and Settings\ib224157\Application Data\MathWorks\MATLAB\R2008b\mexopts.bat 
          MATLAB                 = C:\PROGRA~1\MATLAB\R2008B 
    ->    COMPILER               = cl 
    ->    Compiler flags: 
             COMPFLAGS           = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD 
             OPTIMFLAGS          = /O2 /Oy- /DNDEBUG 
             DEBUGFLAGS          = /Z7 
             arguments           =  
             Name switch         = /Fo 
    ->    Pre-linking commands   =  
    ->    LINKER                 = link 
    ->    Link directives: 
             LINKFLAGS           = /dll /export:mexFunction /LIBPATH:"C:\PROGRA~1\MATLAB\R2008B\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x" /MAP:"multiply3D.mexw32.map" 
             LINKDEBUGFLAGS      = /DEBUG /PDB:"multiply3D.mexw32.pdb" 
             LINKFLAGSPOST       =  
             Name directive      = /out:"multiply3D.mexw32" 
             File link directive =  
             Lib. link directive =  
             Rsp file indicator  = @ 
    ->    Resource Compiler      = rc /fo "mexversion.res" 
    ->    Resource Linker        =  
    ---------------------------------------------------------------- 
     
     
    --> cl  /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoD:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\multiply3D.obj -IC:\PROGRA~1\MATLAB\R2008B\extern\include -IC:\PROGRA~1\MATLAB\R2008B\simulink\include /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 D:\DOCUME~1\IB224157\MESDOC~1\DOCUME~1\PROGRA~1\CODJOE~1\multiply3D.cpp 
     
    multiply3D.cpp 
        Contents of D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\mex_tmp.rsp: 
      D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\multiply3D.obj  C:\PROGRA~1\MATLAB\R2008B\EXTERN\LIB\WIN32\MICROS~1\libmwlapack.lib 
     
     
    --> link /out:"multiply3D.mexw32" /dll /export:mexFunction /LIBPATH:"C:\PROGRA~1\MATLAB\R2008B\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x" /MAP:"multiply3D.mexw32.map"  @D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\MEX_TMP.RSP   
     
       Création de la bibliothèque D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x et de l'objet D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.exp 
    multiply3D.obj : error LNK2019: symbole externe non résolu _dgemm référencé dans la fonction "void __cdecl mexFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const)" (?mexFunction@@YAXHQAPAUmxArray_tag@@H0@Z) 
    multiply3D.mexw32 : fatal error LNK1120: 1 externes non résolus 
     
      C:\PROGRA~1\MATLAB\R2008B\BIN\MEX.PL: Error: Link of 'multiply3D.mexw32' failed. 
     
    ??? Error using ==> mex at 213
    Unable to complete successfully.

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 62
    Points : 73
    Points
    73
    Par défaut
    Citation Envoyé par sharon_cheev Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    This is mex, Copyright 1984-2007 The MathWorks, Inc. 
     
    -> Default options filename found in D:\Documents and Settings\ib224157\Application Data\MathWorks\MATLAB\R2008b 
    ---------------------------------------------------------------- 
    ->    Options file           = D:\Documents and Settings\ib224157\Application Data\MathWorks\MATLAB\R2008b\mexopts.bat 
          MATLAB                 = C:\PROGRA~1\MATLAB\R2008B 
    ->    COMPILER               = cl 
    ->    Compiler flags: 
             COMPFLAGS           = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD 
             OPTIMFLAGS          = /O2 /Oy- /DNDEBUG 
             DEBUGFLAGS          = /Z7 
             arguments           =  
             Name switch         = /Fo 
    ->    Pre-linking commands   =  
    ->    LINKER                 = link 
    ->    Link directives: 
             LINKFLAGS           = /dll /export:mexFunction /LIBPATH:"C:\PROGRA~1\MATLAB\R2008B\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x" /MAP:"multiply3D.mexw32.map" 
             LINKDEBUGFLAGS      = /DEBUG /PDB:"multiply3D.mexw32.pdb" 
             LINKFLAGSPOST       =  
             Name directive      = /out:"multiply3D.mexw32" 
             File link directive =  
             Lib. link directive =  
             Rsp file indicator  = @ 
    ->    Resource Compiler      = rc /fo "mexversion.res" 
    ->    Resource Linker        =  
    ---------------------------------------------------------------- 
     
     
    --> cl  /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoD:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\multiply3D.obj -IC:\PROGRA~1\MATLAB\R2008B\extern\include -IC:\PROGRA~1\MATLAB\R2008B\simulink\include /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 D:\DOCUME~1\IB224157\MESDOC~1\DOCUME~1\PROGRA~1\CODJOE~1\multiply3D.cpp 
     
    multiply3D.cpp 
        Contents of D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\mex_tmp.rsp: 
      D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\multiply3D.obj  C:\PROGRA~1\MATLAB\R2008B\EXTERN\LIB\WIN32\MICROS~1\libmwlapack.lib 
     
     
    --> link /out:"multiply3D.mexw32" /dll /export:mexFunction /LIBPATH:"C:\PROGRA~1\MATLAB\R2008B\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x" /MAP:"multiply3D.mexw32.map"  @D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\MEX_TMP.RSP   
     
       Création de la bibliothèque D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.x et de l'objet D:\DOCUME~1\IB224157\LOCALS~1\TEMP\MEX_DR~1\templib.exp 
    multiply3D.obj : error LNK2019: symbole externe non résolu _dgemm référencé dans la fonction "void __cdecl mexFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const)" (?mexFunction@@YAXHQAPAUmxArray_tag@@H0@Z) 
    multiply3D.mexw32 : fatal error LNK1120: 1 externes non résolus 
     
      C:\PROGRA~1\MATLAB\R2008B\BIN\MEX.PL: Error: Link of 'multiply3D.mexw32' failed. 
     
    ??? Error using ==> mex at 213
    Unable to complete successfully.

    En plus de ce que je t'ai dit, rajoute ca en header :


    void BLASCALL(dgemm)(const char *, const char *, const int *, const int *, const int *, const double *,
    const double *, const int *, const double *, const int *,
    const double *, const double *, const int *);

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    En fait j'avais deja ca en header...merci

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    62
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 62
    Points : 73
    Points
    73
    Par défaut
    Citation Envoyé par sharon_cheev Voir le message
    En fait j'avais deja ca en header...merci


    Bizarre, tout ce que je peux te dire, c'est que c'est juste un pb de link avec dgemm.

    Essayes de linker avec

    C:\Program Files\MATLAB\R2008b\extern\lib\win32\microsoft\libmwblas.lib au lieu de libmwlapack.lib

  9. #9
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 5
    Points : 2
    Points
    2
    Par défaut
    merci beaucoup! ca marche!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme avec la copie des surfaces
    Par Black_Daimond dans le forum DirectX
    Réponses: 3
    Dernier message: 09/01/2003, 10h33
  2. Problèmes avec le filtrage des ip
    Par berry dans le forum Réseau
    Réponses: 9
    Dernier message: 30/12/2002, 07h51
  3. probleme avec la touche F10
    Par b.grellee dans le forum Langage
    Réponses: 2
    Dernier message: 15/09/2002, 22h04
  4. Probleme avec fseek
    Par Bjorn dans le forum C
    Réponses: 5
    Dernier message: 04/08/2002, 07h17
  5. [Kylix] probleme avec un imagelist
    Par NicoLinux dans le forum EDI
    Réponses: 4
    Dernier message: 08/06/2002, 23h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo