📄 g77install.texi
字号:
(The output also is likely to include a diagnostic fromthe linker, since there's no @samp{main_()} function.)However, you do have to sift through it yourself; @code{gcc}currently provides no easy way to ask it where it is installedand where it looks for the various programs and data files itcalls on to do its work.Just @emph{building} @code{g77} should not overwrite any installedprograms---but, usually, after you build @code{g77}, you will wantto install it, so backing up anything it might overwrite isa good idea.(This is true for any package, not just @code{g77},though in this case it is intentional that @code{g77} overwrites@code{gcc} if it is already installed---it is unusual thatthe installation process for one distribution intentionallyoverwrites a program or file installed by another distribution,although, in this case, @code{g77} is an augmentation of the@code{gcc} distribution.)Another reason to back up the existing version first,or make sure you can restore it easily, is that it might bean older version on which other users have come to dependfor certain behaviors.However, even the new version of @code{gcc} you installwill offer users the ability to specify an older version ofthe actual compilation programs if desired, and theseolder versions need not include any @code{g77} components.@xref{Target Options,,Specifying Target Machine and Compiler Version,gcc,Using and Porting GNU CC}, for information on the @samp{-V}option of @code{gcc}.@node Configuring gcc@subsection Configuring GNU CC@code{g77} is configured automatically when you configure@code{gcc}.There are two parts of @code{g77} that are configured in twodifferent ways---@code{g77}, which ``camps on'' to the@code{gcc} configuration mechanism, and @code{libg2c}, whichuses a variation of the GNU @code{autoconf} configurationsystem.Generally, you shouldn't have to be concerned witheither @code{g77} or @code{libg2c} configuration, unlessyou're configuring @code{g77} as a cross-compiler.In this case, the @code{libg2c} configuration, and possibly the@code{g77} and @code{gcc} configurations as well,might need special attention.(This also might be the case if you're porting @code{gcc} toa whole new system---even if it is just a new operating systemon an existing, supported CPU.)To configure the system, see@ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC},following the instructions for running @file{./configure}.Pay special attention to the @samp{--prefix=} option, whichyou almost certainly will need to specify.(Note that @code{gcc} installation information is providedas a plain-text file in @file{gcc/INSTALL}.)The information printed by the invocation of @file{./configure}should show that the @file{f} directory (the Fortran language)has been configured.If it does not, there is a problem.@emph{Note:} Configuring with the @samp{--srcdir} argument,or by starting in an empty directoryand typing a command such as @kbd{../gcc/configure} tobuild with separate build and source directories,is known to work with GNU @code{make},but it is known to not work with other variants of @code{make}.Irix5.2 and SunOS4.1 versions of @code{make} definitelywon't work outside the source directory at present.@code{g77}'s portion of the @file{configure} scriptused to issue a warning message about thiswhen configuring for building binaries outside the source directory,but no longer does this as of version 0.5.23.Instead, @code{g77} simply rejects most common attemptsto build it using a non-GNU @code{make} when thebuild directory is not the same as the source directory,issuing an explanatory diagnostic.@node Building gcc@subsection Building GNU CC@cindex building @code{gcc}@cindex building @code{g77}@cindex @code{LANGUAGES} macroBuilding @code{g77} requires building enough of @code{gcc} thatthese instructions assume you're going to build all of@code{gcc}, including @code{g++}, @code{protoize}, and so on.You can save a little time and disk space by changes the@code{LANGUAGES} macro definition in @code{gcc/Makefile.in}or @code{gcc/Makefile}, but if you do that, you're on your own.One change is almost @emph{certainly} going to cause failures:removing @code{c} or @code{f77} from the definition of the@code{LANGUAGES} macro.After configuring @code{gcc}, which configures @code{g77} and@code{libg2c} automatically, you're ready to start the actualbuild by invoking @code{make}.@pindex configure@emph{Note:} You @strong{must} have run the @file{configure}script in @code{gcc} before you run @code{make},even if you're using an already existing @code{gcc} development directory,because @file{./configure} does the work to recognize that you've added@code{g77} to the configuration.There are two general approaches to building GNU CC fromscratch:@table @dfn@item bootstrapThis method uses minimal native system facilities tobuild a barebones, unoptimized @code{gcc}, that is thenused to compile (``bootstrap'') the entire system.@item straightThis method assumes a more complete native systemexists, and uses that just once to build the entiresystem.@end tableOn all systems without a recent version of @code{gcc}already installed, the @i{bootstrap} method must beused.In particular, @code{g77} uses extensions to the Clanguage offered, apparently, only by @code{gcc}.On most systems with a recent version of @code{gcc}already installed, the @i{straight} method can beused.This is an advantage, because it takes less CPU timeand disk space for the build.However, it does require that the system have fairlyrecent versions of many GNU programs and otherprograms, which are not enumerated here.@menu* Bootstrap Build:: For all systems.* Straight Build:: For systems with a recent version of @code{gcc}.@end menu@node Bootstrap Build@subsubsection Bootstrap Build@cindex bootstrap build@cindex build, bootstrapA complete bootstrap build is done by issuing a commandbeginning with @samp{make bootstrap @dots{}}, asdescribed in @ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC}.This is the most reliable form of build, but it does requirethe most disk space and CPU time, since the complete systemis built twice (in Stages 2 and 3), after an initial build(during Stage 1) of a minimal @code{gcc} compiler usingthe native compiler and libraries.You might have to, or want to, control the way a bootstrapbuild is done by entering the @code{make} commands to buildeach stage one at a time, as described in the @code{gcc}manual.For example, to save time or disk space, you might wantto not bother doing the Stage 3 build, in which case youare assuming that the @code{gcc} compiler you have builtis basically sound (because you are giving up the opportunityto compare a large number of object files to ensure they'reidentical).To save some disk space during installation, after Stage 2is built, you can type @samp{rm -fr stage1} to remove thebinaries built during Stage 1.Also, see @ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC},for important information on building @code{gcc} that isnot described in this @code{g77} manual.For example, explanations of diagnostic messagesand whether they're expected, or indicate trouble,are found there.@node Straight Build@subsubsection Straight Build@cindex straight build@cindex build, straightIf you have a recent version of @code{gcc}already installed on your system, and if you'rereasonably certain it produces code that isobject-compatible with the version of @code{gcc}you want to build as part of building @code{g77},you can save time and disk space by doing a straightbuild.To build just the compilers along with thenecessary run-time libraries, issue the followingcommand:@examplemake -k CC=gcc@end exampleIf you run into problems using this method, you havetwo options:@itemize @bullet@itemAbandon this approach and do a bootstrap build.@itemTry to make this approach work by diagnosing theproblems you're running into and retrying.@end itemizeEspecially if you do the latter, you might considersubmitting any solutions as bug/fix reports.@xref{Trouble,,Known Causes of Trouble with GNU Fortran}.However, understand that many problems preventing astraight build from working are not @code{g77} problems,and, in such cases, are not likely to be addressed infuture versions of @code{g77}.Consider treating them as @code{gcc} bugs instead.@node Pre-installation Checks@subsection Pre-installation Checks@cindex pre-installation checks@cindex installing, checking beforeBefore installing the system, which includes installing@code{gcc}, you might want to do some minimum checkingto ensure that some basic things work.Here are some commands you can try, and output typicallyprinted by them when they work:@examplesh# @kbd{cd /usr/src/gcc}sh# @kbd{./g77 -B./ -v}g77 version @value{version-g77}Driving: ./g77 -B./ -v -c -xf77-version /dev/null -xnoneReading specs from ./specsgcc version @value{version-gcc} cpp -lang-c -v -isystem ./include -undef -D__GNUC__=2 @dots{}GNU CPP version @value{version-gcc} (Alpha GNU/Linux with ELF)#include "..." search starts here:#include <...> search starts here: include /usr/alpha-linux/include /usr/lib/gcc-lib/alpha-linux/@value{version-gcc}/include /usr/includeEnd of search list. ./f771 -fnull-version -quiet -dumpbase g77-version.f -version @dots{}GNU F77 version @value{version-gcc} (alpha-linux) compiled @dots{}GNU Fortran Front End version @value{version-g77} as -nocpp -o /tmp/cca14485.o /tmp/cca14485.s ld -m elf64alpha -G 8 -O1 -dynamic-linker /lib/ld-linux.so.2 @dots{} /tmp/cca14485__G77_LIBF77_VERSION__: @value{version-g77}@@(#)LIBF77 VERSION 19970919__G77_LIBI77_VERSION__: @value{version-g77}@@(#) LIBI77 VERSION pjw,dmg-mods 19980405__G77_LIBU77_VERSION__: @value{version-g77}@@(#) LIBU77 VERSION 19970919sh# @kbd{./xgcc -B./ -v -o /tmp/delete-me -xc /dev/null -xnone}Reading specs from ./specsgcc version @value{version-gcc} ./cpp -lang-c -v -isystem ./include -undef @dots{}GNU CPP version @value{version-gcc} (Alpha GNU/Linux with ELF)#include "..." search starts here:#include <...> search starts here: include /usr/alpha-linux/include /usr/lib/gcc-lib/alpha-linux/@value{version-gcc}/include /usr/includeEnd of search list. ./cc1 /tmp/cca18063.i -quiet -dumpbase null.c -version @dots{}GNU C version @value{version-gcc} (alpha-linux) compiled @dots{} as -nocpp -o /tmp/cca180631.o /tmp/cca18063.s ld -m elf64alpha -G 8 -O1 -dynamic-linker /lib/ld-linux.so.2 @dots{}/usr/lib/crt1.o: In function `_start':../sysdeps/alpha/elf/start.S:77: undefined reference to `main'../sysdeps/alpha/elf/start.S:77: undefined reference to `main'sh#@end example(Note that long lines have been truncated, and @samp{@dots{}}used to indicate such truncations.)The above two commands test whether @code{g77} and @code{gcc},respectively, are able to compile empty (null) source files,whether invocation of the C preprocessor works, whether librariescan be linked, and so on.If the output you get from either of the above two commandsis noticeably different, especially if it is shorter or longerin ways that do not look consistent with the above sampleoutput, you probably should not install @code{gcc} and @code{g77}until you have investigated further.For example, you could try compiling actual applications andseeing how that works.(You might want to do that anyway, even if the above testswork.)To compile using the not-yet-installed versions of @code{gcc}and @code{g77}, use the following commands to invoke them.To invoke @code{g77}, type:@example/usr/src/gcc/g77 -B/usr/src/gcc/ @dots{}@end exampleTo invoke @code{gcc}, type:@example/usr/src/gcc/xgcc -B/usr/src/gcc/ @dots{}@end example@node Installation of Binaries@subsection Installation of Binaries@cindex installation of binaries@cindex @code{g77}, installation of@cindex @code{gcc}, installation ofAfter configuring, building, and testing @code{g77} and @code{gcc},when you are ready to install them on your system, type:@examplemake -k CC=gcc install@end exampleAs described in @ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC}, the values forthe @code{CC} and @code{LANGUAGES} macros shouldbe the same as those you supplied for the builditself.So, the details of the above command might varyif you used a bootstrap build (where you might beable to omit both definitions, or might have tosupply the same definitions you used when buildingthe final stage) or if you deviated from theinstructions for a straight build.If the above command does not install @file{libg2c.a}as expected, try this:@examplemake -k @dots{} install install-libf77@end exampleWe don't know why some non-GNU versions of @code{make} sometimesrequire this alternate command, but they do.(Remember to supply the appropriate definition for @code{CC}where you see @samp{@dots
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -