Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dark Lain

macrumors member
Original poster
Apr 29, 2005
49
6
I am having trouble upgrading bzip2. To start off, yes I do have Developer Tools installed, and I have heard about Mac Ports and Fink.

Here is the output when I try to upgrade.

Code:
sudo make install
Password:

If compilation produces errors, or a large number of warnings,
please read README.COMPILATION.PROBLEMS -- you might be able to
adjust the flags in this Makefile to improve matters.

Also in README.COMPILATION.PROBLEMS are some hints that may help
if your build produces an executable which is unable to correctly
handle so-called 'large files' -- files of size 2GB or more.

gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c crctable.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c randtable.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c compress.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c decompress.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzlib.c
rm -f libbz2.a
ar cq libbz2.a blocksort.o huffman.o crctable.o randtable.o compress.o decompress.o bzlib.o
ranlib libbz2.a
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzip2.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64  -o bzip2 bzip2.o -L. -lbz2
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzip2recover.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64  -o bzip2recover bzip2recover.o
if ( test ! -d /usr/local/bin ) ; then mkdir -p /usr/local/bin ; fi
if ( test ! -d /usr/local/lib ) ; then mkdir -p /usr/local/lib ; fi
if ( test ! -d /usr/local/man ) ; then mkdir -p /usr/local/man ; fi
if ( test ! -d /usr/local/man/man1 ) ; then mkdir -p /usr/local/man/man1 ; fi
if ( test ! -d /usr/local/include ) ; then mkdir -p /usr/local/include ; fi
cp -f bzip2 /usr/local/bin/bzip2
cp -f bzip2 /usr/local/bin/bunzip2
cp -f bzip2 /usr/local/bin/bzcat
cp -f bzip2recover /usr/local/bin/bzip2recover
chmod a+x /usr/local/bin/bzip2
chmod a+x /usr/local/bin/bunzip2
chmod a+x /usr/local/bin/bzcat
chmod a+x /usr/local/bin/bzip2recover
cp -f bzip2.1 /usr/local/man/man1
chmod a+r /usr/local/man/man1/bzip2.1
cp -f bzlib.h /usr/local/include
chmod a+r /usr/local/include/bzlib.h
cp -f libbz2.a /usr/local/lib
chmod a+r /usr/local/lib/libbz2.a
cp -f bzgrep /usr/local/bin/bzgrep
ln -s -f /usr/local/bin/bzgrep /usr/local/bin/bzegrep
ln -s -f /usr/local/bin/bzgrep /usr/local/bin/bzfgrep
chmod a+x /usr/local/bin/bzgrep
cp -f bzmore /usr/local/bin/bzmore
ln -s -f /usr/local/bin/bzmore /usr/local/bin/bzless
chmod a+x /usr/local/bin/bzmore
cp -f bzdiff /usr/local/bin/bzdiff
ln -s -f /usr/local/bin/bzdiff /usr/local/bin/bzcmp
chmod a+x /usr/local/bin/bzdiff
cp -f bzgrep.1 bzmore.1 bzdiff.1 /usr/local/man/man1
chmod a+r /usr/local/man/man1/bzgrep.1
chmod a+r /usr/local/man/man1/bzmore.1
chmod a+r /usr/local/man/man1/bzdiff.1
echo ".so man1/bzgrep.1" > /usr/local/man/man1/bzegrep.1
echo ".so man1/bzgrep.1" > /usr/local/man/man1/bzfgrep.1
echo ".so man1/bzmore.1" > /usr/local/man/man1/bzless.1
echo ".so man1/bzdiff.1" > /usr/local/man/man1/bzcmp.1

However when I enter "bzip2 -V", it still shows "Version 1.0.5"

Thanks in advance for an help
 
I think the command you should try is "which -a bzip2" - this should list all instances of bzip2 on your machine. Most likely when you're calling bzip2, it's using the built-in version.

I don't know directly how to force it to use the newer one though. I'm sure there's a way. Otherwise you can just use the absolute path to it - /usr/local/bin/bzip2
 
Thanks for the reply and the advice, however.

Code:
$ which -a bzip2
/usr/bin/bzip2
/usr/local/bin/bzip2

and when I tried "/usr/bin/bzip2 -V" and "/usr/local/bin/bzip2" both returned "Version 1.0.5"
 
What about when you run the executable that didn't get copied, from the bzip2 source folder?

