You have to split linker and compiler options
your compiler options:
-std=c++11
-I /usr/local/MATLAB/R2021a/extern/include/
the linker options:
-L /usr/local/MATLAB/R2021a/extern/bin/glnxa64/
-lMatlabDataArray
-lMatlabEngine
In Project->Build options->Select your project name on the left->Compiler settings->Compiler flags-> Tick the c++11 flag
In Project->Build options->Select your project name on the left->Search directories->Compiler->Add-> "/usr/local/MATLAB/R2021a/extern/include/"
In Project->Build options->Select your project name on the left->Search directories->Linker->Add-> "/usr/local/MATLAB/R2021a/extern/bin/glnxa64/"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabDataArray"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabEngine"
In Project->Build options->Select your project name on the left->Linker settings->Other options-> "-pthread"