Simulink Rapid accelerator mode compiler error Linux CentOS 7.3 undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char> - matlab

Currently I am trying to run my Simulink model, built with Matlab 2019b, on a server of my university, which runs on Linux CentOS 7.3.1611. If I run the model in either 'normal', or 'accelerator' mode it is successful. However, if I try to run the model in 'rapid accelerator mode' the compiler returns an error during building. The errors all contain the element of not finding the standard library:
undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>
I have searched on MATLAB Answers and stackoverflow for solutions, but none have worked for me so far. I have also asked the IT service of my university for help but they could not help me out.
One of the solutions hinted towards the compiler not being able to find the correct libraries and that the library path should be added/updated here on stack overflow. However, if I print the Library path in matlab then it seems allright:
Library path:
<matlab_root>/cefclient/sys/os/glnxa64:<matlab_root>/sys/opengl/lib/glnxa64:<matlab_root>/sys/os/glnxa64:<matlab_root>/bin/glnxa64:<matlab_root>/extern/lib/glnxa64:<matlab_root>/runtime/glnxa64:<matlab_root>/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:
<matlab_root>/sys/java/jre/glnxa64/jre/lib/amd64/server:<compiler_root>/root/usr/lib64:<compiler_root>/root/usr/lib:<compiler_root>/root/usr/lib64/dyninst
Another problem could be the compiler. At first I used a gcc 8.x compiler, but later found out that a 6.3 version is required, so that is what I am using now
Lastly I found a that a problem could be that "(...) it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro." (from stack overflow)
The last option seems the most likely to me, however, I have not been able to solve this. I tried for instance:
set_param(model,'AccelMakeCommand','make_rtw CPP_OPTS="-D_GLIBCXX_USE_CXX11_ABI=0"')
and
set_param(model,'MakeCommand','make_rtw CPP_OPTS="-D_GLIBCXX_USE_CXX11_ABI=0"')
However, this did not help.
If anyone has a tip that could help me out, that would be great. I have added parts of the console output and the error message were it goes wrong down below for extra info.
Kind regards,
Nathan
Console output messages:
( A lot of other stuff)
### Processing Template Makefile: <matlab_root>/rtw/c/raccel/raccel_unix.tmf
### <model_folder>/slprj/raccel/MyModel/MyModel.mk which is generated from <matlab_root>/rtw/c/raccel/raccel_unix.tmf is up to date
### Building MyModel: <matlab_root>/bin/glnxa64/gmake -f MyModel.mk RSIM_SOLVER_SELECTION=2 PCMATLABROOT="<matlab_root>" EXTMODE_STATIC_ALLOC=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 EXTMODE_TRANSPORT=0 TMW_EXTMODE_TESTING=0 COMBINE_OUTPUT_UPDATE_FCNS=0 INCLUDE_MDL_TERMINATE_FCN=1 MULTI_INSTANCE_CODE=0 MODELREF_TARGET_TYPE=NONE ISPROTECTINGMODEL=NOTPROTECTING OPTS="-DTGT
an error.
Error message:
( A lot of stuff)
g++ -Wl,-rpath,<matlab_root>/sys/os/glnxa64
-L<matlab_root>/sys/os/glnxa64 -o MyModel
MyModel_c233cdf9_1.o MyModel_c233cdf9_1_create.o
MyModel_c233cdf9_1_setParameters.o
MyModel_c233cdf9_1_asserts.o
MyModel_c233cdf9_1_deriv.o
MyModel_c233cdf9_1_checkDynamics.o
MyModel_c233cdf9_1_output.o
MyModel_c233cdf9_1_assembly.o
MyModel_c233cdf9_1_computeConstraintError.o
MyModel_c233cdf9_1_mode_zero_crossings.o
MyModel_c233cdf9_1_geometries.o
MyModel_c233cdf9_1_gateway.o pm_printf.o rt_logging.o
rt_backsubrr_dbl.o rt_forwardsubrr_dbl.o rt_lu_real.o rt_matrixlib_dbl.o
MyModel.o MyModel_capi.o
MyModel_data.o MyModel_tgtconn.o rtGetInf.o
rtGetNaN.o rt_nonfinite.o rt_logging_mmi.o rtw_modelmap_utils.o
raccel_main_new.o raccel_sup.o raccel_mat.o simulink_solver_api.o
raccel_utils.o common_utils.o ext_svr.o updown.o ext_work.o
rtiostream_interface.o rtiostream_tcpip.o rtiostream_utils.o \
<matlab_root>/toolbox/physmod/sm/ssci/lib/glnxa64/sm_ssci_std.a
<matlab_root>/toolbox/physmod/sm/core/lib/glnxa64/sm_std.a
<matlab_root>/toolbox/physmod/pm_math/lib/glnxa64/pm_math_std.a
<matlab_root>/toolbox/physmod/simscape/engine/sli/lib/glnxa64/ssc_sli_std.a
<matlab_root>/toolbox/physmod/simscape/engine/core/lib/glnxa64/ssc_core_std.a
<matlab_root>/toolbox/physmod/network_engine/lib/glnxa64/ne_std.a
<matlab_root>/toolbox/physmod/common/math/core/lib/glnxa64/mc_std.a
<matlab_root>/toolbox/physmod/common/external/library/lib/glnxa64/ex_std.a
<matlab_root>/toolbox/physmod/common/foundation/core/lib/glnxa64/pm_std.a
<matlab_root>/bin/glnxa64/libmwcoder_target_services.so
<matlab_root>/bin/glnxa64/libmwcoder_ParamTuningTgtAppSvc.so
-L"<matlab_root>/bin/glnxa64" -lmwipp -lut -lmx -lmex
-lmat -lmwmathutil -lmwslexec_simbridge -lmwsl_fileio
-lmwsigstream -lmwsl_AsyncioQueue -lmwsl_services
-lmwsdi_raccel -lmwi18n -lmwsl_simtarget_instrumentation
-lfixedpoint -lmwslexec_simlog -lm -lpthread -ldl
<matlab_root>/bin/glnxa64/libQt5WebKit.so.5: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_S_copy(char*, char const*, unsigned
long)#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_locale.so.1.65.1: undefined
reference to `std::__cxx11::numpunct<char>::id#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_serialization.so.1.65.1:
undefined reference to `typeinfo for
std::__codecvt_utf8_base<wchar_t>#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libut.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::assign(char const*)#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libut.so: undefined reference to
`std::logic_error::logic_error(char const*)#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwcoder_target_services.so: undefined
reference to `typeinfo for std::_V2::error_category#GLIBCXX_3.4.21'
<matlab_root>/bin/glnxa64/libmwboost_locale.so.1.65.1: undefined
reference to `typeinfo for std::__cxx11::moneypunct_byname<char,
false>#GLIBCXX_3.4.21'
( A lot of stuff)
collect2: error: ld returned 1 exit status
gmake: *** [MyModel] Error 1
Error(s) encountered while building "MyModel" - Show complete
stack trace
}

Related

Protobuf for MATLAB fails to build in Cygwin

I am trying to build the protobuf compiler for MATLAB using github.com/BraunPhilipp/protobuf-matlab (forked from farsounders code). I followed the instructions at the site and I keep getting this error:
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: CMakeFiles/protoc.dir/home/kiran/protobuf/src/google/protobuf/compiler/main.cc.o:main.cc:(.text+0x2f3): undefined reference to farsounder::protobuf::compiler::matlab::MatlabGenerator::MatlabGenerator()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: CMakeFiles/protoc.dir/home/kiran/protobuf/src/google/protobuf/compiler/main.cc.o:main.cc:(.text+0x3dc): undefined reference to farsounder::protobuf::compiler::matlab::MatlabGenerator::~MatlabGenerator()' /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: CMakeFiles/protoc.dir/home/kiran/protobuf/src/google/protobuf/compiler/main.cc.o:main.cc:(.text+0x57e): undefined reference to `farsounder::protobuf::compiler::matlab::MatlabGenerator::~MatlabGenerator()' collect2: error: ld returned 1 exit status
Any help would be great

