How can I force Homebrew to install 64-bit PostgreSQL on OSX SL? Specifically the libpg.dylib file - ruby

I have been trying to install the Ruby PG gem, but kept getting the "Failed to build gem native extension." error.
After sifting through a lot of google results, I tried nearly every recommendation I came across, all without luck. However, I believe I've tracked down the source of the problem ... Homebrew.
Homebrew installed PostgreSQL 9.0.4, but only with the 32-bit libraries. As I am running Snow Leopard (10.6.8) with XCode 3.26, I need the 64-bit libraries in order to compile everything without library mismatch errors. But I cannot seem to find out how to force Homebrew to install them, even with ARCHFLAGS and ENV set to "-arch x86_64".
Suggestions, please :)
p.s. I found out that I only had 32-bit libraries installed by running:
file /usr/local/Cellar/postgresql/9.0.4/lib/libpq.5.3.dylib
which returned:
/usr/local/Cellar/postgresql/9.0.4/lib/libpq.5.3.dylib: Mach-O dynamically linked shared library i386
Update: re-installed Homebrew, which installed postgresql/9.1.1 and 64-bit shared libraries.
But another problem emerged, while installing the PG gem. For some reason it was looking for ginstall in /opt/local/bin. As I had removed MacPorts, that directory was also removed. I did find this solution:
mkdir -p /opt/local/bin/
sudo ln -s /usr/bin/install /opt/local/bin/ginstall
And now everything seems to be working ....

So it looks like my first install, using Homebrew, must have been done with regular Leopard.
Removing the Homebrew "Cell" directory and all of its contents, running the install script again, then doing "brew install" and "brew update" with all needed packages, got me the latest version of PostgreSQL, with 64-bit developer library.
And creating the above symbolic link fixed any left over errors from the MacPorts removal.
Now all is well :)

Related

How do I build the Firebird database extension (ext-interbase) for PHP on a MacOS M1 Monterey?

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

Error installing Vim with Homebrew (checking for tgetent()... configure: error: NOT FOUND!)

After running brew install vim, I get this error:
checking for tgetent()... configure: error: NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib.
Not sure how to go about fixing this.
You need to install developer tools from Xcode before. Or set up your env handly but you might have other binaries missing later. So I recommend you to install Xcode. And then developer tools. And finally get Vim ;). I even think that Vim is installed by default with developer tools.
Get it here :
https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12
I ran into this problem as well. When running brew doctor, I found an ncurses5-config in the path, which seemed to be confusing homebrew. I uninstalled the chefdk, installed the latest xcode, run brew doctor to ensure the library is gone, and then run brew install vim.
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:
/opt/chefdk/embedded/bin/finstyle-config
/opt/chefdk/embedded/bin/ncurses5-config
/opt/chefdk/embedded/bin/ncursesw5-config
/opt/chefdk/embedded/bin/pkg-config
/opt/chefdk/embedded/bin/xml2-config
/opt/chefdk/embedded/bin/xslt-config
This worked for me on Mac 10.11.4
brew install vim --with-tlib
You might also want to use --with-override-system-vi flag as well

Why isn't cabal-install upgrading itself? [duplicate]

I just installed Haskell from it's official site. After that, following it's quick-start tutorial.
I run:
cabal update
Which shows this message:
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
I run:
cabal install cabal-install
and check if the update was successful with
cabal update
The result, it shows me the same message from the start:
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
So, did I upgrade the cabal-install or not? How do I check my cabal's version?
Important: I'm using the 64 bits version for Mac OS X.
In my case (and probably others?) cabal is initially installed in /usr/local/bin by homebrew when installing haskell-platform. When upgrading cabal, the version is installed to $HOME/.cabal/bin/cabal. You ought to place your cabal bins higher in your $PATH, like so:
export PATH=$HOME/.cabal/bin:$PATH
I had a similar issue after installing the Haskell platform 2012.4.0.0 on OSX. When I ran cabal install cabal-install, it ended with:
cabal: ../ghc-7.4.2/lib/cabal-install-1.16.0.2/bin/cabal: does not exist
So I guessed it got its paths mixed up somewhere. However the executable was actually built successfully (check for ~/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin/cabal) and I just copied it from there to ~/Library/Haskell/bin which is on my path.
Thereafter everything ran OK:
$ which cabal
/Users/luke/Library/Haskell/bin/cabal
$ cabal update
Downloading the latest package list from hackage.haskell.org
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0.3 of the Cabal library
Everyone seems to experience a slightly different issue here. In my case, cabal was built successfully and installed to ~/Library/Haskell/bin.
As noted in ~/.cabal/config, adding ~/Library/Haskell/bin to PATH solved the issue.
Below is the description in ~/.cabal/config:
-- === Built executables will be installed in:
-- ~/Library/Haskell/bin
--
-- You may wish to place this on your PATH by adding the following
-- line to your ~/.bash_profile:
-- export PATH="$HOME/Library/Haskell/bin:$PATH"
On OS X 10.8 I had to add /Library/Haskell/bin to my PATH (put it before /usr/bin). Adding that fixed the error message
cabal --version gives you the version of cabal you're running. If you want to see the version of cabal-install you have, run cabal info cabal-install and look at the versions installed line.
For me on OS X, versions installed is [unknown], after running cabal install cabal-install, which is not great.
I had this problem too.
After running which cabal, I found that it was using /usr/bin/cabal. Deleting this solved the problem.
It seems that cabal by default installs packages locally for the current user and therefore will not be part of the PATH. Look at the
Cabal documentation specifically step 1.2.1 where you can change the configuration to install things globally by default (not recommended).
The way I installed cabal was cabal --global install cabal-install but still had problems with the path which since the default installation of Haskell puts the path in this order C:\Program Files\Haskell Platform\2013.2.0.0\lib\extralibs\bin;C:\Program Files\Haskell Platform\2013.2.0.0\bin; where the first path has precedence over the second one. With the --global flag cabal installed the binary to C:\Program Files\Haskell\bin which isn't in my path but must be added before the C:\Program Files\Haskell Platform\2013.2.0.0\lib\extralibs\bin path.
Taken from the documentation
You must put the cabal.exe in a directory that is on your %PATH%, for example C:\Program Files\Haskell\bin.
In my case, a combination of several answers here was required to get through this issue. I'll attempt to provide a more comprehensive solution in one answer for anyone else in my situation.
For starters, running which cabal showed me that /usr/bin/cabal was being loaded, which was a symlink to /Library/Haskell/ghc-7.8.3-x86_64/bin/cabal. I believe newer versions of cabal were being installed, but this path was specific to a single version so they were ignored. Adding /Library/Haskell/bin to the front of my $PATH remedied that situation.
Second, and more importantly, the new versions of cabal-install were being installed into my cabal sandbox instead of the system location. I didn't see any other answers suggesting this, but after a little monkeying around I found that moving outside of my application's directory allowed cabal to actually install to the system.
Finally, adding the --global flag to the command fixed the problem. My final command was cabal install --global cabal-install. After this, I was finally able to update properly.
TL;DR: if you use cabal sandboxes, move outside the directory of your project and run cabal install --global cabal-install. Also, check your $PATH variable as others have suggested.
In my case the new version of cabal was being installed in the .cabal-sandbox of the project I was in.
e.g. Checking the version:
./.cabal-sandbox/bin/cabal --version
So I needed to upgrade it outside of that. This was on OSX.

