[Create mexfunction from C code] The order of several c files

조회 수: 2 (최근 30일)
shdotcom shdotcom
shdotcom shdotcom 2019년 9월 19일
편집: James Tursa 2023년 4월 18일
I have a c source code that consists of several .c files. How can I know the orders of these files when I build the mex function?
for example:
mex mainFun.c X.c Y.c Z.c
This is the source code:
I have got this error "Error using mex D:\TestMexFunction\unix_timer.c:22:26: fatal error: sys/resource.h: No such file or directory #include <sys/resource.h> ^
compilation terminated." when I run:
mex mainFun.c ants.c parse.c TSP.c dos_timer.c InOut.c ls.c unix_timer.c utilities.c
mainFun.c includes the mexFunction()
acotsp.c includes the main() function
Is it because of the order of c files or another reason?

답변 (2개)

James Tursa
James Tursa 2019년 9월 20일
편집: James Tursa 2023년 4월 18일
The order you compile your source code files should not matter (other than the fact that the mex function name will be based on the first file listed unless you override that). The error seems to be that the compiler can't find the resource.h file.
  댓글 수: 2
shdotcom shdotcom
shdotcom shdotcom 2019년 9월 20일
Yes it is a compiler problem, I have tried to run the C code alone with MinGW compiler and I got same problem with resource.h. MinGW does not have <sys/resource.h>
when I change to cygwin64 it works. However, Matlab does not support cygwin compiler. what I should do in this case?
shdotcom shdotcom
shdotcom shdotcom 2019년 9월 20일
Yes it is a compiler problem, I have tried to run the C code alone with MinGW compiler and I got same problem with resource.h. MinGW does not have <sys/resource.h>
when I change to cygwin64 it works. However, Matlab does not support cygwin compiler. what I should do in this case?

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


shdotcom shdotcom
shdotcom shdotcom 2019년 9월 20일
편집: shdotcom shdotcom 2019년 9월 20일
I have solved the problem by modifying the C code (by removing resource.h)

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by