Recompile with -fPIC

I write this command:
gcc drr.c -o drr -pthread -lcdsl -L./../synch_implementations -I./../synch_implementations
And I can't understand why I get this response:
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_queue_list.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_deque_list.o): relocation R_X86_64_32S against symbol `cdsl_deque_list_lock_based_pthread_push_tail' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: ./../synch_implementations/libcdsl.a(cdsl_lock.o): relocation R_X86_64_32S against symbol `cdsl_pthread_lock_request' can not be used when making a PIE object; recompile with -fPIC
usr/bin/ld: final link failed: Nonrepresentable section on output
ollect2: error: ld returned 1 exit status
Can anyone help me understand what is wrong?
Notes:
1)I use ubuntu (via VirtualBox).
2)I am very inexperienced, so probably this is not a very bright question.
Solution:
When you compile ./../synch_implementations/libcdsl.a you need to add an extra "-fPIC" flag to produce position-independent-code (see comments above).
Note:
The PIC flag is in general needed when producing library object code since it creates objects relative to a global offset table (GOT) which subsequently allows to link library objects with your code.

cuDNN code sample compile error

I'm trying to install NVIDIA's cuDNN library and run their code sample, but it's giving me these errors and I don't know what is wrong.
make all
Building target: cuDNNtest
Invoking: NVCC Linker
/usr/local/cuda-7.5/bin/nvcc --cudart static -L/usr/local/cuda-7.5/lib64 -L/usr/local/cuda-7.5/targets/x86_64-linux/lib/ -L".../cuda-workspace/cuDNNtest/FreeImage/lib/linux/x86_64" -L/usr/lib -L/usr/local/cuda/lib64 --relocatable-device-code=true -gencode arch=compute_52,code=compute_52 -gencode arch=compute_52,code=sm_52 -link -o "cuDNNtest" ./fp16_dev.o ./fp16_emu.o ./mnistCUDNN.o ./UtilNPP/StopWatchLinux.o -lcudnn -lFreeImage -lcublas
./mnistCUDNN.o: In function `npp::ImageAllocator<unsigned char, 1ul>::Malloc2D(unsigned int, unsigned int, unsigned int*, bool)':
.../cuda-workspace/cuDNNtest/UtilNPP/ImageAllocatorsNPP.h:76: undefined reference to `nppiMalloc_8u_C1'
./mnistCUDNN.o: In function `npp::ImageAllocator<unsigned char, 1ul>::Free2D(unsigned char*)':
.../cuda-workspace/cuDNNtest/UtilNPP/ImageAllocatorsNPP.h:87: undefined reference to `nppiFree'
collect2: ld returned 1 exit status
make: *** [cuDNNtest] Error 1
I'm using Nsight Eclipse Edition on Linux centOS, cuda toolkit 7.5 and Titan X (compute capability 5.2, I think).
Thank you in advance.
I solved this adding -lnppi to the libraries list in the project's properties.

