<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Linux Matlab R2010b Mex and MKL 10.3 in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793095#M2400</link>
    <description>Before line 20, where you use CXXFLAGS, you need a line where that symbol is set to the list of icpc options desired. &lt;BR /&gt;&lt;BR /&gt;I do not know how the Mex script of your version of Matlab is put together, but the compiler command should come out with CXXFLAGS replaced by its value, rather than literally. That would require your using $(CXXFLAGS) on line-20.&lt;BR /&gt;&lt;BR /&gt;If the Mex script has become corrupted, you need to fix it or replace it with the original.</description>
    <pubDate>Mon, 28 Feb 2011 06:56:33 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2011-02-28T06:56:33Z</dc:date>
    <item>
      <title>Linux Matlab R2010b Mex and MKL 10.3</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793093#M2398</link>
      <description>Hi,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I'm having issues linking where I haven't had them before.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I use the makefile:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;PRE&gt;[bash]#!/bin/bash
# This Makefile is used under Linux for mex file generation

# Cluster = Matlab_2010b
#MATLABDIR ?= /pkg/matlab_x86_64/R2010b

# Firstname Surname workstation
MATLABDIR ?= /home/username/Software/R2010b
# for Mac
# MATLABDIR ?= /opt/local/matlab

INTEL = /opt/intel/composerxe-2011.0.084
MKLROOT = $(INTEL)/mkl/lib/intel64

CXX = icpc
# -Wall -Wconversion and -fPIC are required for the mex
CFLAGS = -Wall -Wconversion -fPIC -O3 -DMKL_ILP64 -I$(MATLABDIR)/extern/include -limf -L$(MKLROOT) -Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread

MEX = $(MATLABDIR)/bin/mex
MEX_OPTION = CXX\\#$(CXX) CXXFLAGS\\#"$(CFLAGS)"
# comment the following line if you use MATLAB on 32-bit
MEX_OPTION += -largeArrayDims
MEX_EXT = $(MATLABDIR)/bin/mexext


all:	matlab

matlab:	binary

binary: marg_exact_approx.$(MEX_EXT) 

marg_exact_approx.$(MEX_EXT):     
	$(MEX) $(MEX_OPTION) marg_exact_approx.cpp 

clean:
	rm -f *~ *.o *.mex* *.obj
