mex - including external object or lib fails

1 view (last 30 days)
Tobi
Tobi on 17 Jan 2014
Commented: Tobi on 17 Jan 2014
Hello,
im trying to compile a simple c code with mex. In principle this works with:
mex MyCore.c
but if i add a function call tests() in the c file which is defined in a external object file than i run into problems.
versuch.c :
void tests(void){ }
versuch.h:
void tests(void);
and compiling it external with gcc: gcc -c -o versuch.o versuch.c
works so far...
but if i try to add generated object file on Matlab:
mex MyCore.c versuch.o
i get:
*_File versuch.o contains unknown section /4
.text section assumed
File versuch.o contains unknown section /15.
.text section assumed
Relocation out of range!
Link failed. Removing MyCore.mexw32_*
I would prefer to include an external lib but this also wont work
with: ar rcs libversuch.a versuch.o
but there seems to be no way to include an ".s" file into mex... it always is looking for a lib file
In the end i will egt a lib file "libTarget.lib"
I tried to include that one by:
mex MyCore.c -L. -llibTarget
by there I also get:
|File libTarget.lib contains unknown section /4.
.text section assumed
File libTarget.lib contains unknown section /15.
.text section assumed
Relocation out of range!
Link failed. Removing MyCore.mexw32|
mex seems to expect a special format in libs .. but is there no way to include external libs to my c-mex file?
Please help THX! Tobi
  2 Comments
Titus Edelhofer
Titus Edelhofer on 17 Jan 2014
Just for clarification: are you using gcc on a Windows machine? Why not use the lcc that comes with MATLAB?
Tobi
Tobi on 17 Jan 2014
normally i will get the library from third party.. that is most likely compiled with gcc then.

Sign in to comment.

Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!