How to change link.exe when compiling mex-file?

조회 수: 3 (최근 30일)
Henri Hämäläinen
Henri Hämäläinen 2022년 9월 30일
답변: Henri Hämäläinen 2022년 10월 17일
Starting point:
I have a makefile that compiles C-source code to object files and also links them and compiles the mex-file. Matlab testbench is used to run the mex-file to test the C-code.
Desired action:
I want to have BullseyeCoverage software integrated to check the test coverage of the C-source files.
Current situation:
The BullseyeCoverage software doesn't recognize the compilations automatically, so I have tried to invoke the Bullseye cl.exe and link.exe in the makefile. The cl.exe I managed to invoke, but the link.exe I cannot. I think what I need to do atleast is change the linker that the mex-compiler uses, but I don't know how. I might be on the wrong trail here altogether, but this is what I have come up with so far.
Any advice on how to achieve the linker change, or preferrably the whole Bullseye integration, would be much appreciated!

채택된 답변

Henri Hämäläinen
Henri Hämäläinen 2022년 10월 17일
I found a working solution myself.
Object compilation needs to be done by having both Bullseye\bin and Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64 in PATH, and calling the compiler simply with cl.
Mex file compilation needed two compilation options to be added for the call. So, in the mex compilation call, I just added options COMPILER="cl" and LINKER="covc link".

추가 답변 (1개)

Vijay
Vijay 2022년 10월 14일
ld command is used to link object files together and produce executable. Linker is also part of compiler executable.
Since you are using custom make file you can generate object files first and then you can use ld command to generate final executable.Please make sure ld is available on your PATH.
  댓글 수: 1
Henri Hämäläinen
Henri Hämäläinen 2022년 10월 17일
Thanks for the answer! Maybe the solution with ld could also have worked. However, I was able to make this work by having Bullseye\bin in my PATH and calling cl.exe in the makefile for both object and mex compilation. And more importantly regarding the link call issue, the mex compilation needed to have two flags added to the command: COMPILER="cl" LINKER="covc link". This way I got the files linked.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Troubleshooting in MATLAB Compiler SDK에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by