Matlab Coder: No rule to make target c_mexapi_version.o

Hey everybody! I'm trying to convert a time-costly loop I have into a MEX file that I can call from the rest of my MATLAB function, but I'm having trouble compiling it.
I get the following printouts when trying to compile it:
------------------------------------------------------------------------
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "run_trials_data.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "run_trials_initialize.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "run_trials_terminate.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "run_trials.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "normrnd.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "indexShapeCheck.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "interface/_coder_run_trials_info.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "interface/_coder_run_trials_api.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "interface/_coder_run_trials_mex.c"
gcc -c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700 -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE -g -I "D:\Program Files\MATLAB\R2017a/simulink/include" -I "D:\Program Files\MATLAB\R2017a/toolbox/shared/simtargets" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base\codegen\mex\run_trials" -I "D:\Users\Andrew\Google Drive\UCSB\Computational Cognitive Neuroscience Research\Development Code Base" -I ".\interface" -I "D:\Program Files\MATLAB\R2017a\extern\include" -I "." "run_trials_emxutil.c"
gmake: *** No rule to make target `c_mexapi_version.o', needed by `run_trials_mex.mexw64'. Stop.
------------------------------------------------------------------------
I used the Matlab Coder application to automatically generate a build script, which invokes the following command that causes this error:
%%Invoke MATLAB Coder.
codegen -config cfg run_trials -args ARGS{1}
I'd appreciate pointers as to how to fix this make issue. Thanks!

5 comentarios

I would expect to see a line calling GCC on the file:
MATLABROOT\extern\version\c_mexapi_version.c
This sounds like either something may be missing from your installation or there may be an issue in the Makefile that Coder produced.
Two possible debugging steps:
1. What is the output of:
ls([matlabroot '/extern/version/'])
from inside your MATLAB installation? Mine shows:
>> ls([matlabroot '/extern/version/'])
c_mexapi_version.c cpp_mexapi_version.cpp fortran_mexapi_version.F
2. Can you ZIP or TAR your entire codegen directory and attach it here? That may give us a clue as to what happened.
Beyond that, I'd recommend getting in touch with technical support since we'll possibly need to check several things on your system to isolate the issue.
Andrew Tran
Andrew Tran el 17 de Mzo. de 2017
Editada: Andrew Tran el 17 de Mzo. de 2017
Hey Ryan, thanks for your response!
1. I get similar output running that command.
>> ls([matlabroot '/extern/version/'])
. .. c_mexapi_version.c cpp_mexapi_version.cpp fortran_mexapi_version.F
2. I have also attached a ZIP of my codegen directory (I assumed you meant the one generated by the script) as codegen.zip.
OK that helps. If you look at the file run_trials_mex.mk you'll notice that c_mexapi_version.c is indeed in the source files SRC_FILES.
However, you'll notice that MATLAB_ROOT and START_DIR both have spaces in them:
D:\Program Files\MATLAB\R2017a
Coder typically uses the Windows short name (like C:\PROGRA~1\MATLAB\R2017a) to avoid issues with Makefiles and spaces in paths but such names can be disabled. My theory is that this is why the file from MATLABROOT isn't matching the targets further down in the file.
This answer:
describes the situation in great detail for Simulink and gives steps to enable short names if possible. It also gives workarounds if doing so isn't possible.
Hey Ryan, following the first suggestion on the solution list of manually creating a short name fixed my problem! It now compiles (and I believe runs properly). Thanks for your help!
Ryan: Andrew suggests moving your comment into an Answer so that Andrew can Accept it as the solution.

Iniciar sesión para comentar.

 Respuesta aceptada

Ryan Livingston
Ryan Livingston el 20 de Mzo. de 2017
Editada: Ryan Livingston el 8 de Mayo de 2017
Edit
A bug report:
has been published for this issue that includes a patch for MATLAB R2017a. It is recommended to install that patch to resolve this.
Original Answer with Manual Fix
If you look at the file run_trials_mex.mk you'll notice that c_mexapi_version.c is indeed in the source files SRC_FILES.
However, you'll notice that MATLAB_ROOT and START_DIR both have spaces in them:
D:\Program Files\MATLAB\R2017a
Coder typically uses the Windows short name (like C:\PROGRA~1\MATLAB\R2017a) to avoid issues with Makefiles and spaces in paths but such names can be disabled. My theory is that this is why the file from MATLABROOT isn't matching the targets further down in the file.
This answer:
describes the situation in great detail for Simulink and gives steps to enable short names if possible. It also gives workarounds if doing so isn't possible.

Más respuestas (0)

Categorías

Más información sobre Language Fundamentals en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 17 de Mzo. de 2017

Editada:

el 8 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by