Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I currently attempting to build LFS version 9.0 with systemd.
I'm in chapter 6, currently trying to build file-5.37, but I'm having an issue and I'm pulling my hair out trying to figure out what's happening.
Everything else has gone (relatively) well so far, but when I attempt to build file I get an error.
Code:
[root@chroot file-5.37]# make
make all-recursive
make[1]: Entering directory '/sources/file-5.37'
Making all in src
make[2]: Entering directory '/sources/file-5.37/src'
make all-am
make[3]: Entering directory '/sources/file-5.37/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/sources/file-5.37/src'
make[2]: Leaving directory '/sources/file-5.37/src'
Making all in magic
make[2]: Entering directory '/sources/file-5.37/magic'
../src/file -C -m magic
/sources/file-5.37/src/.libs/lt-file: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make[2]: *** [Makefile:816: magic.mgc] Error 127
make[2]: Leaving directory '/sources/file-5.37/magic'
make[1]: *** [Makefile:399: all-recursive] Error 1
make[1]: Leaving directory '/sources/file-5.37'
make: *** [Makefile:331: all] Error 2
Okay so it can't seem to find libz.so.1.
But...
Code:
[root@chroot file-5.37]# ls /lib/libz.*
/lib/libz.a /lib/libz.so /lib/libz.so.1 /lib/libz.so.1.2.11
I have deviated from the book in that I've merged /usr, so /lib is a symlink to /usr/lib, but I've tried creating a copy of /usr/lib at /lib instead with the same result.
It's ld that can't find the library. You should be using the new version of ld, the one originally created as ld-new, which has /lib and /usr/lib in its search path. Are you sure you carried out that adjustment (after installing glibc)? Did you carry out all the sanity checks before proceeding? You might want to carry out the verbose sanity check in 6.10 again and post the results.
Clearly I mucked something up.
I probably mistyped something during the compilation process.
I've been typing most of the commands by hand as I get a better hold of what's happening that way. But I'm far-sighted and mildly dyslexic, so it's easy to mess up. I'm pretty careful about double checking, but mistakes can still slip through.
I either messed up in the compile, or possibly somewhere else. I am at a loss.
Hopefully I don't have to restart. I'm not far in, but it would still be tedious.
Don't type by hand! That's the first thing you learn with LFS. Always copy and paste, especially if you're dyslexic. Even if you aren't it's easy to make mistakes. And it's pointless to turn a Linux build into a test of typing skills.
I'm afraid I can't diagnose your problem any further. The most likely cause of the failure to find zlib would be that ld was still looking in /tools/lib (which doesn't contain a copy) but that seems not to be the case with you. One other possibility is that you forgot to configure ld after building your final final glibc. You could try that now and see if it makes any difference. It's in section 6.9.2.3.
If it's any comfort, the first LFS build usually doesn't work.
Well, I haven't a clue where it went wrong. Guess I'm restarting.
That's annoying. At least I wasn't in chapter 8 or something before finding it went wrong.
I wasn't really typing the commands to practice typing, it was more about paying attention to what they're doing.
If I copy and past every command I have a tendency to only skim over what's happening. By typing it out I'm forced to slow down and look at what the command is doing in more depth. And if I get it wrong, it just shows me that I wasn't looking close enough. XP
I still don't bother with larger, more tedious or more complex commands though. If it's more easily run as a script I'll past it to a script and run that instead.
The second time around I have no problem copying and pasting. And I'll probably start making proper archives of critical files between the larger steps, that way I can revert back to any given point if I do happen to screw up again.
I suspect I can just clear out most of the files that have been created thus far. No need to destroy the directory structure.
I can probably even leave some of the config files in /etc. (Or at least set them aside for later.)
Yes, if you are going to start again, you can leave the directory structure and /sources, but I would clear out /tools completely, together with all other directory contents. For /lib, you could get away with just emptying the directory but it would probably be quicker to delete the /usr tree completely and recreate it.
I would also clear out /etc. Saving the config files elsewhere (for example in /root) is a good idea. I tend to copy the /etc files across from one LFS to the next rather than recreating them for each build.
Did you try reconfiguring ld as I suggested. It's a long shot but it might perhaps work.
Another possibility (if you saved your unmodified tool set as suggested in the book) would be to reinstate the saved set in /tools and start again with Chapter 6.
I can't remember it exactly at the moment, but I remember using a find command once to delete everything that isn't a directory. If I can remember how to do that, it may save me some time with rebuilding the /usr directory.
I did try setting the path in the config, but it didn't seem to change anything. Plus I'm pretty sure if I have to manually direct ld at /lib, I probably messed up bad enough that I should retry. XD
I do with I had properly archived /tools before moving on, but I tried to be lazy and in the process forgot that cp doesn't, by default, traverse symlinks.
I'm worried that the problem started back in chapter 5 anyway, so I'll just go back and be sure to do it right. By the end of it I should have a known-good staring point, and an archive of it an case things go wrong again, or I want to build another system.
Edit:
For future reference. If anyone was wondering what the find command is:
Code:
find <dir> -type f -type l -delete
'-type f' selects all regular files and '-type l' selects any links.
If you want more control over what's being deleted you could use '-exec rm -iv {} \;' instead of '-delete'. If you don't want it to prompt you just use 'f' instead of 'i' so that it forces the removal but still shows what was removed.
Last edited by CPT-GrayWolf; 09-21-2019 at 11:05 AM.
Reason: Added information on command I couldn't remember at the time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.