Maybe you only have the 1.0.5 source and need to re-download the 1.0.6 one.
 
Nope, that didn't work. I re-downloaded from http://bzip.org/downloads.html


Code:
$ sudo make install
Password:

If compilation produces errors, or a large number of warnings,
please read README.COMPILATION.PROBLEMS -- you might be able to
adjust the flags in this Makefile to improve matters.

Also in README.COMPILATION.PROBLEMS are some hints that may help
if your build produces an executable which is unable to correctly
handle so-called 'large files' -- files of size 2GB or more.

gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c blocksort.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c huffman.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c crctable.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c randtable.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c compress.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c decompress.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzlib.c
rm -f libbz2.a
ar cq libbz2.a blocksort.o huffman.o crctable.o randtable.o compress.o decompress.o bzlib.o
ranlib libbz2.a
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzip2.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64  -o bzip2 bzip2.o -L. -lbz2
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -c bzip2recover.c
gcc -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64  -o bzip2recover bzip2recover.o
if ( test ! -d /usr/local/bin ) ; then mkdir -p /usr/local/bin ; fi
if ( test ! -d /usr/local/lib ) ; then mkdir -p /usr/local/lib ; fi
if ( test ! -d /usr/local/man ) ; then mkdir -p /usr/local/man ; fi
if ( test ! -d /usr/local/man/man1 ) ; then mkdir -p /usr/local/man/man1 ; fi
if ( test ! -d /usr/local/include ) ; then mkdir -p /usr/local/include ; fi
cp -f bzip2 /usr/local/bin/bzip2
cp -f bzip2 /usr/local/bin/bunzip2
cp -f bzip2 /usr/local/bin/bzcat
cp -f bzip2recover /usr/local/bin/bzip2recover
chmod a+x /usr/local/bin/bzip2
chmod a+x /usr/local/bin/bunzip2
chmod a+x /usr/local/bin/bzcat
chmod a+x /usr/local/bin/bzip2recover
cp -f bzip2.1 /usr/local/man/man1
chmod a+r /usr/local/man/man1/bzip2.1
cp -f bzlib.h /usr/local/include
chmod a+r /usr/local/include/bzlib.h
cp -f libbz2.a /usr/local/lib
chmod a+r /usr/local/lib/libbz2.a
cp -f bzgrep /usr/local/bin/bzgrep
ln -s -f /usr/local/bin/bzgrep /usr/local/bin/bzegrep
ln -s -f /usr/local/bin/bzgrep /usr/local/bin/bzfgrep
chmod a+x /usr/local/bin/bzgrep
cp -f bzmore /usr/local/bin/bzmore
ln -s -f /usr/local/bin/bzmore /usr/local/bin/bzless
chmod a+x /usr/local/bin/bzmore
cp -f bzdiff /usr/local/bin/bzdiff
ln -s -f /usr/local/bin/bzdiff /usr/local/bin/bzcmp
chmod a+x /usr/local/bin/bzdiff
cp -f bzgrep.1 bzmore.1 bzdiff.1 /usr/local/man/man1
chmod a+r /usr/local/man/man1/bzgrep.1
chmod a+r /usr/local/man/man1/bzmore.1
chmod a+r /usr/local/man/man1/bzdiff.1
echo ".so man1/bzgrep.1" > /usr/local/man/man1/bzegrep.1
echo ".so man1/bzgrep.1" > /usr/local/man/man1/bzfgrep.1
echo ".so man1/bzmore.1" > /usr/local/man/man1/bzless.1
echo ".so man1/bzdiff.1" > /usr/local/man/man1/bzcmp.1

Then ran
Code:
$ which -a bzip2
/usr/bin/bzip2
/usr/local/bin/bzip2

Checked both with
Code:
bzip2 -V

With the same result.

I will try e-mailing the address at http://bzip.org/downloads.html
and see if he has any insight.
 
I think I know why. It's referencing /usr/lib/libbz2.1.0.dylib which is the old version 1.0.5, and when you install, it gets installed into /usr/local/lib so you need to somehow make it so it installs into /usr and not usr/local. There usually is a flag you can pass for the installation directory. Or you can sometimes pass a flag to make it not use shared libraries.
 
Sorry, that din't work either.


