/matlab/mex/.build/bits/impl/tinythread.o: undefined reference to symbol ‘pthread_create@@GLIBC_2.2.5’//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
1.在vl_compilenn.m中修改
% Compiler flags
flags.cc = {} ;
flags.link = {} ;
为:
flags.link = {'-lpthread'};
2.修改Makefile
MEXFLAGS_LD := $(MEXFLAGS) \
CLIBS='$$CLIBS $(LDFLAGS)' \
CXXLIBS='$$CXXLIBS $(LDFLAGS)' \
LDOPTIMFLAGS='$$LDOPTIMFLAGS $(LDOPTIMFLAGS)'
还有,
flags.mexlink = horzcat(flags.cc, flags.link, ...
{'-largeArrayDims'}, ...
{['LDFLAGS=\$LDFLAGS ', strjoin(flags.linkpass)]}, ...
{['CLIBS=\$CLIBS ', strjoin(flags.linklibs)]}, ...
{['CXXLIBS=\$CXXLIBS ', strjoin(flags.linklibs)]}, ...
{['LINKLIBS=\$LINKLIBS ', strjoin(flags.linklibs)]}) ;
/usr/bin/ld:/home/jere/Documents/MATLAB/matconvnet-1.0-beta20/matlab/mex/.build/vl_nnconv.o: relocation R_X86_64_32S against `.rodata’ can not be used when making a shared object; recompile with -fPIC/home/jere/Documents/MATLAB/matconvnet-1.0-beta20/matlab/mex/.build/vl_nnconv.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status
在vl_compilenn.m中
flags.ccoptim = {'-fPIC'} ;
本文介绍了解决MATLAB mex编译时遇到的pthread创建符号未定义及relocation错误的方法。通过修改vl_compilenn.m文件中的链接器标志添加-pthread选项,并设置-fPIC编译选项来解决共享对象编译问题。
1万+

被折叠的 条评论
为什么被折叠?



