You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
sys/times.h Compiling issue
11 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 31 Aug 2021
Abdelrahman Aldik
on 31 Aug 2021
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
on 31 Aug 2021
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
on 31 Aug 2021
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
on 31 Aug 2021
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!
Abdelrahman Aldik
on 1 Sep 2021
I would appreciate it if I can get some feedback abut this issue.
Walter Roberson
on 2 Sep 2021
Edited: Walter Roberson
on 2 Sep 2021
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
on 2 Sep 2021
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
on 2 Sep 2021
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
on 4 Sep 2021
Where should I add those? I would really appreaited if you can elaborate on that.
Walter Roberson
on 4 Sep 2021
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
on 7 Sep 2021
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
on 8 Sep 2021
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.
Answers (0)
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)