From: Kevin Ostheimer on
The source code is very simple but causes a linker error...

*********************************************************
#include <stdio.h>
#include <stdlib.h>
#include <engine.h>

int main(void)
{
Engine *ep;
ep=engOpen(NULL);
engClose(ep);
system("PAUSE");
return;
}
*********************************************************

- Matlabworkspace set to C-Code Workspace
- MATLAB Version 7.1.0.124 (R14) Service Pack 3
!!!But I get a Linker error although everything is successfully
included:
[Linker error] undefined reference to `engOpen'

*********************************************************
EDU>> dir

.. interface.dev interface_private.res
... interface.layout main.c
MATLAB For C interface_private.h main.o
Makefile.win interface_private.rc
*********************************************************

Please help a student... thank you!
From: Titus Edelhofer on
Hi Kevin,
the includes are for compilation. For successful linking you
need to add the library to the call of the linker.
How do you call the compiler/linker?

Titus

"Kevin Ostheimer" <info(a)impulsleistung.de> schrieb im Newsbeitrag
news:ef411d0.-1(a)webcrossing.raydaftYaTP...
> The source code is very simple but causes a linker error...
>
> *********************************************************
> #include <stdio.h>
> #include <stdlib.h>
> #include <engine.h>
>
> int main(void)
> {
> Engine *ep;
> ep=engOpen(NULL);
> engClose(ep);
> system("PAUSE");
> return;
> }
> *********************************************************
>
> - Matlabworkspace set to C-Code Workspace
> - MATLAB Version 7.1.0.124 (R14) Service Pack 3
> !!!But I get a Linker error although everything is successfully
> included:
> [Linker error] undefined reference to `engOpen'
>
> *********************************************************
> EDU>> dir
>
> . interface.dev interface_private.res
> .. interface.layout main.c
> MATLAB For C interface_private.h main.o
> Makefile.win interface_private.rc
> *********************************************************
>
> Please help a student... thank you!


From: Kevin Ostheimer on
I work with the Dev-C++ Platform under WindowsXP. MingW is the
Compiler running in background.

I set the path: "C:\Programme\MATLAB_SV71\extern\include" as
Reference to all header files.

So !ONLY! the files in the upper directory are included.

What path?s else do I have to include?
From: Titus Edelhofer on
Hi Kevin,
it's not the compiler complaining about missing include
files, it's the linker complaining about missing libraries.
Take a look at the help for External Interfaces,
Calling MATLAB from C, and then
Compiling and Linking.
But I guess you will have another problem, because I
don't think MingW is a supported compiler...?

Titus

"Kevin Ostheimer" <info(a)impulsleistung.de> schrieb im Newsbeitrag
news:ef411d0.1(a)webcrossing.raydaftYaTP...
>I work with the Dev-C++ Platform under WindowsXP. MingW is the
> Compiler running in background.
>
> I set the path: "C:\Programme\MATLAB_SV71\extern\include" as
> Reference to all header files.
>
> So !ONLY! the files in the upper directory are included.
>
> What path?s else do I have to include?


From: Michael Wild on
On Tue, 19 Sep 2006 05:54:47 -0400, Kevin Ostheimer wrote:

> The source code is very simple but causes a linker error...
> [...]
>
> - Matlabworkspace set to C-Code Workspace
> - MATLAB Version 7.1.0.124 (R14) Service Pack 3
> !!!But I get a Linker error although everything is successfully
> included:
> [Linker error] undefined reference to `engOpen'
> [...]

as titus said, you will have to link the matlab engine library. most
likely you will have to include somethin like this in the linking stage:

-L/path/to/engine -leng

-L instructs the compiler to add the specified path to the search
directories (it should be something like $matlabroot/bin/$arch where
$matlabroot is the installation directory of matlab and $arch is the
architecture.

-l instructs to link the engine library (probably called eng.dll on
windows, i don't really know. on linux it is called libeng.so).

if you don't have a separate linking stage, add the line to your last
compiler command.


@titus: afaik the mingw compiler is a windows port of gcc, so it should
work.


michael
 |  Next  |  Last
Pages: 1 2
Prev: QAM matlab code
Next: Interfacing Matlab in C-Code