0

I'm compiling a code with many files and some are located in the local MATLAB installation folder. For this I've added an include to g++ which apparently doesn't resolve well because I get an undefined reference to for all MATLAB-C++ functions (I'm trying to use the MATLAB C++ Engine) as shown in the following screenshot:

enter image description here The Makefile is very short and as such:

enter image description here

I've checked the referenced directory and it does include the "Engine.h" referenced by constraints.cpp which is generally enough to execute the MATLAB-C++ engine functions.

Any ideas as to where this problem could come from?

Alexis R Devitre
  • 288
  • 2
  • 6
  • 21

1 Answers1

2

You need to link with the MATLIB library files. Your code is referencing them, but the linker doesn't know what they are.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
  • mmm, excuse my ignorance, linking refers to the "-L ****" syntax (which I though meant library) or something like "-leng" "-lmx"? I used to have those in a priori version of the Makefile I used on my computer but at some point i was told by the compiler that it was not using them or something like that. – Alexis R Devitre Feb 24 '16 at 05:34
  • @AlexisRustamDevitre You need a -L with the path to the folder that holds the MATLAB library files. – 1201ProgramAlarm Feb 24 '16 at 05:38
  • @1201ProgramAlarm **-L** just adds a search directory for library finding. **-I** adds a search directory for finding includes in sources. **-l** (notice the small L), followed by the library name, instructs the linkage. – Youka Feb 24 '16 at 06:08
  • @1201ProgramAlarm so I need the **-L** with the location (which is what I've put in the update) and the **-l** with "eng" and "mex" which are the actual library file calls? Is that it?... Just tried it and.... I think it settles it... could you just confirm my interpretation of what you said... I'd be interested to know wether it's the right idea or not. – Alexis R Devitre Feb 24 '16 at 06:16