0
votes

In my on my header file (pages.h), I've done:

#include "mat.h".  

In my cpp, all I'm trying to do is a simple:

MATFile *pmat.  

However, whenever I try to build my code, I get an error that says:

1>pages.obj : error LNK2019: unresolved external symbol _matOpen referenced in function "public: void __thiscall DataPage::LoadDBIData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadDBIData@DataPage@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

and

1>C:\Users\celes\source\repos\bci2000-svn\tools\P300Classifier_electrode_selection\P300Classifier_electrode_selection.exe : fatal error LNK1120: 1 unresolved externals

I've tried going into Properties->C/C++->General->Additional Include Directories and adding a file path of C:\Program Files (x86)\MATLAB\R2015b\extern\include", but I am still receiving the same error. Without this included path, I only received the second error, not the first one.

I am using Visual Studio 2010 (it's for an old research lab) and R2015b for MATLAB.

Any sort of help would be appreciated!

2
I think you forgot to link to a library for matlib in your c++ project. - drescherjm
Yeah, I actually did get an error where they said I was missing libmat.dll, but I think that was related to my not downloading some tools. Thank you! - ccer

2 Answers

0
votes

The error message indicates that the compiler has trouble resolving the symbol. Apparently, you didn't set up the project correctly. Besides the "Additional Include Directories" option, you also need to set the library directory in the Linker-> Additional Library Directories for using an external library.

Because you are running a project in VS C++, you will need to have $(MATLABPATH)\extern\lib\<arch>\microsoft in that option, where $(MATLABPATH) is "C:\Program Files (x86)\MATLAB\R2015b" and the <arch> might be Win64 or Win32 depending on your target machine flag in your VS project (i.e. 32- or 64-bit).

0
votes

Firstly, you could check if you add C:\Program Files (x86)\MATLAB\R2015b\extern\include in Porperties->VC++ Directories-> Include Directories, C:\Program Files (x86)\MATLAB\R2015b\extern\lib\winXX\microsoft in Porperties->VC++ Directories->Library Directories.

Secondly, you could check if you add libmat.lib;ibeng.lib;libmx.lib in Porperties->Linker->Input->Additional Dependencies.

Finally, you could refer to Microsoft Docs about LNK2019 and LNK1120.