Du mục

Mount error

Fix mount error of nfs volume in Ubuntu:

sudo e2fsck -f -y /dev/sda1
Advertisements
Du mục

[Matlab] MEX file 64bit compling

1. If you have the problem with MSSE2 or MSSE3, set the flag:

mex ‘CXXFLAGS=-msse3 -msse’ -I/home/tntrung/Documents/My_Project/HelloVO/libviso2dev/src matcherMex.cpp

-I : including the *.h folder needed for the compiler.

2. The problem may happen when you compile without the appropriate gcc: /usr/bin/ld: /tmp/mex_200098125486073_16180/matcherMex.o: relocation R_X86_64_32 against `.rodata.str1.1′ can not be used when making a shared object; recompile with -fPIC /tmp/mex_200098125486073_16180/matcherMex.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status

Solution: Using -fPIC option to build the shared objects, notice to put -msse3 -msse if necessary:

gcc -c -msse3 -msse -fPIC matcher.cpp

gcc -shared -o libviso2share.so matcher.o filter.o …

or using Matlab to compile shared library:

mcc -B csharedlib:sharedlibname matcher.o filter.o …

Compiling with mex in Matlab:

mex -I/home/tntrung/Documents/My_Project/HelloVO/libviso2dev/src matcherMex.cpp libviso2share.so

Notice: export LD_LIBRARY_PATH and PATH to the shared library folder before running Matlab, otherwise you will get an error “unable to open shared library”.

For example:

export LD_LIBRARY_PATH=/home/tntrung/Documents/My_Project/HelloVO/libviso2dev/matlab:$LD_LIBRARY_PATH

export PATH=/home/tntrung/Documents/My_Project/HelloVO/libviso2dev/matlab:$PATH

3. [Updated] Compile mex files in another way of MALTAB:

mex(‘matcherMex.cpp’,’../src/matcher.cpp’,’../src/filter.cpp’,’../src/triangle.cpp’,’../src/matrix.cpp’,’-I../src’,’CXXFLAGS=-msse3 -fPIC’);