Click to See Complete Forum and Search --> : bzip2 results in bash: ./bzip2: No such file or directory


hardigunawan
07-09-2001, 10:43 AM
I compiled bzip2 as linux from scratch's book. I can run it in my original linux environment (by running /root/LFS/bin/bzip2). But when I chroot into /root/LFS, I can't execute bzip2 anymore. ( error is : bash: ./bzip2: No such file or directory). Other executables, such as tar, cat are working perfectly under chroot and outside chroot.

Anyone has experienced this? What should I check?

bdg1983
07-09-2001, 05:27 PM
To me, no such file or directory means it cannot find the command in the $PATH.

Does chroot change the PATH variable and is bzip2 (case correct?) in the same directory as tar and cat?

Rob 'Feztaa' Park
07-09-2001, 09:20 PM
Are you trying to run the command like this?

./bzip2

This looks for the program in the current directory only.

try just this:

bzip2

if that doesn't work, then you need to add it's directory to the $PATH

hardigunawan
07-10-2001, 01:55 AM
yes, bzip2 is in the same directory as tar and cat. I tried running it as ./bzip2, /bin/bzip2 and just bzip2. All gives me the same error.

I've not looked into the $PATH though. But since I ran /bin/bzip2, it should be enough w/o needing any $PATH. I'll have a look at it tonight. Thanks

Rob 'Feztaa' Park
07-10-2001, 04:43 PM
I guarantee you that ./bzip2 will only work if the bzip2 executeable is in the current directory, which means that command will only work when you're in /root/LFS/bin/

/bin/bzip2 looks for it starting at the top level directory. (it looks for it in /bin/bzip2, not /root/LFS/bin/bzip2)

bzip2 looks for it in the $PATH variable. type "echo $PATH" to see what directories are in your path. I'll bet that the right directory isn't there.

if you're in the /root/LFS folder, then typing "bin/bzip2" ought to work, but not "/bin/bzip2". The first one looks for bin as a subfolder of the current directory, the second looks for bin as a subfolder of the top level (/)

Anyway, make sure the $PATH variable points to the directory you've got bzip2 in, and all should be good.

hardigunawan
07-11-2001, 09:28 PM
I've found out what had happened!! :D
Yesterday, I tried to change my $PATH, etc, etc, but I still couldn't get it running.

So I recompiled linuxfromscratch's bzip2 and it works. The difference in my steps is the line:
sed \
s/"\$(CC) \$(CFLAGS) -o"/"\$(CC) \$(CFLAGS)
\$(LDFLAGS) -o"/ \
Makefile | make -f -
LDFLAGS=-static &&

At first I compiled it as:
sed s/"\$(CC) \$(CFLAGS) -o"/"\$(CC) $(CFLAGS)\$(LDFLAGS) -o"/ Makefile | make -f - LDFLAGS=-static &&

It should have been:
sed s/"\$(CC) \$(CFLAGS) -o"/"\$(CC) $(CFLAGS) \$(LDFLAGS) -o"/ Makefile | make -f - LDFLAGS=-static &&

There's a space between the $(CFLAGS) and \$(LDFLAGS)

Thanks to you all anyway :)