- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new to linking issues on Windows so I suspect my problem is a simple one. I am trying to build a Matlab mex function.
My mexFunction is just a wrapper which calls another function from a small module (finfo). Compilation of both module and mexfunction go fine, but I get an unresolved external symbol error at link:
In the mexFunction calc_info.obj:
012 00000000 UNDEF notype () External | CALC_INFO
In the finfo module object finfo.obj:
00B 000016C0 SECT2 notype () External | FINFO_mp_CALCINFO
So I don't understand why it is External in the compiled module? And how to resolve my undefined symbol.
Thanks
I am new to linking issues on Windows so I suspect my problem is a simple one. I am trying to build a Matlab mex function.
My mexFunction is just a wrapper which calls another function from a small module (finfo). Compilation of both module and mexfunction go fine, but I get an unresolved external symbol error at link:
[bash]>> mex -c finfo.f90
>> mex -v -ID:\code\MatlabAPI.git calc_info.f d:\code\rahim\finfo.obj d:\code\MatlabAPI.git\MatlabAPImx.obj d:\code\MatlabAPI.git\MatlabAPImex.obj C:\AMD\acml4.4.0\ifort64\lib\libacml_mv.lib
-> Default options filename found in C:\Users\rince\AppData\Roaming\MathWorks\MATLAB\R2010b
----------------------------------------------------------------
-> Options file = C:\Users\rince\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2010b
-> COMPILER = ifort
-> Compiler flags:
COMPFLAGS = /fpp /free /Qprec "/IC:\Program Files\MATLAB\R2010b/extern/include" -c -nologo -DMATLAB_MEX_FILE /MD /fp:source /assume:bscc /Qopenmp
OPTIMFLAGS = /O2 /DNDEBUG
DEBUGFLAGS = /Z7
arguments = -ID:\code\MatlabAPI.git
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:MEXFUNCTION /LIBPATH:"C:\Program Files\MATLAB\R2010b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\templib.x" /MAP:"calc_info.mexw64.map" /NOLOGO /INCREMENTAL:NO
LINKDEBUGFLAGS = /debug /PDB:"calc_info.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"calc_info.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> ifort -ID:\code\MatlabAPI.git /fpp /free /Qprec "/IC:\Program Files\MATLAB\R2010b/extern/include" -c -nologo -DMATLAB_MEX_FILE /MD /fp:source /assume:bscc /Qopenmp /FoC:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\calc_info.obj /O2 /DNDEBUG -DMX_COMPAT_32 calc_info.f
Contents of C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\mex_tmp.rsp:
C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\calc_info.obj D:\code\rahim\finfo.obj D:\code\MatlabAPI.git\MatlabAPImx.obj D:\code\MatlabAPI.git\MatlabAPImex.obj C:\AMD\acml4.4.0\ifort64\lib\libacml_mv.lib
--> link /out:"calc_info.mexw64" /dll /export:MEXFUNCTION /LIBPATH:"C:\Program Files\MATLAB\R2010b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\templib.x" /MAP:"calc_info.mexw64.map" /NOLOGO /INCREMENTAL:NO @C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\mex_tmp.rsp
Creating library C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\templib.x and object C:\Users\rince\AppData\Local\Temp\mex_JSZ0fe\templib.exp
calc_info.obj : error LNK2019: unresolved external symbol CALC_INFO referenced in function MEXFUNCTION
calc_info.mexw64 : fatal error LNK1120: 1 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'calc_info.mexw64' failed.
[/bash] When I look at the symbol names with dumpbin, In the mexFunction calc_info.obj:
012 00000000 UNDEF notype () External | CALC_INFO
In the finfo module object finfo.obj:
00B 000016C0 SECT2 notype () External | FINFO_mp_CALCINFO
So I don't understand why it is External in the compiled module? And how to resolve my undefined symbol.
Thanks
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Subprogram names declared inside CONTAINS .. END .. appear decorated with the module name in the object files.
Either use the decorated name in calc_info.f90, or place the subprogram calc_info outside any modules.
Make sure that the name is used consistently; CALC_INFO and CALCINFO do not match.
Either use the decorated name in calc_info.f90, or place the subprogram calc_info outside any modules.
Make sure that the name is used consistently; CALC_INFO and CALCINFO do not match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much for help! It was an inconsistency with the underscore and so completely my fault! I didn't spot it becuase I assumed the underscore was removed as part of the name mangling.
Thanks again.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>I assumed the underscore was removed as part of the name mangling
On the contrary, the underscore is used in symbol names precisely because humans tend to ignore it and computers do not!
On the contrary, the underscore is used in symbol names precisely because humans tend to ignore it and computers do not!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page