software building 11 ruydodrt5a2jmrwkndrlzz4khac6w4jsqvoidyi ruydodrt5a2jmrwkndrlzz4khac6w4jsqvoidyi RUYDODRT5A2JMRWKNDRLZZ4KHAC6W4JSQVOIDYI


Building and Installing Software Packages for Linux: Third Example: Fortune 11. Third Example: FortuneThis final example requires some knowledge of C programming. The majority of UNIX/Linux software is written in C, and learning at least a little bit of C would certainly be an asset for anyone serious about software installation.The notorious fortune program displays up a humorous saying, a "fortune cookie", every time Linux boots up. Unfortunately (pun intended), attempting to build fortune on a Red Hat distribution with a 2.0.30 kernel generates fatal errors. ~/fortune# make all gcc -O2 -Wall -fomit-frame-pointer -pipe -c fortune.c -o fortune.o fortune.c: In function `add_dir': fortune.c:551: structure has no member named `d_namlen' fortune.c:553: structure has no member named `d_namlen' make[1]: *** [fortune.o] Error 1 make[1]: Leaving directory `/home/thegrendel/for/fortune/fortune' make: *** [fortune-bin] Error 2Looking at fortune.c, the pertinent lines are these. if (dirent->d_namlen == 0) continue; name = copy(dirent->d_name, dirent->d_namlen);We need to find the structure dirent, but it is not declared in the fortune.c file, nor does a grep dirent show it in any of the other source files. However, at the top of fortune.c, there is the following line. #include <dirent.h>This appears to be a system library include file, therefore, the logical place to look for dirent.h is in /usr/include. Indeed, there does exist a dirent.h file in /usr/include, but that file does not contain the declaration of the dirent structure. There is, however, a reference to another dirent.h file. #include <linux/dirent.h>At last, going to /usr/include/linux/dirent.h, we find the structure declaration we need. struct dirent { long d_ino; __kernel_off_t d_off; unsigned short d_reclen; char d_name[256]; /* We must not include limits.h! */ };Sure enough, the structure declaration contains no d_namelen, but there are a couple of "candidates" for its equivalent. The most likely of these is d_reclen, since this structure member probably represents the length of something and it is a short integer. The other possibility, d_ino, could be an inode number, judging by its name and type. As a matter of fact, we are probably dealing with a "directory entry" structure, and these elements represent attributes of a file, its name, inode, and length (in blocks). This would seem to validate our guess.Let us edit the file fortune.c, and change the two d_namelen references in lines 551 and 553 to d_reclen. Try a make all again. Success. It builds without errors. We can now get our "cheap thrills" from fortune. 2

Wyszukiwarka

Podobne podstrony:
software building 6 2ocvurnawmtlrc3nobvr5ybctyvu4z555g7oeiq 2ocvurnawmtlrc3nobvr5ybctyvu4z555g7oeiq
software building 8 e4uyh3qkwxjc7pme5ousvqulimbc3x5q6hwh2di e4uyh3qkwxjc7pme5ousvqulimbc3x5q6hwh2di
software building 4 ow4u7ftjqix6ypyajyiausw6ljbnsk4lccnikpi ow4u7ftjqix6ypyajyiausw6ljbnsk4lccnikpi
software building rk7wcyx6ll4z62ay6pxhl7zsmijpswjrdb3qt6a rk7wcyx6ll4z62ay6pxhl7zsmijpswjrdb3qt6a
software building 2 n76ie6xpeb3tkzsblytpeqzqkz2gq3dvxytjrra n76ie6xpeb3tkzsblytpeqzqkz2gq3dvxytjrra
software building 3 cm4c3mvlq633x2fbs3nkewycw6by57oa3d3gvhy cm4c3mvlq633x2fbs3nkewycw6by57oa3d3gvhy
software building 10 qphvkeqmjh45xg5kqrp7ve2cjksv5iet2yw7t6a qphvkeqmjh45xg5kqrp7ve2cjksv5iet2yw7t6a
software building 7 gvqwxnhhh6cp42g7acdoucihxzm3dxkcuizdtka gvqwxnhhh6cp42g7acdoucihxzm3dxkcuizdtka
software building 13 mgyrdfdbroezamwrbct7xrjmnwjih5u5euadhma mgyrdfdbroezamwrbct7xrjmnwjih5u5euadhma
software building 5 z4naps6edff5df6r2cjzhoabg3kkdtaiislc3za z4naps6edff5df6r2cjzhoabg3kkdtaiislc3za
software building 1 4mtij5nhoj6dihjrdfhj5ed4gtky4376odatrxq 4mtij5nhoj6dihjrdfhj5ed4gtky4376odatrxq
software building 14 wqgkthak6yuioaph52rogh75d4n2rdp5bnaqv7q wqgkthak6yuioaph52rogh75d4n2rdp5bnaqv7q
software building 12 zvmjr3cx2kxg2soy4tu2wczso5tyoaa2qfkxgma zvmjr3cx2kxg2soy4tu2wczso5tyoaa2qfkxgma
software building 9 2inhqd5wjqaqos5nqjqk7dqsszz4na7guvhab7i 2inhqd5wjqaqos5nqjqk7dqsszz4na7guvhab7i
software raid 11 lpy3lsjabwr2phpxcg7lutsqbzpjwcpxwaglwla lpy3lsjabwr2phpxcg7lutsqbzpjwcpxwaglwla
2000 11 Corel Photopaint 9 Image Editing Software
11 (311)
ZADANIE (11)

więcej podobnych podstron