I've successfully installed unixODBC 2.3.4 on Mac OS X 10.12.6 (Sierra) but when I try to run pip install pyodbc I run into the following error:
ld: library not found for -lodbc
I assume that what it's looking for is libodbc.la that got installed with unixODBC:
test -z "/usr/local/lib" || .././install-sh -c -d "/usr/local/lib"
/bin/sh ../libtool --mode=install /usr/bin/install -c libodbc.la '/usr/local/lib'
Is this not what Pyodbc is looking for? How do I get it to find and use it successfully?
I've downloaded a copy of the Pyodbc source (version 4.0.17) and figured this out by examining its setup.py. It is indeed looking for unixODBC:
# The latest versions of OS X no longer ship with iodbc. Assume
# unixODBC for now.
settings['libraries'].append('odbc')
This causes ld to be called with -lodbc which looks for /lib/usr/libodbc.dylib. Unfortunately since El Capitan, normal installations go into /lib/local/usr.
What I did to fix this, then, is to add the following line in setup.py under the sys.platform == 'darwin': section:
# unixODBC make/install places libodbc.dylib in /usr/local/lib/ by default
# (also OS/X since El Capitan prevents /usr/lib from being accessed )
settings['library_dirs'] = [ '/usr/local/lib' ]
I can then install this with PIP from my local system like so:
$ sudo pip install /path/to/pyodbc-4.0.17/
I'll work on getting a patch made to Pyodbc but this gets me by in the meantime.
Related
Firebird Extension for PHP on MacOS M1
I have PHP7.4 installed with homebrew and the Xcode command line tools.
I followed the instructions as per the source repository here https://github.com/FirebirdSQL/php-firebird using the following methodology, I have changed the Linux formula to suite the MacOS library locations as per this answer here
Issues compiling firebird driver for PHP-7.4 on macos:
git clone https://github.com/FirebirdSQL/php-firebird.git
cd php-firebird
phpize
CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Resources/lib ./configure
make
The error I get is
configure: error: libfbclient, libgds or libib_util not found! Check config.log for more information.
In the log file it refers to the following which is the crux of the issue
ld: warning: ignoring file /opt/firebird/lib/libib_util.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
The problem is that the Firebird package for Mac is only built for the 64bit architecture and not the ARM architecture.
Solution
I always seem to struggle building the extension for Firebird on MacOS (Intel or M1) and after a month of leaving the problem I discovered the solution which I leave here for myself all of you who have hit this wall, until ARM is supported on MacOS for Firebird we probably have to run the 64 bit version with 64 bit PHP. The steps below should get you up and running. I came up with 2 solutions, the first most obvious one was to make a docker build.
Docker Solution
docker run -v $(pwd):/app tina4stack/php -ini | grep interbase
Home brew solution
The second solution (more complicated) was to follow these steps, I don't always like to run a docker engine for simple things.
Install latest Firebird for MacOS
First, make sure you have installed the latest Firebird MacOS package, Firebird 3.0 at the time of writing has only one you can install.
The next problem I ran into was home-brew had installed an ARM version of PHP which made the linking to the x86_64 architecture impossible. Kudos to the documentation here https://austencam.com/posts/setting-up-an-m1-mac-for-laravel-development-with-homebrew-php-mysql-valet-and-redis
Install Rosetta
First I installed Rosetta (helps run 64 bit apps on MacOS ARM)
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Install Home-brew for 64bit architecture
Next I removed homebrew and reinstalled it with the arch -x86_64 bit flag
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install PHP7.4
Then installed a fresh php#7.4
arch -x86_64 brew install php#7.4
Compile the extension
git clone https://github.com/FirebirdSQL/php-firebird.git
cd php-firebird
phpize
CFLAGS='-arch x86_64' CPPFLAGS=-I/Library/Frameworks/Firebird.framework/Headers LDFLAGS=-L/Library/Frameworks/Firebird.framework/Resources/lib ./configure
make
sudo make install
Tying it all together
I added the following to my php.ini file
extension=interbase
If you don't know where to edit your ini file, run the following command:
php -ini | grep php.ini
When I ran php -ini | grep interpose I got errors about not finding the firebird libraries. In the end I copied the libraries to the PHP bin and lib folders
cp /Library/Frameworks/Firebird.framework/Resources/lib/* /usr/local/Cellar/php#7.4/7.4.25/lib
cp /Library/Frameworks/Firebird.framework/Resources/lib/* /usr/local/Cellar/php#7.4/7.4.25/bin
I'm sure someone could comment on making the above a bit neater but I was happy to find that the ini command returns now as expected.
php -ini | grep interbase
interbase
Let me know if you hit issues I didn't find, there were some other things I tried for the Firebird library resolution but I'm not sure they worked.
Installing modules with PECL
As an addition the the above solution, easily install other PHP modules using the following command
arch -x86_64 pecl install <module>
Example
arch -x86_64 pecl install openswoole
I am building h5py on Mac, following instructions "Building against Parallel HDF5" in this link: http://docs.h5py.org/en/latest/build.html
$ export CC=mpicc
$ python setup.py configure --mpi
$ sudo python setup.py build
I get this error:
h5py-2.5.0/h5py/api_compat.h:27:10: fatal error: 'hdf5.h' file not found
What should I do? If I need to install some dev version of HDF5, how can I do it on Mac?
I was getting this same error message yesterday, doing a general installation of HDF5 (not building against parallel). I was able to get around it by using Homebrew (a package manager for OS X that can be found here: http://brew.sh/).
Once you've installed Homebrew (if you don't already have it), the command is brew install hdf5.
You can find hdf5.h lib in your Unix and set in CPATH varible
freebsd 11 example:
>> find /usr -iname "*hdf5.h*"
<< /usr/local/include/hdf5.h
>> export CPATH="/usr/local/include/"
Then you can compile that you need
I want to get started with geodjango and for this I have to install gdal. I am using MacOS 10.8.3
In order to do so with brew as advised in the geodjango documentation but I get the following error :
$brew install gdal
==> Downloading http://download.osgeo.org/gdal/1.10.0/gdal-1.10.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/gdal-1.10.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/gdal/1.10.0 --mandir=/usr/local/Cellar/gdal/1.10.0/share/man --with-local=/usr/local/Cellar/gdal/1.10.0 --with-threads --with-libtool -
==> make
==> make install
==> /Users/Lucas/.virtualenvs/geotest/bin/python setup.py install --prefix=/usr/local/Cellar/gdal/1.10.0 --record=installed.txt --single-version-externally-managed
gcc-4.2 -bundle -undefined dynamic_lookup -g -L/usr/local/opt/sqlite/lib -lsqlite3 -I/usr/local/opt/sqlite/include -arch x86_64 build/temp.macosx-10.6-intel-2.7/extensions/gdalconst_wrap.o -L../../.libs -L../../ -L/private/tmp/gdal-gOux/gdal-1.10.0/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_gdalconst.so
Your Xcode and or CLT are mis-configured. Try some or all of the following:
xcodebuild -license
sudo xcode-select -switch /path/to/Xcode.app
error: command 'gcc-4.2' failed with exit status 1
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
These open issues may also help:
https://github.com/mxcl/homebrew/issues/19845
https://github.com/mxcl/homebrew/issues/20373
https://github.com/mxcl/homebrew/pull/20457
As advised, I did :
xcodebuild -license
and agreed to the licence, then :
sudo xcode-select -switch /Applications/Xcode.app
I also checked the issues but none of them was helpfull.
I have Xcode 4.6.3 installed and have brewed lots of other formulaes in the past without any problem.
When I run brew doctor, I get :
$brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
/Applications/Postgres.app/Contents/MacOS/bin/gdal-config
/Applications/Postgres.app/Contents/MacOS/bin/geos-config
/Applications/Postgres.app/Contents/MacOS/bin/uuid-config
/Applications/Postgres.app/Contents/MacOS/bin/xml2-config
I don't want to remove postgres.app from my path as it is necessary for the CLI of postgres.app configuration as explained here : http://postgresapp.com/documentation#toc_1
About the python from library, I tried to remove them using :
PATH=$(echo $PATH |sed 's/\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin//')
as advised here :https://www.linuxquestions.org/questions/linux-newbie-8/how-to-remove-directory-from-%24path-483463/. But it did not removed anything from the path.
So here I am not installing gdal ...
I found a workaround on SO, I can't find the original post but similar info is given on this one : Installing Scipy on Mac OS X Lion 10.7.5
So I added the following lines to my .bashrc and I then managed to brew install gdal.
export CC=gcc
export CXX=g++
Be aware that this did not solved my problem entirely as I still have config issue with geodjango, but at least I have gdal installed.
I am having trouble re-installing gfortran on my mac after upgrading to mountain lion.
I have:
Downloaded the latest version of XCode and installed command line tools.
I tried running gfortran but it is not available in gcc4.2 so...
I downloaded the latest version of fink and fink commander.
I downloaded gcc4.8 through fink and the install was performed successfully.
Now I am stuck, the gfortran command still does not work (command not found), there is also no gcc-4.8 or gfortran-4.8 in usr/bin and so I cannot rename gcc. If I run gcc-4.8 I also get "command not found".
I have spent hours on these sites but still cannot solve the problem, can anyone help me?
If you have installed fink in the default location then the gcc/gfortran/g++ packages should be be found in
/sw/bin
and called
/sw/bin/gcc-fsf-4.8
/sw/bin/gfortran-fsf-4.8
/sw/bin/g++-fsf-4.8
Create a bash script, SelectGCC-4.8.sh, with the following:
sudo cd /usr/local/bin
sudo rm cc gcc c++ g++
sudo ln -s /sw/bin/gcc-fsf-4.8 cc
sudo ln -s /sw/bin/gcc-fsf-4.8 gcc
sudo ln -s /sw/bin/c++-fsf-4.8 c++
sudo ln -s /sw/bin/g++-fsf-4.8 g++
NOTE: only the first sudo will ask for your password
I try download lighttpd 1.4.23 source, and compile it on MacOSX 10.5.5.
This is the error I am getting:
$ ./autogen.sh
./autogen.sh: running `libtoolize --copy --force'
./autogen.sh: line 19: libtoolize: command not found
I tried ask the same question on lighttpd forum, but I can't get any help there.
Thanks in advance.
libtoolize is part of GNU libtool, a package for building libraries portably. On the Mac, one option for getting it is to use MacPorts, a package manager which works in a similar fashion as Gentoo and FreeBSD, in that it compiles packages on your machine. See http://www.macports.org/install.php.
Beware, though, that it will be installed as glibtoolize, i.e. with a 'g' prefixed. That is a standard way to make GNU tools live in parallel with UNIX tools of the same name, that might be present (even though there isn't one in this particular case).
The command for installing libtool from MacPorts is: sudo port install libtool
Add a '-d' flag after the 'port' command to see the build output.
Here's what I use to install lighttpd 1.4.25 on Mac OS X 10.6.2. If I remember correctly, the same thing worked for me in a recent version of Mac OS X 10.5.
Install Xcode Developer Tools
Either install them from the DVD that came with your Mac (under Optional Installs) or download them from Apple's developer page.
Install PCRE
curl -O http://softlayer.dl.sourceforge.net/project/pcre/pcre/7.9/pcre-7.9.tar.gz
tar xzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && sudo make install
cd ../
Install lighttpd
curl -O http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.25.tar.gz
tar xzf lighttpd-*.tar.gz
cd lighttpd-*
./configure
make && sudo make install
Note that the URLs above will quickly go out of date; you may need to download the latest versions of the .tar.gz packages from a different location.