fontforge building in brew, terminal cant find gcc error

This is my first time trying to compile source code in terminal (I installed gimp using macPorts but this could be part of the problem...?)
I want to install fontforge and I was following these instructions how to install fontforge.
I got this warning while installing brew:
Warning: The following *evil* dylibs exist in /usr/local/lib
They may break builds or worse. You should consider deleting them:
/usr/local/lib/libssl.0.9.8.dylib
I could not find usr/local/lib and the only libssl file was in opt/local/lib called libssl.1.0.0.dylib which is supposed to be hidden apparently...
I made it to the "brew install cairo --use-clang" step, then when I try the "brew install fontforge --use-gcc" step I get the following warning:
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing fontforge dependency: gettext
Error: GCC could not be found
when I check gcc version I get:
:~ me$ gcc --V
i686-apple-darwin11-llvm-gcc-4.2: no input files
Do I need to uninstall macports (then re-install gimp?)
I read gcc comes with xcode, I have xcode 4.3 (upgraded after this issue but didn't fix it) so do I have gcc or not? is there another way to check etc.
Can anyone tell me what I am doing wrong (what I broke etc)?
NOTE I also have flashbuilder which has a program called gcc as well (I dont know if this broke the other gcc...)

Problem with gcc 4.6 installation on ubuntu

I am trying to install gcc 4.6 (mainly for having C++0x better supported) in my ubuntu 9.10 (via virtualbox). I referred to previous questions, but I am getting a different error.
I am referring this link for the installation. Now, I have done till the ./gcc-xx/configure ... step. Though it was giving some flex package related error. Mostly due to that make is also failing with below errors:
build/gengtype.o: In function
adjust_field_rtx_def':
/home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:978:
undefined reference tolexer_line'
/home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:1032:
undefined reference to lexer_line'
/home/milind/ubuntu_shared/GCC/build/gcc/../../gcc-4.6-20110610/gcc/gengtype.c:1042:
undefined reference tolexer_line' ...............
Now this is giving me a hard time figuring it out because I have already flex/bison latest versions installed. I searched over internet for 2 days almost but no luck. Any help would be really appreciated. Also note that, I already have gcc 4.4 installed in /usr/bin/gcc and I have unzipped the gcc 4.6 tar in my home directory local folder.
[Note: I am also ok with installing ubuntu 11.10 too (which has gcc 4.6) as last resort. But I don't know if its .iso image is available.]
I got this fixed. I followed following procedure:
[Note: run all the commands with sudo, if you are not login as root. e.g. sudo ls -ltr; sudo make install;
As mentioned in the link in my
question, download the gcc4.6...tar
file in a temporary place
Now find the place where current
gcc is stored. e.g. My earlier
gcc4.4 was stored in
/usr/lib/gcc/i486-linux-gnu. Which
has a folder called 4.4, 4.4.1
Create a folder named 4.6 (or
4.6.1/2/3 etc.) and put that
.tar file inside it. Untar the
file as shown in link.
Follow all the procedure as per the
link. Use nohup <command> & to
track the logs. i.e. nohup make
clean all & followed by tail -f
nohup.out
If some error comes, it means some
package is missing. Mostly those
package will be present in your
current gcc version. You can
install them there itself. For
example, in my case zlib was
missing. I ran sudo apt-get install
zlib1g-dev libssl-dev and it worked
fine. Otherwise download from internet and install it.
Once your gcc is installed, you
can simply check it using type
gcc-4.6. In my case it showed that
it's stored as
/usr/local/bin/g++-4.6.
Either you can use the same path to
compile or you can put an alias in
your bash/tcsh/ksh. e.g.
/usr/local/bin/g++-4.6 -std=c++0x
-Wall test.cpp
FWIW Debian testing and unstable have gcc-4.6 as a standard package. So you can simply install that distro inside of virtualbox or, as I've done on my Ubuntu 11.04 server at home, via kvm. In the past, I also used to use dchroot build environments.
There may also be prepackaged gcc-4.6 binaries at launchpad.

Resources