'File format not recognized" using mex

2 views (last 30 days)
Vytautas Valaitis
Vytautas Valaitis on 21 Jul 2020
Answered: Nipun Katyal on 14 Aug 2020
Hi,
I'm trying to create a mex executable to a file that uses a linker to a library "libraryname", where libraryname.lib is a linker that I created on my machine using "lib" function from VC++. Everything works well when I run mex on the same machine that was used to create the .lib file. Now I want to run this on the cluster, but there I cannot create a new .lib file, so I need to use the .lib file that I created on my computer. When I run the same mex command on the cluster machine I get the following error:
Command:
mex source_code.c libraryname.lib
error:
/usr/bin/ld: libraryname.lib(libraryname.dll): Recognised but unhandled machine
type (0x8664) in Import Library Format archive
libraryname.lib: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
I found a much older thread on a similar problem here, but I'm not sure if this is applicable to Matlab 2019b
Could anyone give a hint on how to resolve this?

Answers (1)

Nipun Katyal
Nipun Katyal on 14 Aug 2020
This problem occurs because the supported file type is .so/.dll and not .lib/.dll. If you want to tell the linker to link this library you should specify it in this format
mex source file<*.c> -L<path to the library> -lLibraryName
here is the link for usage.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!