{"action":"created","issue":{"url":"https://api.github.com/repos/kyamagu/mexopencv/issues/303","repository_url":"https://api.github.com/repos/kyamagu/mexopencv","labels_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/303/labels{/name}","comments_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/303/comments","events_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/303/events","html_url":"https://github.com/kyamagu/mexopencv/issues/303","id":195480794,"number":303,"title":"Undef reference to mxArray:toString()","user":{"login":"jdeeee","id":24564020,"avatar_url":"https://avatars.githubusercontent.com/u/24564020?v=3","gravatar_id":"","url":"https://api.github.com/users/jdeeee","html_url":"https://github.com/jdeeee","followers_url":"https://api.github.com/users/jdeeee/followers","following_url":"https://api.github.com/users/jdeeee/following{/other_user}","gists_url":"https://api.github.com/users/jdeeee/gists{/gist_id}","starred_url":"https://api.github.com/users/jdeeee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdeeee/subscriptions","organizations_url":"https://api.github.com/users/jdeeee/orgs","repos_url":"https://api.github.com/users/jdeeee/repos","events_url":"https://api.github.com/users/jdeeee/events{/privacy}","received_events_url":"https://api.github.com/users/jdeeee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-14T09:29:56Z","updated_at":"2016-12-14T12:27:52Z","closed_at":null,"body":"Hi!\r\n\r\nI am trying to build mexopencv. For this, I have downloaded OpenCV 3.1.0 from opencv.org and followed http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation to build it. It looked to be successful:\r\n\r\n``` sh\r\n$ pkg-config --cflags --libs opencv\r\n-I/usr/local/include/opencv\r\n-I/usr/local/include\r\n-L/usr/local/lib\r\n-lopencv_cudabgsegm\r\n-lopencv_cudaobjdetect\r\n-lopencv_cudastereo\r\n-lopencv_shape\r\n-lopencv_stitching\r\n-lopencv_cudafeatures2d\r\n-lopencv_superres\r\n-lopencv_cudacodec\r\n-lopencv_videostab\r\n-lopencv_cudaoptflow\r\n-lopencv_cudalegacy\r\n-lopencv_calib3d\r\n-lopencv_features2d\r\n-lopencv_objdetect\r\n-lopencv_highgui\r\n-lopencv_videoio\r\n-lopencv_photo\r\n-lopencv_imgcodecs\r\n-lopencv_cudawarping\r\n-lopencv_cudaimgproc\r\n-lopencv_cudafilters\r\n-lopencv_video\r\n-lopencv_ml\r\n-lopencv_imgproc\r\n-lopencv_flann\r\n-lopencv_cudaarithm\r\n-lopencv_viz\r\n-lopencv_core\r\n-lopencv_cudev\r\n```\r\n\r\nI then tried to build mexopencv with \r\n\r\n``` sh\r\n$ make MATLABDIR=/usr/local/MATLAB/R2016b/\r\n```\r\n\r\nwhich consistently tells me that my gcc version is 5.4.0 which is not supported. I therefore installed gcc and gpp 4.9 and tried\r\n\r\n``` sh\r\n$ make MATLABDIR=/usr/local/MATLAB/R2016b/ MEX=\"/usr/local/MATLAB/R2016b/bin/mex -v GCC=/usr/bin/gcc-4.9\"\r\n```\r\n\r\nThis produces the following:\r\n\r\n``` sh\r\n$ make MATLABDIR=/usr/local/MATLAB/R2016b/ MEX=\"/usr/local/MATLAB/R2016b/bin/mex -v GCC=/usr/bin/gcc-4.9\"\r\n/usr/local/MATLAB/R2016b/bin/mex -v GCC=/usr/bin/gcc-4.9 -largeArrayDims -cxx -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -output +cv/initCameraMatrix2D src/+cv/initCameraMatrix2D.cpp -Llib -lMxArray -L/usr/local/lib -lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_shape -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_cudacodec -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_calib3d -lopencv_features2d -lopencv_objdetect -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudawarping -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_video -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_cudaarithm -lopencv_viz -lopencv_core -lopencv_cudev   \r\nVerbose mode is on.\r\n... Looking for compiler 'g++' ...\r\n... Executing command 'which g++' ...Yes ('/usr/bin/g++').\r\n... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.so').\r\nFound installed compiler 'g++'.\r\nOptions file details\r\n-------------------------------------------------------------------\r\n\tCompiler location: /usr/bin/gcc-4.9\r\n\tOptions file: /home/meee/.matlab/R2016b/mex_C++_glnxa64.xml\r\n\tCMDLINE2 : /usr/bin/gcc-4.9 -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,\"/usr/local/MATLAB/R2016b/extern/lib/glnxa64/c_exportsmexfileversion.map\" /tmp/mex_389786248278256_15940/initCameraMatrix2D.o /tmp/mex_389786248278256_15940/cpp_mexapi_version.o   -lMxArray  -lopencv_cudabgsegm  -lopencv_cudaobjdetect  -lopencv_cudastereo  -lopencv_shape  -lopencv_stitching  -lopencv_cudafeatures2d  -lopencv_superres  -lopencv_cudacodec  -lopencv_videostab  -lopencv_cudaoptflow  -lopencv_cudalegacy  -lopencv_calib3d  -lopencv_features2d  -lopencv_objdetect  -lopencv_highgui  -lopencv_videoio  -lopencv_photo  -lopencv_imgcodecs  -lopencv_cudawarping  -lopencv_cudaimgproc  -lopencv_cudafilters  -lopencv_video  -lopencv_ml  -lopencv_imgproc  -lopencv_flann  -lopencv_cudaarithm  -lopencv_viz  -lopencv_core  -lopencv_cudev   -Llib  -L/usr/local/lib   -Wl,-rpath-link,/usr/local/MATLAB/R2016b/bin/glnxa64 -L\"/usr/local/MATLAB/R2016b/bin/glnxa64\" -lmx -lmex -lmat -lm -lstdc++ -o /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.mexa64\r\n\tCXX : /usr/bin/gcc-4.9\r\n\tDEFINES : -D_GNU_SOURCE -DMATLAB_MEX_FILE \r\n\tMATLABMEX : -DMATLAB_MEX_FILE \r\n\tCXXFLAGS : -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11\r\n\tINCLUDE : -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -I\"/usr/local/MATLAB/R2016b/extern/include\" -I\"/usr/local/MATLAB/R2016b/simulink/include\"\r\n\tCXXOPTIMFLAGS : -O -DNDEBUG\r\n\tCXXDEBUGFLAGS : -g\r\n\tLDXX : /usr/bin/gcc-4.9\r\n\tLDFLAGS : -pthread -Wl,--no-undefined \r\n\tLDTYPE : -shared\r\n\tLINKEXPORT : -Wl,--version-script,\"/usr/local/MATLAB/R2016b/extern/lib/glnxa64/mexFunction.map\"\r\n\tLINKEXPORTVER : -Wl,--version-script,\"/usr/local/MATLAB/R2016b/extern/lib/glnxa64/c_exportsmexfileversion.map\"\r\n\tLINKLIBS : -lMxArray  -lopencv_cudabgsegm  -lopencv_cudaobjdetect  -lopencv_cudastereo  -lopencv_shape  -lopencv_stitching  -lopencv_cudafeatures2d  -lopencv_superres  -lopencv_cudacodec  -lopencv_videostab  -lopencv_cudaoptflow  -lopencv_cudalegacy  -lopencv_calib3d  -lopencv_features2d  -lopencv_objdetect  -lopencv_highgui  -lopencv_videoio  -lopencv_photo  -lopencv_imgcodecs  -lopencv_cudawarping  -lopencv_cudaimgproc  -lopencv_cudafilters  -lopencv_video  -lopencv_ml  -lopencv_imgproc  -lopencv_flann  -lopencv_cudaarithm  -lopencv_viz  -lopencv_core  -lopencv_cudev   -Llib  -L/usr/local/lib   -Wl,-rpath-link,/usr/local/MATLAB/R2016b/bin/glnxa64 -L\"/usr/local/MATLAB/R2016b/bin/glnxa64\" -lmx -lmex -lmat -lm -lstdc++\r\n\tLDOPTIMFLAGS : -O\r\n\tLDDEBUGFLAGS : -g\r\n\tMWCPPLIB : \"/usr/local/MATLAB/R2016b/sys/os/glnxa64/libstdc++.so.6\"\r\n\tOBJEXT : .o\r\n\tLDEXT : .mexa64\r\n\tSETENV : CXX=\"/usr/bin/gcc-4.9\"\r\nCXXFLAGS=\"-ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -D_GNU_SOURCE -DMATLAB_MEX_FILE \"\r\nCXXOPTIMFLAGS=\"-O -DNDEBUG\"\r\nCXXDEBUGFLAGS=\"-g\"\r\nLDXX=\"/usr/bin/gcc-4.9\"\r\nLDFLAGS=\"-pthread -Wl,--no-undefined  -shared -lMxArray  -lopencv_cudabgsegm  -lopencv_cudaobjdetect  -lopencv_cudastereo  -lopencv_shape  -lopencv_stitching  -lopencv_cudafeatures2d  -lopencv_superres  -lopencv_cudacodec  -lopencv_videostab  -lopencv_cudaoptflow  -lopencv_cudalegacy  -lopencv_calib3d  -lopencv_features2d  -lopencv_objdetect  -lopencv_highgui  -lopencv_videoio  -lopencv_photo  -lopencv_imgcodecs  -lopencv_cudawarping  -lopencv_cudaimgproc  -lopencv_cudafilters  -lopencv_video  -lopencv_ml  -lopencv_imgproc  -lopencv_flann  -lopencv_cudaarithm  -lopencv_viz  -lopencv_core  -lopencv_cudev   -Llib  -L/usr/local/lib   -Wl,-rpath-link,/usr/local/MATLAB/R2016b/bin/glnxa64 -L\"/usr/local/MATLAB/R2016b/bin/glnxa64\" -lmx -lmex -lmat -lm -lstdc++ -Wl,--version-script,\"/usr/local/MATLAB/R2016b/extern/lib/glnxa64/mexFunction.map\"\"\r\nLDDEBUGFLAGS=\"-g\"\r\n\tGCC : /usr/bin/gcc-4.9\r\n\tCPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.so\r\n\tMATLABROOT : /usr/local/MATLAB/R2016b\r\n\tARCH : glnxa64\r\n\tSRC : /home/meee/Desktop/mexopencv/mexopencv/src/+cv/initCameraMatrix2D.cpp;/usr/local/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp\r\n\tOBJ : /tmp/mex_389786248278256_15940/initCameraMatrix2D.o;/tmp/mex_389786248278256_15940/cpp_mexapi_version.o\r\n\tOBJS : /tmp/mex_389786248278256_15940/initCameraMatrix2D.o /tmp/mex_389786248278256_15940/cpp_mexapi_version.o \r\n\tSRCROOT : /home/meee/Desktop/mexopencv/mexopencv/src/+cv/initCameraMatrix2D\r\n\tDEF : /tmp/mex_389786248278256_15940/initCameraMatrix2D.def\r\n\tEXP : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.exp\r\n\tLIB : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.lib\r\n\tEXE : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.mexa64\r\n\tILK : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.ilk\r\n\tMANIFEST : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.mexa64.manifest\r\n\tTEMPNAME : /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D\r\n\tEXEDIR : /home/meee/Desktop/mexopencv/mexopencv/+cv/\r\n\tEXENAME : initCameraMatrix2D\r\n\tOPTIM : -O -DNDEBUG\r\n\tLINKOPTIM : -O\r\n\tCMDLINE1_0 : /usr/bin/gcc-4.9 -c -D_GNU_SOURCE -DMATLAB_MEX_FILE  -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -I\"/usr/local/MATLAB/R2016b/extern/include\" -I\"/usr/local/MATLAB/R2016b/simulink/include\" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG /home/meee/Desktop/mexopencv/mexopencv/src/+cv/initCameraMatrix2D.cpp -o /tmp/mex_389786248278256_15940/initCameraMatrix2D.o\r\n\tCMDLINE1_1 : /usr/bin/gcc-4.9 -c -D_GNU_SOURCE -DMATLAB_MEX_FILE  -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -I\"/usr/local/MATLAB/R2016b/extern/include\" -I\"/usr/local/MATLAB/R2016b/simulink/include\" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG /usr/local/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp -o /tmp/mex_389786248278256_15940/cpp_mexapi_version.o\r\n-------------------------------------------------------------------\r\nBuilding with 'g++'.\r\n/usr/bin/gcc-4.9 -c -D_GNU_SOURCE -DMATLAB_MEX_FILE  -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -I\"/usr/local/MATLAB/R2016b/extern/include\" -I\"/usr/local/MATLAB/R2016b/simulink/include\" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG /home/meee/Desktop/mexopencv/mexopencv/src/+cv/initCameraMatrix2D.cpp -o /tmp/mex_389786248278256_15940/initCameraMatrix2D.o\r\n/usr/bin/gcc-4.9 -c -D_GNU_SOURCE -DMATLAB_MEX_FILE  -Iinclude -I/usr/local/include/opencv -I/usr/local/include  -I\"/usr/local/MATLAB/R2016b/extern/include\" -I\"/usr/local/MATLAB/R2016b/simulink/include\" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG /usr/local/MATLAB/R2016b/extern/version/cpp_mexapi_version.cpp -o /tmp/mex_389786248278256_15940/cpp_mexapi_version.o\r\n/usr/bin/gcc-4.9 -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,\"/usr/local/MATLAB/R2016b/extern/lib/glnxa64/c_exportsmexfileversion.map\" /tmp/mex_389786248278256_15940/initCameraMatrix2D.o /tmp/mex_389786248278256_15940/cpp_mexapi_version.o   -lMxArray  -lopencv_cudabgsegm  -lopencv_cudaobjdetect  -lopencv_cudastereo  -lopencv_shape  -lopencv_stitching  -lopencv_cudafeatures2d  -lopencv_superres  -lopencv_cudacodec  -lopencv_videostab  -lopencv_cudaoptflow  -lopencv_cudalegacy  -lopencv_calib3d  -lopencv_features2d  -lopencv_objdetect  -lopencv_highgui  -lopencv_videoio  -lopencv_photo  -lopencv_imgcodecs  -lopencv_cudawarping  -lopencv_cudaimgproc  -lopencv_cudafilters  -lopencv_video  -lopencv_ml  -lopencv_imgproc  -lopencv_flann  -lopencv_cudaarithm  -lopencv_viz  -lopencv_core  -lopencv_cudev   -Llib  -L/usr/local/lib   -Wl,-rpath-link,/usr/local/MATLAB/R2016b/bin/glnxa64 -L\"/usr/local/MATLAB/R2016b/bin/glnxa64\" -lmx -lmex -lmat -lm -lstdc++ -o /home/meee/Desktop/mexopencv/mexopencv/+cv/initCameraMatrix2D.mexa64\r\n/tmp/mex_389786248278256_15940/initCameraMatrix2D.o: In function 'mexFunction':\r\ninitCameraMatrix2D.cpp:(.text+0x2bf4): undefined reference to 'MxArray::toString() const'\r\ncollect2: error: ld returned 1 exit status\r\n\r\nMakefile:171: recipe for target '+cv/initCameraMatrix2D.mexa64' failed\r\nmake: *** [+cv/initCameraMatrix2D.mexa64] Error 255\r\n```\r\n\r\nWhat could be the cause of this?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/kyamagu/mexopencv/issues/comments/267021726","html_url":"https://github.com/kyamagu/mexopencv/issues/303#issuecomment-267021726","issue_url":"https://api.github.com/repos/kyamagu/mexopencv/issues/303","id":267021726,"user":{"login":"amroamroamro","id":83908,"avatar_url":"https://avatars.githubusercontent.com/u/83908?v=3","gravatar_id":"","url":"https://api.github.com/users/amroamroamro","html_url":"https://github.com/amroamroamro","followers_url":"https://api.github.com/users/amroamroamro/followers","following_url":"https://api.github.com/users/amroamroamro/following{/other_user}","gists_url":"https://api.github.com/users/amroamroamro/gists{/gist_id}","starred_url":"https://api.github.com/users/amroamroamro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amroamroamro/subscriptions","organizations_url":"https://api.github.com/users/amroamroamro/orgs","repos_url":"https://api.github.com/users/amroamroamro/repos","events_url":"https://api.github.com/users/amroamroamro/events{/privacy}","received_events_url":"https://api.github.com/users/amroamroamro/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T12:27:52Z","updated_at":"2016-12-14T12:27:52Z","body":"@jdeeee \r\nI think you are using the wrong version.. You say you built OpenCV 3.1.0, but the libs listed in the output of `pkg-config` are those of OpenCV 2.x not 3.x! Also make sure you are on the right branch of mexopencv as well..\r\n\r\nI suggest you start again and use our guide to build opencv/opencv_contrib and mexopencv:\r\nhttps://github.com/kyamagu/mexopencv/wiki/Installation-%28Linux%2C-MATLAB%2C-OpenCV-3%29\r\n\r\nTo avoid any confusion, I would also remove any previous installations of opencv you had (either manually built or installed with `apt-get`).\r\n\r\nFinally I suggest you use `update-alternatives` if you are switching between multiple versions of gcc/g++. As kyamagu mentioned, check that you are using the same compiler for building both (opencv and mexopencv).\r\n\r\nIf you later get problems with conflicting libraries at runtime, refer to https://github.com/kyamagu/mexopencv/wiki/Troubleshooting-%28UNIX%29 for possible solutions using preloading.\r\n"}}
{"actor":{"display_login":"amroamroamro"}}