[/bash]&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;But I'm getting undefined reference:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;[username@host Mex]$ make&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;/home/username/Software/R2010b/bin/mex CXX#icpc CXXFLAGS#"-Wall -Wconversion -fPIC -O3 -DMKL_ILP64 -I/home/username/Software/R2010b/extern/include -limf -L/opt/intel/composerxe-2011.0.084/mkl/lib/intel64 -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread" -largeArrayDims marg_exact_approx.cpp&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.o: In function `mexFunction':&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x184): undefined reference to `vslNewStream'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x253): undefined reference to `vdRngGamma'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x280): undefined reference to `vdRngGamma'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x2bb): undefined reference to `vdRngGamma'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x2e8): undefined reference to `vdRngGamma'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x360): undefined reference to `vdRngGamma'&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.o:marg_exact_approx.cpp:(.text+0x398): more undefined references to `vdRngGamma' follow&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.o: In function `mexFunction':&lt;/DIV&gt;&lt;DIV&gt;marg_exact_approx.cpp:(.text+0x3b7): undefined reference to `vslDeleteStream'&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt; mex: link of ' "marg_exact_approx.mexa64"' failed.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;make: *** [marg_exact_approx./home/username/Software/R2010b/bin/mexext] Error 1&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;When I name mangle the libraries I've specified, the functions are there.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;nm libmkl_intel_ilp64.so | grep vdRngGamma&lt;/DIV&gt;&lt;DIV&gt;000000000039abd0 T vdRngGamma&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Feb 2011 05:44:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793093#M2398</guid>
      <dc:creator>kramulous</dc:creator>
      <dc:date>2011-02-28T05:44:22Z</dc:date>
    </item>
    <item>
      <title>Linux Matlab R2010b Mex and MKL 10.3</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793094#M2399</link>
      <description>&lt;DIV&gt;there is some mismatching:&lt;/DIV&gt;CFLAGS=-Wall-Wconversion-fPIC-O3&lt;B&gt;-DMKL_ILP64&lt;/B&gt;-I$(MATLABDIR)/extern/include-limf-L$(MKLROOT)-Wl,--start-group-lmkl_intel_&lt;B&gt;lp64&lt;/B&gt;-lmkl_sequential-lmkl_core-Wl,--end-group-lpthread</description>
      <pubDate>Mon, 28 Feb 2011 06:55:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793094#M2399</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2011-02-28T06:55:54Z</dc:date>
    </item>
    <item>
      <title>Linux Matlab R2010b Mex and MKL 10.3</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793095#M2400</link>
      <description>Before line 20, where you use CXXFLAGS, you need a line where that symbol is set to the list of icpc options desired. &lt;BR /&gt;&lt;BR /&gt;I do not know how the Mex script of your version of Matlab is put together, but the compiler command should come out with CXXFLAGS replaced by its value, rather than literally. That would require your using $(CXXFLAGS) on line-20.&lt;BR /&gt;&lt;BR /&gt;If the Mex script has become corrupted, you need to fix it or replace it with the original.</description>
      <pubDate>Mon, 28 Feb 2011 06:56:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793095#M2400</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-02-28T06:56:33Z</dc:date>
    </item>
    <item>
      <title>Linux Matlab R2010b Mex and MKL 10.3</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793096#M2401</link>
      <description>Hi Gennady,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;When I posted the Makefile, I played around a little more and accidently posted the mismatch.&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Feb 2011 06:58:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793096#M2401</guid>
      <dc:creator>kramulous</dc:creator>
      <dc:date>2011-02-28T06:58:45Z</dc:date>
    </item>
    <item>
      <title>Linux Matlab R2010b Mex and MKL 10.3</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793097#M2402</link>
      <description>Hi all,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I've got it working now and posting back a solution to complete the thread. mecej4's post above forced me to be a little more critical of my makefile.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;As a result, I completely removed Matlab's /bin/mex binary due to insufficient arguments to configure libraries, etc.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[bash]#!/bin/make

BINARY = marg_exact_approx
MEX_SUFFIX = mexa64

MATLAB = /home/username/Software/R2010b
INTEL = /opt/intel/composerxe-2011.0.084
MKLROOT = $(INTEL)/mkl/lib/intel64

CC = icpc
OPTS = -DMATLAB_MEX_FILE -DMKL_ILP64 -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -O3 -xHost
SRC = marg_exact_approx.cpp
OBJS = $(SRC:.cpp=.o)


INC = -I$(MATLAB)/extern/include -I$(MATLAB)/simulink/include
LIBS = -shared -Wl,--version-script,$(MATLAB)/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined 
LIBS += -Wl,-rpath-link,$(MATLAB)/bin/glnxa64 -L$(MATLAB)/bin/glnxa64 -lmx -lmex -lmat -Wl,--start-group $(MKLROOT)/libmkl_intel_ilp64.a $(MKLROOT)/libmkl_sequential.a $(MKLROOT)/libmkl_core.a -Wl,--end-group -lpthread

.SUFFIXES: .cpp .o

.cpp.o:
	$(CC) $(OPTS) $(INC) -c $&amp;lt; -o $@

Go: $(OBJS)
	$(CC) $(OBJS) $(OPTS) -o $(BINARY).$(MEX_SUFFIX) $(LIBS)
	@echo Binary created!!

clean:
	set nonomatch; rm -f $(BINARY).$(MEX_SUFFIX) *.o
[/bash]&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;I also had to change mkl to being statically linked as there was a mismatch between Matlab libraries and as a result was getting (when executing the mex file within Matlab):&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;/home/username/Software/R2010b/bin/glnxa64/MATLAB: symbol lookup error: /opt/intel/composerxe-2011.0.084/mkl/lib/intel64/libmkl_vml_mc3.so: undefined symbol: mkl_serv_mkl_malloc&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;BR /&gt;hooroo</description>
      <pubDate>Mon, 28 Feb 2011 23:07:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Linux-Matlab-R2010b-Mex-and-MKL-10-3/m-p/793097#M2402</guid>
      <dc:creator>kramulous</dc:creator>
      <dc:date>2011-02-28T23:07:54Z</dc:date>
    </item>
  </channel>
</rss>

