SETUPMEXPOSIXTIME Build mex file for system POSIX time function POSIXTIME. Syntax: SETUPMEXPOSIXTIME() Description: SETUPMEXPOSIXTIME() builds a mex file implementing the function POSIXTIME, that gets the system current POSIX time from the standard C library. TARGET: /path/to/posixtime.mex(a64) SOURCES: /path/to/posixtime.c INCLUDES: none LIBRARIES: none Notes: The system time is get by the C function TIME. This function uses the function MEX to build the target. On GNU/Linux systems, the build process might fail after a warning if the compiler version is newer than the latest version supported by MATLAB, even though running the same MEX command on a system shell builds the target properly. The reason is that MATLAB may extent or overwrite the environment variable LD_LIBRARY_PATH to point to its own version of the standard libraries, causing an incompatibility with the version of the compiler. To solve the problem, either build the target from the shell or temporarily overwrite the environment variable LD_LIBRARY_PATH from the MATLAB session. Examples: % Compile interface function for low level C function TIME. setupMexPosixtime(); % Incompatible versions of system compiler and libraries shipped with the % interpreter may cause build failure. % Try to build the target against system libraries instead of shipped ones. ld_library_path = getenv('LD_LIBRARY_PATH') setenv('LD_LIBRARY_PATH') setupMexPosixtime() setenv('LD_LIBRARY_PATH', ld_library_path) clear('ld_library_path') See also: POSIXTIME Authors: Joan Pau Beltran <joanpau.beltran@socib.cat>
0001 function setupMexPosixtime() 0002 %SETUPMEXPOSIXTIME Build mex file for system POSIX time function POSIXTIME. 0003 % 0004 % Syntax: 0005 % SETUPMEXPOSIXTIME() 0006 % 0007 % Description: 0008 % SETUPMEXPOSIXTIME() builds a mex file implementing the function POSIXTIME, 0009 % that gets the system current POSIX time from the standard C library. 0010 % TARGET: 0011 % /path/to/posixtime.mex(a64) 0012 % SOURCES: 0013 % /path/to/posixtime.c 0014 % INCLUDES: 0015 % none 0016 % LIBRARIES: 0017 % none 0018 % 0019 % Notes: 0020 % The system time is get by the C function TIME. 0021 % 0022 % This function uses the function MEX to build the target. On GNU/Linux 0023 % systems, the build process might fail after a warning if the compiler 0024 % version is newer than the latest version supported by MATLAB, even though 0025 % running the same MEX command on a system shell builds the target properly. 0026 % The reason is that MATLAB may extent or overwrite the environment variable 0027 % LD_LIBRARY_PATH to point to its own version of the standard libraries, 0028 % causing an incompatibility with the version of the compiler. 0029 % To solve the problem, either build the target from the shell or temporarily 0030 % overwrite the environment variable LD_LIBRARY_PATH from the MATLAB session. 0031 % 0032 % Examples: 0033 % % Compile interface function for low level C function TIME. 0034 % setupMexPosixtime(); 0035 % 0036 % % Incompatible versions of system compiler and libraries shipped with the 0037 % % interpreter may cause build failure. 0038 % % Try to build the target against system libraries instead of shipped ones. 0039 % ld_library_path = getenv('LD_LIBRARY_PATH') 0040 % setenv('LD_LIBRARY_PATH') 0041 % setupMexPosixtime() 0042 % setenv('LD_LIBRARY_PATH', ld_library_path) 0043 % clear('ld_library_path') 0044 % 0045 % See also: 0046 % POSIXTIME 0047 % 0048 % Authors: 0049 % Joan Pau Beltran <joanpau.beltran@socib.cat> 0050 0051 % Copyright (C) 2013-2016 0052 % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 0053 % <http://www.socib.es> 0054 % 0055 % This program is free software: you can redistribute it and/or modify 0056 % it under the terms of the GNU General Public License as published by 0057 % the Free Software Foundation, either version 3 of the License, or 0058 % (at your option) any later version. 0059 % 0060 % This program is distributed in the hope that it will be useful, 0061 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0062 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0063 % GNU General Public License for more details. 0064 % 0065 % You should have received a copy of the GNU General Public License 0066 % along with this program. If not, see <http://www.gnu.org/licenses/>. 0067 0068 error(nargchk(0, 0, nargin, 'struct')); 0069 0070 funcname = 'posixtime'; 0071 funcpath = which(funcname); 0072 0073 if isempty(funcpath) 0074 error('glider_toolbox:setup:NotFound', ... 0075 'Could not find location of %s.', funcname); 0076 end 0077 0078 prefix = fileparts(funcpath); 0079 target = fullfile(prefix, [funcname '.' mexext()]); 0080 sources = fullfile(prefix, [funcname '.c']); 0081 0082 mex('-output', target, sources); 0083 0084 end