Code:
$ sudo make install PREFIX=/usr
Password:
if ( test ! -d /usr/bin ) ; then mkdir -p /usr/bin ; fi
if ( test ! -d /usr/lib ) ; then mkdir -p /usr/lib ; fi
if ( test ! -d /usr/man ) ; then mkdir -p /usr/man ; fi
if ( test ! -d /usr/man/man1 ) ; then mkdir -p /usr/man/man1 ; fi
if ( test ! -d /usr/include ) ; then mkdir -p /usr/include ; fi
cp -f bzip2 /usr/bin/bzip2
cp -f bzip2 /usr/bin/bunzip2
cp -f bzip2 /usr/bin/bzcat
cp -f bzip2recover /usr/bin/bzip2recover
chmod a+x /usr/bin/bzip2
chmod a+x /usr/bin/bunzip2
chmod a+x /usr/bin/bzcat
chmod a+x /usr/bin/bzip2recover
cp -f bzip2.1 /usr/man/man1
chmod a+r /usr/man/man1/bzip2.1
cp -f bzlib.h /usr/include
chmod a+r /usr/include/bzlib.h
cp -f libbz2.a /usr/lib
chmod a+r /usr/lib/libbz2.a
cp -f bzgrep /usr/bin/bzgrep
ln -s -f /usr/bin/bzgrep /usr/bin/bzegrep
ln -s -f /usr/bin/bzgrep /usr/bin/bzfgrep
chmod a+x /usr/bin/bzgrep
cp -f bzmore /usr/bin/bzmore
ln -s -f /usr/bin/bzmore /usr/bin/bzless
chmod a+x /usr/bin/bzmore
cp -f bzdiff /usr/bin/bzdiff
ln -s -f /usr/bin/bzdiff /usr/bin/bzcmp
chmod a+x /usr/bin/bzdiff
cp -f bzgrep.1 bzmore.1 bzdiff.1 /usr/man/man1
chmod a+r /usr/man/man1/bzgrep.1
chmod a+r /usr/man/man1/bzmore.1
chmod a+r /usr/man/man1/bzdiff.1
echo ".so man1/bzgrep.1" > /usr/man/man1/bzegrep.1
echo ".so man1/bzgrep.1" > /usr/man/man1/bzfgrep.1
echo ".so man1/bzmore.1" > /usr/man/man1/bzless.1
echo ".so man1/bzdiff.1" > /usr/man/man1/bzcmp.1
 
Start from fresh download, and this time edit the Makefile before running sudo make install. Change the PREFIX line below:


Code:
# ------------------------------------------------------------------
# This file is part of bzip2/libbzip2, a program and library for
# lossless, block-sorting data compression.
#
# bzip2/libbzip2 version 1.0.6 of 6 September 2010
# Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
#
# Please read the WARNING, DISCLAIMER and PATENTS sections in the 
# README file.
#
# This program is released under the terms of the license contained
# in the file LICENSE.
# ------------------------------------------------------------------

SHELL=/bin/sh

# To assist in cross-compiling
CC=gcc
AR=ar
RANLIB=ranlib
LDFLAGS=

BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)

# Where you want it installed when you do 'make install'
PREFIX=/usr/local


But kainjow is right. The problem is that the bzip2 binary is linked to the existing libbz2.dylib in /usr/lib. This is why I like Macports---someone else can figure this out and get it to work.

Of course, Apple will eventually update this ...

Code:
Procyon: ~] which bzip2
/opt/local/bin/bzip2
Procyon: ~] bzip2 --version
bzip2, a block-sorting file compressor.  Version 1.0.6, 6-Sept-2010.
   
   Copyright (C) 1996-2010 by Julian Seward.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms set out in the LICENSE file, which is included
   in the bzip2-1.0.6 source distribution.

Thus the Macports version is up-to-date. So I just made /usr/bin/bzip2 a symbolic link to /opt/local/bin/bzip2
 
Sorry editing the Prefix and then "sudo make install" and still only get "Version 1.0.5".
 
Sorry editing the Prefix and then "sudo make install" and still only get "Version 1.0.5".

Yeah, the real problem is that the Makefile creates only a static library and not a dynamic library. Then the binary links incorrectly with the old libbz2.dylib in /usr/lib

So the Makefile needs patching. Here's the Macports patch file, which should provide you with the modifications you need to make:

Code:
--- Makefile.orig       2008-02-14 06:39:18.000000000 -0600
+++ Makefile    2009-02-14 16:48:03.000000000 -0600
@@ -35,9 +35,9 @@
       decompress.o \
       bzlib.o
 