fortran: using pgplot with eclipse photran

So I am really not a Fortran programmer at all, but I have some code I am working with that uses the pgplot graphics libraries in fortran. I am able to get the code running in fortran from the console using the following commands.
gfortran -o simple discrete.f -lpgplot -IX11
discrete.f is the name of the file. So this works when I run it from the console. However, I want to run the code in the eclipse photran plugin so that I can use the debugger so that I can step through the code and observe some of the variables. I tried to put the -lpgplot and -IX11 flags in Eclipse, but I am getting errors about pgbbuf and pgnumb_ functions as undefined reference (which means that the -lpgplot function is not working when called from eclipse.
Can anyone please tell me how to set the flags correctly to run this code in Photran so that I can compile it and see the pgplot figure come up?
I am adding the console output:
02:57:05 **** Clean-only build of configuration Debug for project burglar_code_martin ****
make clean
rm -rf ./burglary_model.o burglar_code_martin
02:57:05 Build Finished (took 61ms)
02:57:05 **** Build of configuration Debug for project burglar_code_martin ****
make all
Building file: ../burglary_model.f
Invoking: GNU Fortran Compiler
gfortran -funderscoring -I/usr/lib -O0 -g -Wall -c -fmessage-length=0 -lpgplot -IX11 -o "burglary_model.o" "../burglary_model.f"
Warning: Nonconforming tab character in column 1 of line 225
Warning: Nonconforming tab character in column 1 of line 228
../burglary_model.f:155.27:
call probcheck(frac,1,outc)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:54.33:
call probcheck(robprob,1,outcome)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:95.30:
call probcheck(placeprob,1,outcome)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:206.36:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'burgsatloc' at (1)
../burglary_model.f:206.44:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'pic' at (1)
../burglary_model.f:206.51:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'screen' at (1)
../burglary_model.f:145.32:
integer l,pic,screen,i,j,k,PGOPEN,burgsatloc(512,*),nbar,outc
1
Warning: Unused variable 'k' declared at (1)
../burglary_model.f:146.15:
real rand,red,green,blue
1
Warning: Unused variable 'rand' declared at (1)
../burglary_model.f:143.53:
subroutine initialize(burgsatloc,B,l,pic,screen,rbar,Bbar)
1
Warning: Unused dummy argument 'screen' at (1)
../burglary_model.f:4.58:
integer i,j,n,l,pic,screen,guy,burgsatloc(512,512),k,
1
Warning: Unused variable 'k' declared at (1)
Finished building: ../burglary_model.f
Building target: burglar_code_martin
Invoking: GNU Fortran Linker
gfortran -lpgplot -IX11 -o "burglar_code_martin" ./burglary_model.o
./burglary_model.o: In function `output_':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:241: undefined reference to `pgbbuf_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:242: undefined reference to `pgnumb_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:244: undefined reference to `pgenv_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:246: undefined reference to `pglab_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:247: undefined reference to `pgimag_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:253: undefined reference to `pgebuf_'
./burglary_model.o: In function `initialize_':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:165: undefined reference to `pgopen_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:168: undefined reference to `pgpap_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:169: undefined reference to `pgask_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:170: undefined reference to `pgscir_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:175: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:181: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:187: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:193: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:199: undefined reference to `pgscr_'
./burglary_model.o: In function `implicit':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:109: undefined reference to `pgclos_'
collect2: ld returned 1 exit status
make: *** [burglar_code_martin] Error 1
02:57:05 Build Finished (took 209ms)

Perl Cross Compilation: MAKE

I've been trying to Cross Compile Perl-5.14.2 for NetBSD target from Linux machine.
Configure script successfully invoked with following options,
./Configure -des -Dusecrosscompile
-Dtargetarch=netbsd
-Dosvers=3.0.0
-Dtargethost=10.184.22.48
-Dtargetuser=username
-Dusrinc=.../sb1-mips/usr/include
-Dlibpth=.../xc-sb1-mips/netbsd/Lib/lib
-Dcc=.../mips64-netbsdelf-gcc
Once after Configured, make wasn't successful.
It breaks at different places right from creating miniperlmain.o file.
For example following error occurred while generating gv.o file:
gv.c: In function `Perl_try_amagic_un':
gv.c:2018: error: void value not ignored as it ought to be
gv.c:2029: error: void value not ignored as it ought to be
gv.c:2029: warning: cast from pointer to integer of different size
gv.c: In function `Perl_try_amagic_bin':
gv.c:2061: error: void value not ignored as it ought to be
gv.c:2063: error: void value not ignored as it ought to be
make: *** [gv.o] Error 1
Now to get rid of these errors I've passed two flags namely -DPERL_IMPLICIT_CONTEXT and -DPERL_GCC_BRACE_GROUPS_FORBIDDEN to C Compiler CCFLAGS which solved the problem.
Since it is a custom build, want to know about all of the CCFLAGS that have to be passed in order to achieve a successful build?
What does each flag mean?
Is their any documentation available?
Use vagrant. It has some OpenBSD and FreeBSD images. Hopefuly those will be compatible with NetBSD.
You can get a build environment very fast with that. Then you can transfer and build your code happily :)