Compilation mixte de C et de Fortran
Bonjour-bonjour !
J'ai un programme Matlab qui fait appel a des mex-files. Les mex-files ont été compilés sous Unix et mon travail est de le faire sous Windows. J'ai des routines Fortran et la fonction "Gateway" (fonction qui fait le lien entre Matlab et les routines Fortran) en C
Quand on compile sous Unix, on peut mélanger C et Fortran, il "suffit" donc de faire :
Code:
1 2
|
mex loiglpattdir.c glpattdir2.F initbr.F filin.F dirfin.F mindowson.F huilemax.F couple_came.F diff_Ccame_ad.F dico_Ccame_ad.F maths.F trtbr.F |
Sous Windows, mex ne peut prendre que des fichiers C ou que des Fortran. J'ai donc compilé toutes mes sources Fortran en .obj (et j'ai déjà bien galéré !) et pour créer le mex-file, je fais :
Code:
1 2
|
mex loiglpattdir.c glpattdir2.obj initbr.obj filin.obj dirfin.obj mindowson.obj huilemax.obj couple_came.obj diff_Ccame_ad.obj dico_Ccame_ad.obj maths.obj trtbr.obj |
Et là, Matlab me renvoie :
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
This is mex, Copyright 1984-2005 The MathWorks, Inc.
-> Default options filename found in C:\Documents and Settings\e332442\Application Data\MathWorks\MATLAB\R14SP3
----------------------------------------------------------------
-> Options file = C:\Documents and Settings\e332442\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
MATLAB = c:\palette\apl\matlabv7r3
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = -c -Zp8 -G5 -GR -W3 -DMATLAB_MEX_FILE -nologo
OPTIMFLAGS = /MD -O2 -Oy- -DNDEBUG
DEBUGFLAGS = /MDd -Zi -Fd"loiglpattdir.mexw32.pdb"
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /MAP /LIBPATH:"c:\palette\apl\matlabv7r3\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /implib:_lib6824.x /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
LINKDEBUGFLAGS = /DEBUG /PDB:"loiglpattdir.mexw32.pdb"
LINKFLAGSPOST =
Name directive = /out:"loiglpattdir.mexw32"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> "cl -c -Zp8 -G5 -GR -W3 -DMATLAB_MEX_FILE -nologo /FoC:\DOCUME~1\e332442\LOCALS~1\Temp\loiglpattdir.obj -Ic:\palette\apl\matlabv7r3\extern\include -Ic:\palette\apl\matlabv7r3\simulink\include /MD -O2 -Oy- -DNDEBUG loiglpattdir.c"
loiglpattdir.c
loiglpattdir.c(111) : warning C4013: 'glpattdir2' undefined; assuming extern returning int
Contents of 6824_tmp.rsp:
C:\DOCUME~1\e332442\LOCALS~1\Temp\loiglpattdir.obj glpattdir2.obj initbr.obj filin.obj dirfin.obj mindowson.obj huilemax.obj couple_came.obj diff_Ccame_ad.obj dico_Ccame_ad.obj maths.obj trtbr.obj
--> "link /out:"loiglpattdir.mexw32" /dll /export:mexFunction /MAP /LIBPATH:"c:\palette\apl\matlabv7r3\extern\lib\win32\microsoft" libmx.lib libmex.lib libmat.lib /implib:_lib6824.x /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 @6824_tmp.rsp "
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
C:\DOCUME~1\e332442\LOCALS~1\Temp\loiglpattdir.obj glpattdir2.obj initbr.obj filin.obj dirfin.obj mindowson.obj huilemax.obj couple_came.obj diff_Ccame_ad.obj dico_Ccame_ad.obj maths.obj trtbr.obj
Creating library _lib6824.x and object _lib6824.exp
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
loiglpattdir.obj : error LNK2001: unresolved external symbol _glpattdir2
loiglpattdir.mexw32 : fatal error LNK1120: 1 unresolved externals
C:\PALETTE\APL\MATLABV7R3\BIN\MEX.PL: Error: Link of 'loiglpattdir.mexw32' failed.
??? Error using ==> mex
Unable to complete successfully |
A ce que je comprends (loiglpattdir.obj : error LNK2001: unresolved external symbol _glpattdir2), il ne trouve pas ma fonction fortran "glpattdir2"...
Un idée de ce que je n'ai pas ou mal fait ?
Merci d'avance,
ZeFMG.