How to handle this problem in MS VC++

C

Cris Ding

Hi, everyone,

Suppose the following simple program:

#include "engine.h"

int main()
{
Engine *ep;

if (!(ep = engOpen(NULL))) {
printf("Can't start MATLAB engine");
exit(-1);
}

engClose(ep);
return(0);
}

When I was trying to compile and link the program:

Linking...
engwindemo.obj : error LNK2001: unresolved external symbol _engClose
engwindemo.obj : error LNK2001: unresolved external symbol _engOpen
Debug/engwindemo.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

engwindemo.exe - 3 error(s), 0 warning(s)

Then I found "engClose" and "engOpen" are defined in "liben.def",
which in turn is directed to "libeng.dll" as indicated by the
following information.

LIBRARY libeng.dll
EXPORTS
_engClose=engClose
....
_engOpen=engOpen
....
_libeng_build_date=libeng_build_date
_libeng_version=libeng_version

I added all these two files into the project, but still the linking
error information appears. I wonder whether I have put the
"libeng.dll" into a wrong directory, that is, I should not add
"libeng.dll" into the project, but put it into some other proper
directory instead so that MS VC++ can find it when linking. Could
anyone give me some hints on this? Thanks a lot.

VB
/Cris
 
J

Joona I Palaste

Cris Ding said:
Hi, everyone,
Suppose the following simple program:
#include "engine.h"
int main()
{
Engine *ep;
if (!(ep = engOpen(NULL))) {
printf("Can't start MATLAB engine");
exit(-1);
}

When I was trying to compile and link the program:
Linking...
engwindemo.obj : error LNK2001: unresolved external symbol _engClose
engwindemo.obj : error LNK2001: unresolved external symbol _engOpen
Debug/engwindemo.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
engwindemo.exe - 3 error(s), 0 warning(s)
Then I found "engClose" and "engOpen" are defined in "liben.def",
which in turn is directed to "libeng.dll" as indicated by the
following information.

You'll want to link the "libeng.dll" library. How to do this is none
of comp.lang.c's business, as it's specific to MSVC++.
 
M

Mark McIntyre

Then I found "engClose" and "engOpen" are defined in "liben.def",
which in turn is directed to "libeng.dll" as indicated by the
following information.

This would be a Windows question. You need to ask it over there.

(by the way the function's runtime code may be in the DLL but you still
need a .lib file to link with, unless you're doing /real/ dynamic loading,
which you're not. The .lib contains the stub loader for the DLL code).
 
R

Rob Thorpe

Hi, everyone,

Suppose the following simple program:

#include "engine.h"

int main()
{
Engine *ep;

if (!(ep = engOpen(NULL))) {
printf("Can't start MATLAB engine");
exit(-1);
}

engClose(ep);
return(0);
}

When I was trying to compile and link the program:

Linking...
engwindemo.obj : error LNK2001: unresolved external symbol _engClose
engwindemo.obj : error LNK2001: unresolved external symbol _engOpen
Debug/engwindemo.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

engwindemo.exe - 3 error(s), 0 warning(s)

Then I found "engClose" and "engOpen" are defined in "liben.def",
which in turn is directed to "libeng.dll" as indicated by the
following information.

LIBRARY libeng.dll
EXPORTS
_engClose=engClose
...
_engOpen=engOpen
...
_libeng_build_date=libeng_build_date
_libeng_version=libeng_version

I added all these two files into the project, but still the linking
error information appears. I wonder whether I have put the
"libeng.dll" into a wrong directory, that is, I should not add
"libeng.dll" into the project, but put it into some other proper
directory instead so that MS VC++ can find it when linking. Could
anyone give me some hints on this? Thanks a lot.

VB
/Cris


Ask comp.os.ms-windows.programmer and comp.soft-sys.matlab, they are
likely to know more.
 
Joined
Jul 22, 2009
Messages
1
Reaction score
0
libraries

May be the problem is linking libraries, look at this solution.
www
mathworks.com
/support/solutions/data/1-30UM5H.html?product=ML&solution=1-30UM5H
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top