Closed joris997 closed 3 years ago
I am able to compile against the new MathLink v4 libraries in Windows 10 & Mathematica 12.2.0. I can post more specific steps later for what worked for me, but (similar to what you did) I basically made edits and recompiled math.c in ./third/mathlink/math.c (assuming you are in the frost top-level repo directory) using compileMathlink.m. The READMEs in the folder are helpful. Although I got things working, I don't know if these changes provide the same speed and functionality as the v3 library.
The changes I think you need to make are along the lines of replacing Disown with Release for the undefined references. Don't forget to locally copy the v4 .lib and .dll files into the same directory as the mex file.
I'm not sure if this would be helpful for linking against the v3 library or if there are simpler solutions (like fixing path assumptions made in the precompiled versions of mathlink).
So this was a two-step process for me (make sure to make backups of original files):
function [] = compileMathlink()
% This is to compile mathlink to *.mex* files
% Note: the math.c has not been updated since 2004, thus there is no point
% for you to compile it yourself.
% We recommend you to use the compiled *.mex* files included.
Mathematica_path = 'C:/Program Files/Wolfram Research/Mathematica/12.2/SystemFiles';
Link_path = 'Links/MathLink/DeveloperKit/Windows-x86-64/CompilerAdditions/';
compilerdir = fullfile(Mathematica_path, Link_path);
dlldir = fullfile(Mathematica_path, Link_path, '../', 'SystemAdditions');
headerdir = fullfile(Mathematica_path, 'IncludeFiles/C');
fprintf('mex(\t\n%s, \t\n%s, \t\n%s, \t\n%s, \t\n%s, \t\n%s\n)\n\n', ...
'-D__STDC__', ...
['-I', compilerdir], ...
['-L', compilerdir], ...
'-lml64i4', ...
['-I', headerdir], ...
'math.c');
mex('-D__STDC__', ...
['-I', compilerdir], ...
['-L', compilerdir], ...
'-lml64i4', ...
['-I', headerdir], ...
'math.c');
out = fileparts(which('compileMathlink'));
copyfile(fullfile(compilerdir, 'ml64i4.lib'), out);
copyfile(fullfile(dlldir, 'ml64i4.dll'), out);
% Remove the ~ files if there are any.
delete('*.*~');
end
Hope this can be of use to people, but as a quick aside I am not associated with this project and will not be providing support for this code. The intent is for it to be used as a source of ideas to help you get around your particular issue.
The function above can easily be made more general by taking in some combination Mathematica's $InstallationDirectory, $Version, and $SystemID values as inputs, so that values such as 12.2 and Windows-x86-64 are not hard coded values.
Thanks a lot nr-codes! My reply is a bit late but your second comment did the trick. Really appreciate the effort!
Hello all. I'm trying to get frost-dev to work and am stuck on the dependencies. First of it seems that my Mathematica version came with libML64i4. files instead of i3.* files. I copied and renamed them which, when running
testscript.m
now seems to get past that issue.Afterwards however I obtain the following error when running test-script:
Which led me to think that some issue between i3. and i4. persists. If I look into
mathlink.h
(line 3634) indeed I see the notion thatSubsequently I tried to compile the Mathlink code myself via the
compileMatlink.m
script that is included with the dependency (although it is mentioned that this would not be necessary) which results in the not completely unexpected errorSo all seems related but I am not sure how to proceed with this. Anyone have any idea? Thanks in advance!