Mex: C2Matlab coding. Problems with libraries while linking (error LNK2019)

3 views (last 30 days)
Hi everybody!
This is my first question at MATLAB community. It's about mex. Here I go:
I'm integrating an external procedures for using a digital IO card using mex. The problem is that while I try to compile and link the code I get the error LNK2019.
I call the mex compiler/linker as:
if true
mex -win64 -v -g -lWDT_DIO64.lib pruebaargumentos.cpp % code
end
After that I get:
if true
pruebaargumentos.obj : error LNK2019: unresolved external symbol InitDIO referenced in function mexFunction
pruebaargumentos.mexw64 : fatal error LNK1120: 1 unresolved externals % code
end
The library is at the same path my cpp program is. I've included the header but anyway I get this error.
With the option -c I got the .obj file without a problem so the only thing that remain is linking it to the library (I hope).
  4 Comments

Sign in to comment.

Accepted Answer

Jan
Jan on 31 Jul 2013
Try to use full paths for the file name of the library. If this works, there was a problem with finding the file in the LIBPATH. See -L argument for mex.
  1 Comment
Julio Ortega
Julio Ortega on 31 Jul 2013
I just checked what you told me and I found that:
You where right. I only need to ad the correct path with -L and also the name of the library with -l (excluding the extension .lib) at the end it looks:
mex -win64 -v -LC:\Users\Julio\Documents\MATLAB\ConsoleApplication1 -lWDT_DIO64 pruebaargumentos.cpp
It's solved the compilation problem. Thanks Jan!

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!