-all: libbz2.a bzip2 bzip2recover test
+all: libbz2.a libbz2.dylib bzip2 bzip2recover test
 
-bzip2: libbz2.a bzip2.o
+bzip2: libbz2.a libbz2.dylib bzip2.o
        $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
 
 bzip2recover: bzip2recover.o
@@ -52,15 +52,23 @@
                $(RANLIB) libbz2.a ; \
        fi
 
+libbz2.dylib: $(OBJS)
+       rm -f libbz2.dylib
+       $(CC) -dynamiclib $(OBJS) -o libbz2.__MacPorts_Version__.dylib \
+               -install_name $(PREFIX)/lib/libbz2.__MacPorts_Compatibility_Version__.dylib \
+               -compatibility_version __MacPorts_Compatibility_Version__ -current_version __MacPorts_Version__
+       ln -s libbz2.__MacPorts_Version__.dylib libbz2.__MacPorts_Compatibility_Version__.dylib
+       ln -s libbz2.__MacPorts_Version__.dylib libbz2.dylib
+
 check: test
 test: bzip2
        @cat words1
-       ./bzip2 -1  < sample1.ref > sample1.rb2
-       ./bzip2 -2  < sample2.ref > sample2.rb2
-       ./bzip2 -3  < sample3.ref > sample3.rb2
-       ./bzip2 -d  < sample1.bz2 > sample1.tst
-       ./bzip2 -d  < sample2.bz2 > sample2.tst
-       ./bzip2 -ds < sample3.bz2 > sample3.tst
+       DYLD_LIBRARY_PATH=. ./bzip2 -1  < sample1.ref > sample1.rb2
+       DYLD_LIBRARY_PATH=. ./bzip2 -2  < sample2.ref > sample2.rb2
+       DYLD_LIBRARY_PATH=. ./bzip2 -3  < sample3.ref > sample3.rb2
+       DYLD_LIBRARY_PATH=. ./bzip2 -d  < sample1.bz2 > sample1.tst
+       DYLD_LIBRARY_PATH=. ./bzip2 -d  < sample2.bz2 > sample2.tst
+       DYLD_LIBRARY_PATH=. ./bzip2 -ds < sample3.bz2 > sample3.tst
        cmp sample1.bz2 sample1.rb2 
        cmp sample2.bz2 sample2.rb2
        cmp sample3.bz2 sample3.rb2
@@ -89,6 +98,7 @@
        chmod a+r $(PREFIX)/include/bzlib.h
        cp -f libbz2.a $(PREFIX)/lib
        chmod a+r $(PREFIX)/lib/libbz2.a
+       cp -f libbz2.__MacPorts_Version__.dylib $(PREFIX)/lib
        cp -f bzgrep $(PREFIX)/bin/bzgrep
        ln -s -f bzgrep $(PREFIX)/bin/bzegrep
        ln -s -f bzgrep $(PREFIX)/bin/bzfgrep
@@ -109,7 +123,7 @@
        ln -s -f bzdiff.1 $(PREFIX)/share/man/man1/bzcmp.1
 
 clean: 
-       rm -f *.o libbz2.a bzip2 bzip2recover \
+       rm -f *.o libbz2.a libbz2.*.dylib bzip2 bzip2recover \
        sample1.rb2 sample2.rb2 sample3.rb2 \
        sample1.tst sample2.tst sample3.tst
 
So, I just replace the original makefile with yours?

By the way, Thanks for all the help so far.
 
So, I just replace the original makefile with yours?

By the way, Thanks for all the help so far.

Not exactly. What I posted was a patch file, which indicates how to modify the existing Makefile to create a new Makefile that will work the way we want. Some of the changes are probably specific to Macports.

I'll make things easier and post an actual Makefile soon, after I test that it works correctly.

[EDIT] A Makefile is attached. Rename it as Makefile without the .txt extension. Download a clean copy of the bzip2 package, and replace the existing Makefile with the attached one. Then in Terminal do

Code:
make

followed by

Code:
sudo make install

(The new bzip files will install into /usr, replacing the old bzip files.)


I've tested this carefully and it works fine for me.

[EDIT] Actually, it doesn't, since the libs and binaries are not universal. Need to fix the Makefile.

This is a good example of why one is almost always better off waiting for Apple to update stuff in /usr, or to use something like Macports.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.