sys/times.h Compiling issue
10 次查看(过去 30 天)
显示 更早的评论
Hello
I was trying to compile a mex file and I got the following error
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
>> compileSparseCoLO
Compiling Libraries...Building with 'MinGW64 Compiler (C++)'.
Error using mex
In file included from
C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\mex\ccputime.cpp:26:0:
C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\mex\ccputime.h:28:23: fatal error:
sys/times.h: No such file or directory
#include <sys/times.h>
^
compilation terminated.
Error in compileSparseCoLO (line 81)
eval(command);
I'm not sure where is the problem and how to solve it. I would appreiate your help.
13 个评论
Abdelrahman Aldik
2021-8-31
I have created the sys file as well as the three h files and I have put them in the same directory as my project. Still, I got the same error.
Walter Roberson
2021-8-31
The code has a <> style #include. <> style #include does not look in the current directory, only on the include path. If the files are not stored in one of the standard include paths, then you will need to use the mex -I option to indicate the directory that has the sys folder inside it -- even if that is your project directory itself. For example,
mex -I. other arguments
the -I. means to treat . (current directory) as part of the include path -- base directories from which to try to find sys/times.h
Abdelrahman Aldik
2021-8-31
I executed
>> mex -I. -setup C++
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
>> compileSparseCoLO
and still got the same error. What should I do?
Abdelrahman Aldik
2021-8-31
I also have tried:
>> mex -I.(C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys) -setup C++
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
>> compileSparseCoLO
and still, got the same error!
Walter Roberson
2021-9-2
编辑:Walter Roberson
2021-9-2
compileSparseCoLO is a script. Edit in, and look near line 55 or so, where you will see an if/elseif series that starts with
if strcmp(computer, 'GLNXA64') && (MLVer(1) > 7 || (MLVer(1) == 7&& MLVer(2) > 2))
In the case of Windows, you need to find the "else" branch of that, which looks like
else % Mac, Windows or Solaris
which is then followed by
MexFlags = ' -O ';
Change that line to
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112"';
Abdelrahman Aldik
2021-9-2
Thanks alot for your reply. I managed to avoid tis error but I got the following error instead
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
>> compileSparseCoLO
Compiling Libraries...Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
done
Compiling mexForestConvert.cpp...Building with 'MinGW64 Compiler (C)'.
Error using mex
Cannot export mexFunction: symbol not defined
ccputime.obj:ccputime.cpp:(.text+0xd): undefined reference to `times(tms*)'
ccputime.obj:ccputime.cpp:(.text+0x3d): undefined reference to `gettimeofday(timeval*,
void*)'
collect2.exe: error: ld returned 1 exit status
Error in compileSparseCoLO (line 93)
eval(command);
Walter Roberson
2021-9-2
You probably also need to add -L and -l (lower-case L) options . -L to name the location to search for a DLL, and -l naming the DLL to search for (which would be the DLL containing the compiled implementation of times)
Abdelrahman Aldik
2021-9-4
Where should I add those? I would really appreaited if you can elaborate on that.
Walter Roberson
2021-9-4
Although it is not ideal, you would change
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112"';
to
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112" -L"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys" -ltime';
but possibly what you would need is
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112" "C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys\time.obj"';
Abdelrahman Aldik
2021-9-7
Upon usng this line:
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112" -L"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys" -ltime';
I have received the following error
>> compileSparseCoLO
Current directory is = C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\mex
Cannot find sub-directory "mex"
Execute this script at the top directory of SparseCoLO
>> compileSparseCoLO
Compiling Libraries...Error using mex
MEX cannot find library 'time', specified with the -l option.
MEX searched for a file with one of the following names:
libtime.a
time.lib
libtime.lib
Verify the library name is correct. If the library is not
on the existing path, specify the path with the -L option.
Error in compileSparseCoLO (line 81)
eval(command);
And upon using this line
MexFlags = ' -O -I"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112" "C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys\time.obj"';
I received this following error
>> compileSparseCoLO
Compiling Libraries...Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
done
Compiling mexForestConvert.cpp...Error using mex
C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\mex\"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys\time.obj"mexForestConvert.cpp
not found; check that you are in the correct current folder, and check the spelling of
'C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\mex\"C:\Users\Abd-PC\Downloads\SparseCoLO112\SparseCoLO112\sys\time.obj"mexForestConvert.cpp'.
Error in compileSparseCoLO (line 93)
eval(command);
I'm not sure what to do next?
Abdelrahman Aldik
2021-9-8
I have installed Microsoft Visual C++ 2019 and used it to compile the mex file, I got the following error
>> compileSparseCoLO
Compiling Libraries...Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
done
Compiling mexForestConvert.cpp...Building with 'Microsoft Visual C++ 2019 (C)'.
Error using mex
LINK : error LNK2001: unresolved external symbol mexFunction
ccputime.lib : fatal error LNK1120: 1 unresolved externals
I would appreciate your help.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)