MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling XmathCommand() from a ucb block on Windows

I would like to call matlab external program interface function "XmathCommand()" from a ucb code.
I include   "xmathlib.h" header file in the ucb c code.
 

Xmath Solaris (71.5):

REFS The only changes that need to is to add "INCLUDES    = -I$(SYSBLD)/../xmath/include" to the makefile and everything works fine. The following is the final linking message reported on the xmath command  window:

Creating ./simucb.so.1.0
/usr/ccs/bin/ld -G -z nodefs -o ./simucb.so.1.0.new ./tt_cmc_rtw/tt.o ./tt_cmc_rtw/tt_data.o    ucbhook.o tt_cmc_rtw/tt_ucb.o   -lm  -lhyper
Done.
 

Windows (71.6):

The same process does not work on windows platform. I use the same ucb code. I copy the "makelnx.bat" and "makelnx.mk" to the working directory and add the followings:

INCLUDES    = -I$(SYSBLD)/../xmath/include
 
If I run the simulation,  the following error is produced:
 
Linking simucb.dll ..
link /OUT:simucb.dll /NOLOGO /DLL /SUBSYSTEM:console /INCREMENTAL:no ucbhook.obj tt_cmc_rtw\tt_ucb.obj C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\simucb.exp
C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\simexe.lib C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\libdllutil.lib C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\hyper\lib\libhyper.lib
ttlib.lib libcmt.lib
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
tt_ucb.obj : error LNK2001: unresolved external symbol _XmathCommand
simucb.dll : fatal error LNK1120: 1 unresolved externals
 
I modify the LIBS  in  "makelnx.mk" to include Xmath.lib:
 
LIBS = \
"C:\Program Files\National Instruments\MATRIXx\mx_71.6\xmath\lib\xmath.lib" \
$(SYSBLD)\lib\simucb.exp \
$(SYSBLD)\lib\simexe.lib \
$(SYSBLD)\lib\libdllutil.lib \
$(HYPER)\lib\libhyper.lib \
$(USRLIBS) \
$(FLIB)
 
If I run the simulation,  the following error is produced:
 
Linking simucb.dll ..
 link /OUT:simucb.dll /NOLOGO /DLL /SUBSYSTEM:console /INCREMENTAL:no ucbhook.obj tt_cmc_rtw\tt_ucb.obj "C:\Program Files\National Instruments\MATRIXx\mx_71.6\xmath\lib\xmath.lib"
C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\simucb.exp C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\simexe.lib C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\sysbld\lib\libdllutil.lib
C:\PROGRA~1\NATION~1\MATRIXx\mx_71.6\hyper\lib\libhyper.lib ttlib.lib libcmt.lib
libdllutil.lib(dll_init.obj) : error LNK2005: _AllocateMatrix already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _WrapMatrix already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeleteMatrix already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _AllocateString already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _WrapString already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _AllocateStringMatrix already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _WrapStringMatrix already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeleteString already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _WrapPDM already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeletePDM already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _AllocateNull already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeleteNull already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _AllocateList already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeleteList already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _DeleteAny already defined in xmath.lib(externtypes.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathMain already defined in xmath.lib(xmath_client.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathStart already defined in xmath.lib(xmath_client.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathStop already defined in xmath.lib(xmath_client.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathPut already defined in xmath.lib(xsp.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathGet already defined in xmath.lib(xsp.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathExecute already defined in xmath.lib(xmath_client.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathPanic already defined in xmath.lib(xsp.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathReleaseIPC already defined in xmath.lib(xsp.obj)
libdllutil.lib(dll_init.obj) : error LNK2005: _XmathSyncWorkDir already defined in xmath.lib(xmath_client.obj)
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
xmath.lib(s_win32_dbg.obj) : error LNK2001: unresolved external symbol
__imp__MessageBoxA@16
xmath.lib(s_win32.obj) : error LNK2001: unresolved external symbol __imp__GetUserNameA@8
simucb.dll : fatal error LNK1120: 2 unresolved externals

Any idea why the windows behave differently and how to resolve the issue.

Thanks
 
Farshid
0 Kudos
Message 1 of 2
(7,809 Views)
Farshid,
      
      On windows, you can't link with xmath.lib directly, so that must be removed from the linked in libraries for the UCB. The libdllutil.lib has everything that's possible to call within a UCB.

It looks like the XmathCommand function is not part of the libdllutil.lib and therefore not accessible. However, the XmathExecute function is available. So, use that one instead.

Cheers,

NathanT
0 Kudos
Message 2 of 2
(7,755 Views)