PJLink
PJLink copied to clipboard
Error building native library in Fedora 28
Notice I edited ~/.Mathematica/Paclets/Repository/PJLink-.0.2/PJLink/MathLinkEnvironment.py:666
to reflect the actual installation root for Mathematica.
running build
running build_ext
building 'PJLinkNativeLibrary' extension
creating build
creating build/temp.linux-x86_64-3.6
gcc -pthread -B /opt/anaconda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -I/opt/anaconda/include/python3.6m -c PJLinkNativeLibrary.cpp -o build/temp.linux-x86_64-3.6/PJLinkNativeLibrary.o
g++ -pthread -shared -B /opt/anaconda/compiler_compat -L/opt/anaconda/lib -Wl,-rpath=/opt/anaconda/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/PJLinkNativeLibrary.o -L/opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -lMLi4 -o /home/fsiano/.Mathematica/Paclets/Repository/PJLink-1.0.2/PJLink/PJLinkNativeLibrary/src/PJLinkNativeLibrary.cpython-36m-x86_64-linux-gnu.so
An exception has occurred, use %tb to see the full traceback.
SystemExit: error: command 'g++' failed with exit status 1
/opt/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2918: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
and %tb
gives
---------------------------------------------------------------------------
DistutilsExecError Traceback (most recent call last)
/opt/anaconda/lib/python3.6/distutils/unixccompiler.py in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
196
--> 197 self.spawn(linker + ld_args)
198 except DistutilsExecError as msg:
/opt/anaconda/lib/python3.6/distutils/ccompiler.py in spawn(self, cmd)
908 def spawn(self, cmd):
--> 909 spawn(cmd, dry_run=self.dry_run)
910
/opt/anaconda/lib/python3.6/distutils/spawn.py in spawn(cmd, search_path, verbose, dry_run)
35 if os.name == 'posix':
---> 36 _spawn_posix(cmd, search_path, dry_run=dry_run)
37 elif os.name == 'nt':
/opt/anaconda/lib/python3.6/distutils/spawn.py in _spawn_posix(cmd, search_path, verbose, dry_run)
158 "command %r failed with exit status %d"
--> 159 % (cmd, exit_status))
160 elif os.WIFSTOPPED(status):
DistutilsExecError: command 'g++' failed with exit status 1
During handling of the above exception, another exception occurred:
LinkError Traceback (most recent call last)
/opt/anaconda/lib/python3.6/distutils/core.py in setup(**attrs)
147 try:
--> 148 dist.run_commands()
149 except KeyboardInterrupt:
/opt/anaconda/lib/python3.6/distutils/dist.py in run_commands(self)
954 for cmd in self.commands:
--> 955 self.run_command(cmd)
956
/opt/anaconda/lib/python3.6/distutils/dist.py in run_command(self, command)
973 cmd_obj.ensure_finalized()
--> 974 cmd_obj.run()
975 self.have_run[command] = 1
/opt/anaconda/lib/python3.6/distutils/command/build.py in run(self)
134 for cmd_name in self.get_sub_commands():
--> 135 self.run_command(cmd_name)
136
/opt/anaconda/lib/python3.6/distutils/cmd.py in run_command(self, command)
312 """
--> 313 self.distribution.run_command(command)
314
/opt/anaconda/lib/python3.6/distutils/dist.py in run_command(self, command)
973 cmd_obj.ensure_finalized()
--> 974 cmd_obj.run()
975 self.have_run[command] = 1
/opt/anaconda/lib/python3.6/distutils/command/build_ext.py in run(self)
338 # Now actually compile and link everything.
--> 339 self.build_extensions()
340
/opt/anaconda/lib/python3.6/distutils/command/build_ext.py in build_extensions(self)
447 else:
--> 448 self._build_extensions_serial()
449
/opt/anaconda/lib/python3.6/distutils/command/build_ext.py in _build_extensions_serial(self)
472 with self._filter_build_errors(ext):
--> 473 self.build_extension(ext)
474
/opt/anaconda/lib/python3.6/distutils/command/build_ext.py in build_extension(self, ext)
557 build_temp=self.build_temp,
--> 558 target_lang=language)
559
/opt/anaconda/lib/python3.6/distutils/ccompiler.py in link_shared_object(self, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
716 export_symbols, debug,
--> 717 extra_preargs, extra_postargs, build_temp, target_lang)
718
/opt/anaconda/lib/python3.6/distutils/unixccompiler.py in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
198 except DistutilsExecError as msg:
--> 199 raise LinkError(msg)
200 else:
LinkError: command 'g++' failed with exit status 1
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
<ipython-input-3-a1f503dd0203> in <module>()
----> 1 ker = SubprocessKernel()
2 def MEval (expr, wait = True, kernel = ker):
3 """MEval evaluates a Mathematica expression in the Mathematica kernel
4
5 """
~/.Mathematica/Paclets/Repository/PJLink-1.0.2/SubprocessKernel/SubprocessKernel.py in __init__(self, init, debug_level)
15
16 def __init__(self, init = None, debug_level = 0):
---> 17 super().__init__(NativeLink(init=init, debug_level=debug_level))
18 self.__py_eval_link = None
19 self.__reader = None
~/.Mathematica/Paclets/Repository/PJLink-1.0.2/PJLink/NativeLink.py in __init__(self, init, debug_level)
46 self._init = init
47 self.__errMsgOut = [ "" ]
---> 48 self._loadNativeLibrary(debug_level=debug_level)
49
50 self.__markStack = deque()
~/.Mathematica/Paclets/Repository/PJLink-1.0.2/PJLink/NativeLink.py in _loadNativeLibrary(self, initialize, debug_level, setup, *args)
127 argv1 = sys.argv
128 sys.argv = [ "-q", "build", "build_ext", "--inplace" ]
--> 129 import setup as setup
130 sys.path.pop(0)
131 sys.argv = argv1
~/.Mathematica/Paclets/Repository/PJLink-1.0.2/PJLink/PJLinkNativeLibrary/src/setup.py in <module>()
54 version = '1.0',
55 description = 'Implementation of JLinkNativeLibrary for python',
---> 56 ext_modules = [module1]
57 )
58
/opt/anaconda/lib/python3.6/distutils/core.py in setup(**attrs)
161 raise
162 else:
--> 163 raise SystemExit("error: " + str(msg))
164
165 return dist
SystemExit: error: command 'g++' failed with exit status 1
Thanks for the report. Someone else had issues with an Anaconda distribution of python failing to build because of the #include <cstdint>
. That was circumventable with a Mac-specific fix, so I'm guessing g++ is failing because of the same issue (i.e. Anaconda does odd things). I'll google to see if I can find a workaround that I can implement for Fedora too.
Out of curiosity, what did you need to change in MathLinkEnvironment? If more configuration is needed I should allow it to be passed in the initialization.
I'm going to expunge the "-q" from the sys.argv
with the hope that it allows things to be cleaner for people with issues in the future. Do you mind testing it without that and letting me know what happens? It might quiet a more particular message.
Using the standard python which comes with Fedora (not anaconda) and PJLink versrion 1.0.3:
Because of #5 I changed (3 instances) in
~/.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/MathLinkEnvironment.py
os.path.join(root, "SystemFiles", ...)
to os.path.join(root, "11.3", "SystemFiles", ...)
Notice the include has -I/opt/Wolfram/Mathematica/SystemFiles/...
(not -I/opt/Wolfram/Mathematica/11.3/SystemFiles/...
).
unning build_ext
building 'PJLinkNativeLibrary' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/Wolfram/Mathematica/SystemFiles/Links/MathLink/DeveloperKit/Linux/CompilerAdditions -I/usr/include/python3.6m -c PJLinkNativeLibrary.cpp -o build/temp.linux-x86_64-3.6/PJLinkNativeLibrary.o
An exception has occurred, use %tb to see the full traceback.
SystemExit: error: command 'gcc' failed with exit status 1
/usr/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2971: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
and %tb
:
--------------------------------------------------------------------------
DistutilsExecError Traceback (most recent call last)
/usr/lib64/python3.6/distutils/unixccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
126 self.spawn(compiler_so + cc_args + [src, '-o', obj] +
--> 127 extra_postargs)
128 except DistutilsExecError as msg:
/usr/lib64/python3.6/distutils/ccompiler.py in spawn(self, cmd)
908 def spawn(self, cmd):
--> 909 spawn(cmd, dry_run=self.dry_run)
910
/usr/lib64/python3.6/distutils/spawn.py in spawn(cmd, search_path, verbose, dry_run)
35 if os.name == 'posix':
---> 36 _spawn_posix(cmd, search_path, dry_run=dry_run)
37 elif os.name == 'nt':
/usr/lib64/python3.6/distutils/spawn.py in _spawn_posix(cmd, search_path, verbose, dry_run)
158 "command %r failed with exit status %d"
--> 159 % (cmd, exit_status))
160 elif os.WIFSTOPPED(status):
DistutilsExecError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
CompileError Traceback (most recent call last)
/usr/lib64/python3.6/distutils/core.py in setup(**attrs)
147 try:
--> 148 dist.run_commands()
149 except KeyboardInterrupt:
/usr/lib64/python3.6/distutils/dist.py in run_commands(self)
954 for cmd in self.commands:
--> 955 self.run_command(cmd)
956
/usr/lib64/python3.6/distutils/dist.py in run_command(self, command)
973 cmd_obj.ensure_finalized()
--> 974 cmd_obj.run()
975 self.have_run[command] = 1
/usr/lib64/python3.6/distutils/command/build_ext.py in run(self)
338 # Now actually compile and link everything.
--> 339 self.build_extensions()
340
/usr/lib64/python3.6/distutils/command/build_ext.py in build_extensions(self)
447 else:
--> 448 self._build_extensions_serial()
449
/usr/lib64/python3.6/distutils/command/build_ext.py in _build_extensions_serial(self)
472 with self._filter_build_errors(ext):
--> 473 self.build_extension(ext)
474
/usr/lib64/python3.6/distutils/command/build_ext.py in build_extension(self, ext)
532 extra_postargs=extra_args,
--> 533 depends=ext.depends)
534
/usr/lib64/python3.6/distutils/ccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
573 continue
--> 574 self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
575
/usr/lib64/python3.6/distutils/unixccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
128 except DistutilsExecError as msg:
--> 129 raise CompileError(msg)
130
CompileError: command 'gcc' failed with exit status 1
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
<ipython-input-2-46b7fe96b177> in <module>()
----> 1 ker = SubprocessKernel()
2 def MEval (expr, wait = True, kernel = ker) :
3 """MEval evaluates a Mathematica expression in the Mathematica kernel
4
5 """
.Mathematica/Paclets/Repository/PJLink-1.0.3/SubprocessKernel/SubprocessKernel.py in __init__(self, init, debug_level)
.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/NativeLink.py in __init__(self, init, debug_level)
.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/NativeLink.py in _loadNativeLibrary(self, initialize, debug_level, *args)
.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/PJLinkNativeLibrary/__init__.py in <module>()
.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/PJLinkNativeLibrary/__init__.py in _get_lib_dir_loc()
.Mathematica/Paclets/Repository/PJLink-1.0.3/PJLink/PJLinkNativeLibrary/src/setup.py in <module>()
/usr/lib64/python3.6/distutils/core.py in setup(**attrs)
161 raise
162 else:
--> 163 raise SystemExit("error: " + str(msg))
164
165 return dist
SystemExit: error: command 'gcc' failed with exit status 1
@bgatessucks I think I got a patch for this path as well as the others. The path finding is a bit more centralized now. Can you give it another try? Hopefully the only issue is just these paths.
Not there yet with 1.0.4:
I have several versions of Mathematica installed at /opt/Wolfram/Mathematica/ver
with ver
in
10.4.1
11.0.1
11.1
11.1.1
11.2
11.3
7.0.1
8.0.4
9.0.1
and it seems that 10.4.1
gets picked up.
Would it be possible to add an argument for the user to provide the Mathematica root ?
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/PJLink/MathLinkEnvironment.py in get_Kernel_binary(cls, version, use_default_root)
723 try:
--> 724 root = cls.get_Mathematica_root(version, use_default_root=use_default_root)
725 except ValueError:
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/PJLink/MathLinkEnvironment.py in get_Mathematica_root(cls, mname, use_default_root)
699 if mname is None and cls.CURRENT_MATHEMATICA is None:
--> 700 root = cls.get_Installed_Mathematica(use_default_root=use_default_root)
701 if plat == "Darwin":
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/PJLink/MathLinkEnvironment.py in get_Installed_Mathematica(cls, use_default_root)
656 vers = app
--> 657 verNum = float(app)
658 mathematicas.append((mathematica, verNum, vers))
ValueError: could not convert string to float: '10.4.1'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-2-46b7fe96b177> in <module>()
----> 1 ker = SubprocessKernel()
2 def MEval (expr, wait = True, kernel = ker) :
3 """MEval evaluates a Mathematica expression in the Mathematica kernel
4
5 """
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/SubprocessKernel/SubprocessKernel.py in __init__(self, init, debug_level)
15
16 def __init__(self, init = None, debug_level = 0):
---> 17 super().__init__(NativeLink(init=init, debug_level=debug_level))
18 self.__py_eval_link = None
19 self.__reader = None
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/PJLink/NativeLink.py in __init__(self, init, debug_level)
35
36 if init is None:
---> 37 bin = self.Env.get_Kernel_binary()
38 init = ["-linkmode", "launch", "-linkname", "'{}' -mathlink".format(bin)]#, "-mathlink", "-wstp"]
39 elif isinstance(init, str) and os.path.isfile(init):
~/.Mathematica/Paclets/Repository/PJLink-1.0.4/PJLink/MathLinkEnvironment.py in get_Kernel_binary(cls, version, use_default_root)
725 except ValueError:
726 if not (isinstance(version, str) and os.path.isfile(version)):
--> 727 raise ValueError("Don't know how to find the WolframKernel executable on system {}".format(plat))
728 else:
729 mbin = version
ValueError: Don't know how to find the WolframKernel executable on system Linux
@bgatessucks Okay I think I got a fix in place for the bad directory finding. Thanks for all your help with this. I also have a system where you can provide your own $InstallationDirectory
. Try :
from PJLink import MathLinkEnvironment as Env
Env.INSTALLATION_DIRECTORY = "mathematica/installation/directory"
I got it to find things properly on Mac for a different Mathematica version, but we'll see how it goes.
Progress, it's just g++ now, with Env.INSTALLATION_DIRECTORY = "/opt/Wolfram/Mathematica/11.3"
:
running build_ext
building 'PJLinkNativeLibrary' extension
creating build
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -I/usr/include/python3.6m -c PJLinkNativeLibrary.cpp -o build/temp.linux-x86_64-3.6/PJLinkNativeLibrary.o
g++ -pthread -shared -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -g -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -g -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none build/temp.linux-x86_64-3.6/PJLinkNativeLibrary.o -L/opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions -L/usr/lib64 -lMLi4 -lpython3.6m -o ~/.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/PJLinkNativeLibrary/src/PJLinkNativeLibrary.cpython-36m-x86_64-linux-gnu.so
An exception has occurred, use %tb to see the full traceback.
SystemExit: error: command 'g++' failed with exit status 1
DistutilsExecError Traceback (most recent call last)
/usr/lib64/python3.6/distutils/unixccompiler.py in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
204
--> 205 self.spawn(linker + ld_args)
206 except DistutilsExecError as msg:
/usr/lib64/python3.6/distutils/ccompiler.py in spawn(self, cmd)
908 def spawn(self, cmd):
--> 909 spawn(cmd, dry_run=self.dry_run)
910
/usr/lib64/python3.6/distutils/spawn.py in spawn(cmd, search_path, verbose, dry_run)
35 if os.name == 'posix':
---> 36 _spawn_posix(cmd, search_path, dry_run=dry_run)
37 elif os.name == 'nt':
/usr/lib64/python3.6/distutils/spawn.py in _spawn_posix(cmd, search_path, verbose, dry_run)
158 "command %r failed with exit status %d"
--> 159 % (cmd, exit_status))
160 elif os.WIFSTOPPED(status):
DistutilsExecError: command 'g++' failed with exit status 1
During handling of the above exception, another exception occurred:
LinkError Traceback (most recent call last)
/usr/lib64/python3.6/distutils/core.py in setup(**attrs)
147 try:
--> 148 dist.run_commands()
149 except KeyboardInterrupt:
/usr/lib64/python3.6/distutils/dist.py in run_commands(self)
954 for cmd in self.commands:
--> 955 self.run_command(cmd)
956
/usr/lib64/python3.6/distutils/dist.py in run_command(self, command)
973 cmd_obj.ensure_finalized()
--> 974 cmd_obj.run()
975 self.have_run[command] = 1
/usr/lib64/python3.6/distutils/command/build_ext.py in run(self)
338 # Now actually compile and link everything.
--> 339 self.build_extensions()
340
/usr/lib64/python3.6/distutils/command/build_ext.py in build_extensions(self)
447 else:
--> 448 self._build_extensions_serial()
449
/usr/lib64/python3.6/distutils/command/build_ext.py in _build_extensions_serial(self)
472 with self._filter_build_errors(ext):
--> 473 self.build_extension(ext)
474
/usr/lib64/python3.6/distutils/command/build_ext.py in build_extension(self, ext)
557 build_temp=self.build_temp,
--> 558 target_lang=language)
559
/usr/lib64/python3.6/distutils/ccompiler.py in link_shared_object(self, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
716 export_symbols, debug,
--> 717 extra_preargs, extra_postargs, build_temp, target_lang)
718
/usr/lib64/python3.6/distutils/unixccompiler.py in link(self, target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang)
206 except DistutilsExecError as msg:
--> 207 raise LinkError(msg)
208 else:
LinkError: command 'g++' failed with exit status 1
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
<ipython-input-5-46b7fe96b177> in <module>()
----> 1 ker = SubprocessKernel()
2 def MEval (expr, wait = True, kernel = ker) :
3 """MEval evaluates a Mathematica expression in the Mathematica kernel
4
5 """
.Mathematica/Paclets/Repository/PJLink-1.0.5/SubprocessKernel/SubprocessKernel.py in __init__(self, init, debug_level)
.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/NativeLink.py in __init__(self, init, debug_level)
.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/NativeLink.py in _loadNativeLibrary(self, initialize, debug_level, *args)
.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/PJLinkNativeLibrary/__init__.py in <module>()
.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/PJLinkNativeLibrary/__init__.py in _get_lib_dir_loc()
.Mathematica/Paclets/Repository/PJLink-1.0.5/PJLink/PJLinkNativeLibrary/src/setup.py in <module>()
/usr/lib64/python3.6/distutils/core.py in setup(**attrs)
161 raise
162 else:
--> 163 raise SystemExit("error: " + str(msg))
164
165 return dist
SystemExit: error: command 'g++' failed with exit status 1
@bgatessucks do you have a library called MLi4 in /opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions? For me it's MLi4.a, but setup.py doesn't care about the extension. The fact that it got through the gcc call suggests it's just a linking issue, now.
I tried to rewrite the dependency finder so that it doesn't require a file called MLi4 but instead looks for the highest-version library files in the directory. Let me know if it worked. If not, can you paste the file names inside /opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions
? My current guess is I'm selecting that file incorrectly.
ls /opt/Wolfram/Mathematica/11.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions
gives:
libML32i3.a
libML32i3.so
libML32i4.a
libML32i4.so
libML64i3.a
libML64i3.so
libML64i4.a
libML64i4.so
MathLink.cmake
mathlink.h
MathLink-release.cmake
mcc
mprep
Ah that could entirely be the issue then. Any chance the current version (1.0.6) builds? I added more intelligent path-finding so it ought to have found either libML64i4
or libML32i4
but I can't be sure which. It's also possible to specify this directly with Env.MATHLINK_LIBRARY_NAME = "ML64i4"
. Once again thanks for all your help. I have no access to any Linux or Windows machine so this is super useful.
Progress but not there yet:
Env.INSTALLATION_DIRECTORY = "/opt/Wolfram/Mathematica/11.3"
Env.MATHLINK_LIBRARY_NAME = "ML64i4"
ImportError Traceback (most recent call last)
<ipython-input-5-46b7fe96b177> in <module>()
----> 1 ker = SubprocessKernel()
2 def MEval (expr, wait = True, kernel = ker) :
3 """MEval evaluates a Mathematica expression in the Mathematica kernel
4
5 """
~/.Mathematica/Paclets/Repository/PJLink-1.0.6/SubprocessKernel/SubprocessKernel.py in __init__(self, init, debug_level)
15
16 def __init__(self, init = None, debug_level = 0):
---> 17 super().__init__(NativeLink(init=init, debug_level=debug_level))
18 self.__py_eval_link = None
19 self.__reader = None
~/.Mathematica/Paclets/Repository/PJLink-1.0.6/PJLink/NativeLink.py in __init__(self, init, debug_level)
46 self._init = init
47 self.__errMsgOut = [ "" ]
---> 48 self._loadNativeLibrary(debug_level=debug_level)
49
50 self.__markStack = deque()
~/.Mathematica/Paclets/Repository/PJLink-1.0.6/PJLink/NativeLink.py in _loadNativeLibrary(self, initialize, debug_level, *args)
101 except ImportError as e:
102 self.__LIBRARY_LOAD_EXCEPTION = e
--> 103 raise e
104 else:
105 self.__NATIVE_LIBRARY_LOADED = True
~/.Mathematica/Paclets/Repository/PJLink-1.0.6/PJLink/NativeLink.py in _loadNativeLibrary(self, initialize, debug_level, *args)
98
99 try:
--> 100 import PJLink.PJLinkNativeLibrary as pj
101 except ImportError as e:
102 self.__LIBRARY_LOAD_EXCEPTION = e
~/.Mathematica/Paclets/Repository/PJLink-1.0.6/PJLink/PJLinkNativeLibrary/__init__.py in <module>()
50 try:
51 sys.path.insert(0, _get_lib_dir_loc())
---> 52 from PJLinkNativeLibrary import *
53 finally:
54 sys.path.pop(0)
ImportError: libML64i4.so: cannot open shared object file: No such file or directory
That's very odd...so the library compiled but gave that warning? Could you show me the compiler output and what's in ~/.Mathematica/Paclets/Repository/PJLink-1.0.6/PJLink/PJLinkNativeLibrary? I think it must be linking against the .so version of libML64i4 instead of the .a, since it was able to find both. If that's the case I'll need to change how I choose to the link MathLink library in slightly.