Error running Fortran on Mac - macos

I am running macOS 10.13.5 and I have installed Fortran using Homebrew. I can compile and build a program like this:
program HelloWorld
write(*,*)'Hello World'
end program
But when I try to run it I get the same error:
dyld: Library not loaded: #rpath/libgfortran.3.dylib
Referenced from: /Users/sergiobacelar/Documents/books2calibre/books_software/feher_fortran/prog01/prog01_01/Build/prog
Reason: image not found
/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/geany_run_script_2Q4DKZ.sh: line 7: 47712 Abort trap: 6 "Build/prog"
I have libgfortran.3.dylib inside anaconda3/lib and I have gcc 8.1.0 in homebrew but when I do gfortran -v I get gcc 4.8.5 from Anaconda.

I use anaconda/miniconda quite a bit on Linux and mac environments. Modules (https://en.wikipedia.org/wiki/Environment_Modules_(software)) are a great way to keep it from polluting your environment. As an example, at the end of my .bashrc file, I have:
module use --append "$HOME/.modules"
This directory contains a module file for conda:
$ cat .modules/conda
#%Module1.0
module-whatis "add ~/miniconda3 to path"
prepend-path PATH /Users/ptb/miniconda3/bin
A $ module load conda will then adjust the PATH, making all miniconda related things visible.
Edit:
I wrote the first part of this answer on my linux machine where modules are installed by default and forgot that 2 things are needed to make it work on a mac.
On a mac, modules can be installed via homebrew with brew install modules. One then needs to put the following before module use ...:
. /usr/local/Modules/default/init/bash

Related

How to install Net::SSH2 from CPAN on Cygwin

I needed to install Net:SSH2 in a Cygwin environment under Windows 7 (64 bit). As usually I tried to install it with cpanm.
I already had the necessary Cygwin packages (see below) installed but the Perl build failed because it couldn't find the libssh2 library.
There is a special text file BUILDING.WIN32 in the Net::SSH2 package but this is only useful when building the module by hand and it refers mainly to MinGW. So this no help.
This is the log of the build:
Entering Net-SSH2-0.53
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (7.02)
Running Makefile.PL
Configuring Net-SSH2-0.53 ... Subroutine checklibs redefined at inc/Module/Install/CheckLib.pm line 11.
Subroutine assertlibs redefined at inc/Module/Install/CheckLib.pm line 25.
Subroutine _author_side redefined at inc/Module/Install/CheckLib.pm line 39.
The libssh2 library is required by this module. If you don't have it, you can
download it from http://www.libssh2.org; you may also need OpenSSL, which can
be obtained from http://www.openssl.org , or libgcrypt, which can be obtained
from http://www.gnupg.org .
Debian: sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
You can pass your libssh2 lib and include dirs (and extra link args) on the
command line. E.g.:
perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include \
ldargs="-lz"
These can also be set through the LIBSSH2_LIB/LIBSSH2_INCLUDE/LIBSSH2_LDARGS
environment variables.
To build with libgcrypt instead of OpenSSL, pass 'gcrypt' as a parameter to
Makefile.PL, e.g.:
perl Makefile.PL gcrypt
If you want to build on Windows, see the file BUILDING.WIN32 in the
distribution.
Can't link/include C library 'ssh2', aborting.
First install the libssh2-devel package from Cygwin, e.g. with apt-cyg the command line frontend for installing packages from within a cygwin shell.
apt-cyg install libssh2-devel
Then set some environment variables to the right path for getting Net::SSH2 to work with the Cygwin packages:
LIBSSH2_LIB=/usr/lib/ LIBSSH2_INCLUDE=/usr/include/ cpanm -v Net::SSH2
That worked for me. Much easier than what the readme file linked above looked like.

How to install Scrapy on Mac OS X 10.7 ? (lxml error)

I'm a total newbie concerning Python and I have trouble installing Scrapy on Mac OS X 10.7. I've tried a lot of different things, but in summary, when I run:
scrapy startproject tutorial
I've got these errors :
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Symbol not found: ___xmlStructuredErrorContext
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/lxml/etree.so
After a lot of googling, I've followed this post and tried:
python setup.py build --static-deps --libxml2-version=2.7.8 && pip install lxml
but it tells me:
RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available (pass --without-cython to ignore this error).
And if I run the same command with the —without-cython option, I get:
error: command 'llvm-gcc-4.2' failed with exit status 1
(though I've installed XCode command line tools)
Thanks in advance for your help !
(fyi, I am using MacPorts and pip install…)
You mention Macports at the end and also pip. I think you are mixing up packaging and installation methods.
The first import error should not be seen using a macports python as it puts its libraries under /opt/
As you have started on macports I would use the easy way
port install py27-scrapy
This will install all the needed packages (including python and lxml) to get scrapyto work.
To run scrapy you would need to use the macports python in /opt/local/bin/python2.7. This can be set as the default python if /opt/local/bin is on your path and you run port select to choose this as the python found. The scrapy executable script is /opt/local/bin/scrapy-2.7 Version numbers are used because you can have multiple versions of python working at once.

perlbrew migrate modules to new perl install, on Mac OS X 10.7.5

I asked this question on perlmonks, and have made limited progress so I will ask here. I installed perl 5.16.0, threaded, on Mac OS X 10.7.5, using perlbrew. Now, when I try to transfer modules to the new install, it fails with a message that I don't understand. Below are commands I used and output.
$ perlbrew install --as perl-5.16.0t -Dusethreads perl-5.16.0
Then, following a post on perlmonks:
$ perldoc -t perllocal | perl -lane'/"Module"/ && print $F[-1]' | sort -u >/tmp/pms
$ perlbrew switch perl-5.16.0t
$ cpanm -v </tmp/pms &>>/tmp/inst.log & tail -f /tmp/inst.log
I then tried these commands as a simple check, and got output I can't begin to fathom:
$ perl -e 1 -MFile::Find
dyld: lazy symbol binding failed: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
Trace/BPT trap: 5
$ perldoc File::Find
dyld: lazy symbol binding failed: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /Users/abualiga/perl5/lib/perl5/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
Expected in: flat namespace
Trace/BPT trap: 5
I uninstalled perl-5.16.0t and removed folder perlbrew and the line from .bash_profile, so now I am back to system perl 5.12.3. I would like to know how to do this though, to have multiple perls in my home directory, and not have to use ActiveState.
Did you install perlbrew with default settings in the default directory (perl5/perlbrew)? Reinstall perlbrew and switch to your preferred perl and check the following:
First, do you have cpanm installed in perlbrew? "which cpanm" will tell you which one you are using. It should be located in a directory with a path ending in "perlbrew/bin". If not, you can install it with
perlbrew install-cpanm
Also, is the line in your bash_profile something like "source ~/perl5/perlbrew/etc/bashrc"? Is it the correct path for that perlbrew bashrc file? Did you restart your terminal after editing your bash_profile? What's in your #INC? To check:
perl -e 'print join "\n", #INC'
If perlbrew is installed correctly, there should only be subdirectories of your perlbrew directory in #INC.
From your error messages, it looks like the perlbrew perl is looking for that module and finding one built against another perl located in "/Users/abualiga/perl5/lib" which isn't compatible. Perlbrew perl's modules are usually located somewhere like "~/perl5/perlbrew/perls/perl-5.16.3/lib". Which means either you didn't install those modules properly for the particular perlbrew perl you are using, or something is wrong with the path/#INC. If it's the latter, something is wrong with the perlbrew bashrc script (I know they fixed a bug in the latest version - 0.61 - of perlbrew). Though, if you didn't install perlbrew in the default way, then you may need to fix the path yourself.
Also, in the future, if you would like to transfer modules between different perls installed with perlbrew, these instructions may help.

Trouble compiling mono from source via cygwin on windows

I work off my i: drive
I've downloaded the following mono source file mono-2.11.2.tar.bz2
I've installed the windows version of mono v2.11.2 to "I:\Mono-2.11.2"
I installed cygwin as per the following instructions found on the following webpage http://shana.worldofcoding.com/en/mono_cygwin_tutorial.html
I replaced the "make.exe" with the one from the mono website as per instruction. I had to get one more file "cygintl-2.dll" which resides in cygwin package libintl2/libintl2-0.12.1-3
I added the following my .bashrc file. I had to change "c/Mono-2.11.2/bin" to "i/Mono-2.11.2/bin"
PATH=.:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/i/Mono-2.11.2/bin
PKG_CONFIG_PATH=.:/lib/pkgconfig:/cygdrive/i/Mono-2.11.2/lib/pkgconfig
LD_LIBRARY_PATH=.:/usr/local/lib:/usr/lib:/lib:/cygdrive/i/Mono-2.11.2/lib
export PATH PKG_CONFIG_PATH LD_LIBRARY_PATH
I placed my mono source under the folder specified: /usr/src/mono/
So my dirs looks like:
i:
i:\cygwin\
i:\cygwin\usr\src\mono
i:\cygwin\usr\src\mono\mono
i:\cygwin\usr\src\mono\mcs etc etc
i:\Mono-2.11.2\bin etc
Now the instructions says I must change dirs to /usr/src/mono/mono and run "./autogen.sh --prefix=/usr/local" from the cygwin terminal
However that doesnt work. Running the above command from /usr/src/mono/ works fine.
Now heres the problem. The next instruction is to run "make". However this comes up with :
$ make
make: *** No targets specified and no makefile found. Stop.
I even tried running it from the /usr/src/mono/mono dir. Still no luck.
Can someone please suggest what I should do to be able to build the mono source on windows 7?
Update:
I needed to install the **gnu c++ compiler (g++)**. I just ran the cygwin setup again, searched for g++ and installed that. The autogen.sh ran to completion
The last lines of ./autogen.sh --prefix=/usr/local output should
look like bellow with Now type make to compile at the end. And it
generats Makefile in the same directory.
I think in your case ./autogen.sh failed. You can keep a log file
and check what it is complaining about.
./autogen.sh --prefix=/usr/local 2>&1 | tee autogen.log
More info: http://en.wikipedia.org/wiki/GNU_build_system
The end of the ./autogen.sh ouptut:
config.status: executing quiet-libtool commands
config.status: executing default commands
mcs source: mcs
olive source:
Engine:
GC: sgen and bundled Boehm GC with typed GC and parallel mark
TLS: __thread
SIGALTSTACK: yes
Engine: Building and using the JIT
oprofile: no
BigArrays: no
DTrace: no
LLVM Back End: no (dynamically loaded: no)
Libraries:
Moon Profile: no (boehm)
MonoDroid: no
MonoTouch: no
Mobile: no
JNI support: IKVM Native
libgdiplus: assumed to be installed
zlib: system zlib
Now type `make' to compile

ImageMagick on Mac OSX Snow Leopard. Is there any way to get it to compile and run?

It seems that I have more trouble getting standard Unix things to run on Snow Leopard than any other platform--including Windows cygwin
For the past couple of days, I've been trying to get ImageMagick to run on Snow Leopard.
The most obvious way, Mac Ports, fails:
tppllc-Mac-Pro:ImageMagick-sl swirsky$ sudo port install imagemagick
---> Computing dependencies for p5-locale-gettext
---> Configuring p5-locale-gettext
Error: Target org.macports.configure returned: configure failure: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_perl_p5-locale-gettext/work/gettext-1.05" && /opt/local/bin/perl Makefile.PL INSTALLDIRS=vendor " returned error 2
Command output: checking for gettext... no
checking for gettext in -I/opt/local/include -arch i386 -L/opt/local/lib -lintl...gettext function not found. Please install libintl at Makefile.PL line 18.
no
Error: Unable to upgrade port: 1
Error: Unable to execute port: upgrade xorg-libXt failed
Before reporting a bug, first run the command again with the -d flag to get complete output.
tppllc-Mac-Pro:ImageMagick-sl swirsky$
Not wanting to spend another two days figuring out why my libintl doesn't have a "gettext" function, I tried a different route: the script mentioned here: http://github.com/masterkain/ImageMagick-sl
This script downloads and installs an ImageMagic independently of MacPorts issues
tppllc-Mac-Pro:ImageMagick-sl swirsky$ /usr/local/bin/convert
dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
It downloads everything and compiles fine, but fails when I try to run it, with the message above.
So now I'm two steps away from ImageMagick, trying to get a newer libiconv on my machine.
I downloaded the latest libiconv, compiled and built it. I put the resulting library in /opt/local/lib, and I still get the same error message:
tppllc-Mac-Pro:.libs swirsky$ sudo mv libiconv.2.dylib /opt/local/lib/libiconv.2.dylib
tppllc-Mac-Pro:.libs swirsky$ convert
dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
Now here's something interesting. The error message shows it's looking in /opt/local/lib/libiconv.2.dylib.
otools -L shows that this does implement 8.0.0:
tppllc-Mac-Pro:.libs swirsky$ otool -L /opt/local/lib/libiconv.2.dylib
/opt/local/lib/libiconv.2.dylib:
/usr/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
tppllc-Mac-Pro:.libs swirsky$
And, for good measure, I set the DYLD_LIBRARY_PATH to make sure this directory is the one for dynamic libraries.
So even though I do have a library that provides 8.0.0, it's being seen as 7.0.0! Any ideas why this would happen?
So here's my question: Is it possible to get ImageMagick to run on OSX Snow Leopard? Are there any binary distributions that have static libraries baked in so I don't have to worry about these issue/
This worked for me:
sudo brew install imagemagick
You may also try the ImageMagick install script located here:
http://github.com/masterkain/ImageMagick-sl
It helped me a lot. May be needed to change some library versions inside the script.
I've seen this exact error with this exact library in multiple situations. It was, in every case, an instance where either the individual or an script they were using was setting the DYLD_LIBRARY_PATH variable.
Make sure this variable is not being set as it overrides loading the explicitly linked libraries with those at that path.
If the DYLD_* must be set, use the more sane DYLD_FALLBACK_LIBRARY_PATH. Which will attempt to load the explicitly linked libraries first, then fallback to the user declared ones.
I did notice on your initial build that it was not finding the gettext library in macports. So make sure those are installed.
My google showed up a few hits, and the first or second one had a link to the binary.
I was finally able to get my "macports" installation consistent enough to get imagemagick installed and running. I had to manually delete my /opt/local/ directores where the files lived, and clean out some other dependencies.
It seems that the dynamic linker is pulling in the system libiconv.2.dylib (which has compatibility version 7.0.0). Without seeing your entire build process it's hard to know for sure why this is, but I'm suspicious of your libiconv build; note that in the following failure:
tppllc-Mac-Pro:.libs swirsky$ otool -L /opt/local/lib/libiconv.2.dylib
/opt/local/lib/libiconv.2.dylib:
/usr/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
your libiconv.2.dylib seems to think that its install path is /usr/local/lib, not /opt/local/lib. This probably why the dynamic linker isn't finding it; it's looking for it in /usr/local/lib, not finding it, and falling back on the system library in /usr/lib. Try setting the install path for your libiconv.2.dylib so that it's load commands tell the linker to look for it in /opt/local/lib, and that may resolve the issue.
I had the same problem, and solved it by uninstalling then reinstalling libiconv using Macports. Then everything works fine (I also have /opt/local/lib/ as the first entry in my DYLD_LIBRARY_PATH variable)
Strange. I'm pretty happy with my macports - and everything is compiled without errors. I can only advice - use macports.
ImageMagick #6.6.9-9_0+graphviz+hdri+jpeg2+mpeg+perl+q16+rsvg+wmf (active)

Resources