| 1 |
|
|---|
| 2 | GCC Frequently Asked Questions
|
|---|
| 3 |
|
|---|
| 4 | The latest version of this document is always available at
|
|---|
| 5 | [1]http://gcc.gnu.org/faq.html.
|
|---|
| 6 |
|
|---|
| 7 | This FAQ tries to answer specific questions concerning GCC. For
|
|---|
| 8 | general information regarding C, C++, resp. Fortran please check the
|
|---|
| 9 | [2]comp.lang.c FAQ, [3]comp.std.c++ FAQ, and the [4]Fortran
|
|---|
| 10 | Information page.
|
|---|
| 11 |
|
|---|
| 12 | Other GCC-related FAQs: [5]libstdc++-v3, and [6]GCJ.
|
|---|
| 13 | _________________________________________________________________
|
|---|
| 14 |
|
|---|
| 15 | Questions
|
|---|
| 16 |
|
|---|
| 17 | 1. [7]General information
|
|---|
| 18 | 1. [8]What is the relationship between GCC and EGCS?
|
|---|
| 19 | 2. [9]What is an open development model?
|
|---|
| 20 | 3. [10]How do I get a bug fixed or a feature added?
|
|---|
| 21 | 4. [11]Does GCC work on my platform?
|
|---|
| 22 | 2. [12]Installation
|
|---|
| 23 | 1. [13]How to install multiple versions of GCC
|
|---|
| 24 | 2. [14]Dynamic linker is unable to find GCC libraries
|
|---|
| 25 | 3. [15]libstdc++/libio tests fail badly with --enable-shared
|
|---|
| 26 | 4. [16]GCC can not find GNU as/GNU ld
|
|---|
| 27 | 5. [17]cpp: Usage:... Error
|
|---|
| 28 | 6. [18]Optimizing the compiler itself
|
|---|
| 29 | 7. [19]Why does libiconv get linked into jc1 on Solaris?
|
|---|
| 30 | 3. [20]Testsuite problems
|
|---|
| 31 | 1. [21]How do I pass flags like -fnew-abi to the testsuite?
|
|---|
| 32 | 2. [22]How can I run the test suite with multiple options?
|
|---|
| 33 | 4. [23]Older versions of GCC
|
|---|
| 34 | 1. [24]Is there a stringstream / sstream for GCC 2.95.2?
|
|---|
| 35 | 5. [25]Miscellaneous
|
|---|
| 36 | 1. [26]Friend Templates
|
|---|
| 37 | 2. [27]dynamic_cast, throw, typeid don't work with shared
|
|---|
| 38 | libraries
|
|---|
| 39 | 3. [28]Why do I need autoconf, bison, xgettext, automake, etc?
|
|---|
| 40 | 4. [29]Why can't I build a shared library?
|
|---|
| 41 | 5. [30]When building C++, the linker says my constructors,
|
|---|
| 42 | destructors or virtual tables are undefined, but I defined
|
|---|
| 43 | them
|
|---|
| 44 | 6. [31]Will GCC someday include an incremental linker?
|
|---|
| 45 | _________________________________________________________________
|
|---|
| 46 |
|
|---|
| 47 | General information
|
|---|
| 48 |
|
|---|
| 49 | What is the relationship between GCC and EGCS?
|
|---|
| 50 |
|
|---|
| 51 | In 1990/1991 gcc version 1 had reached a point of stability. For the
|
|---|
| 52 | targets it could support, it worked well. It had limitations inherent
|
|---|
| 53 | in its design that would be difficult to resolve, so a major effort
|
|---|
| 54 | was made to resolve those limitations and gcc version 2 was the
|
|---|
| 55 | result.
|
|---|
| 56 |
|
|---|
| 57 | When we had gcc2 in a useful state, development efforts on gcc1
|
|---|
| 58 | stopped and we all concentrated on making gcc2 better than gcc1 could
|
|---|
| 59 | ever be. This is the kind of step forward we wanted to make with the
|
|---|
| 60 | EGCS project when it was formed in 1997.
|
|---|
| 61 |
|
|---|
| 62 | In April 1999 the Free Software Foundation officially halted
|
|---|
| 63 | development on the gcc2 compiler and appointed the EGCS project as the
|
|---|
| 64 | official GCC maintainers. The net result was a single project which
|
|---|
| 65 | carries forward GCC development under the ultimate control of the
|
|---|
| 66 | [32]GCC Steering Committee.
|
|---|
| 67 | _________________________________________________________________
|
|---|
| 68 |
|
|---|
| 69 | What is an open development model?
|
|---|
| 70 |
|
|---|
| 71 | We are using a bazaar style [33][1] approach to GCC development: we
|
|---|
| 72 | make snapshots publicly available to anyone who wants to try them; we
|
|---|
| 73 | welcome anyone to join the development mailing list. All of the
|
|---|
| 74 | discussions on the development mailing list are available via the web.
|
|---|
| 75 | We're going to be making releases with a much higher frequency than
|
|---|
| 76 | they have been made in the past.
|
|---|
| 77 |
|
|---|
| 78 | In addition to weekly snapshots of the GCC development sources, we
|
|---|
| 79 | have the sources readable from a CVS server by anyone. Furthermore we
|
|---|
| 80 | are using remote CVS to allow remote maintainers write access to the
|
|---|
| 81 | sources.
|
|---|
| 82 |
|
|---|
| 83 | There have been many potential GCC developers who were not able to
|
|---|
| 84 | participate in GCC development in the past. We want these people to
|
|---|
| 85 | help in any way they can; we ultimately want GCC to be the best
|
|---|
| 86 | compiler in the world.
|
|---|
| 87 |
|
|---|
| 88 | A compiler is a complicated piece of software, there will still be
|
|---|
| 89 | strong central maintainers who will reject patches, who will demand
|
|---|
| 90 | documentation of implementations, and who will keep the level of
|
|---|
| 91 | quality as high as it is today. Code that could use wider testing may
|
|---|
| 92 | be integrated--code that is simply ill-conceived won't be.
|
|---|
| 93 |
|
|---|
| 94 | GCC is not the first piece of software to use this open development
|
|---|
| 95 | process; FreeBSD, the Emacs lisp repository, and the Linux kernel are
|
|---|
| 96 | a few examples of the bazaar style of development.
|
|---|
| 97 |
|
|---|
| 98 | With GCC, we are adding new features and optimizations at a rate that
|
|---|
| 99 | has not been done since the creation of gcc2; these additions
|
|---|
| 100 | inevitably have a temporarily destabilizing effect. With the help of
|
|---|
| 101 | developers working together with this bazaar style development, the
|
|---|
| 102 | resulting stability and quality levels will be better than we've had
|
|---|
| 103 | before.
|
|---|
| 104 |
|
|---|
| 105 | [1] We've been discussing different development models a lot over
|
|---|
| 106 | the past few months. The paper which started all of this introduced
|
|---|
| 107 | two terms: A cathedral development model versus a bazaar
|
|---|
| 108 | development model. The paper is written by Eric S. Raymond, it is
|
|---|
| 109 | called ``The Cathedral and the Bazaar''. The paper is a useful
|
|---|
| 110 | starting point for discussions.
|
|---|
| 111 | _________________________________________________________________
|
|---|
| 112 |
|
|---|
| 113 | How do I get a bug fixed or a feature added?
|
|---|
| 114 |
|
|---|
| 115 | There are lots of ways to get something fixed. The list below may be
|
|---|
| 116 | incomplete, but it covers many of the common cases. These are listed
|
|---|
| 117 | roughly in order of decreasing difficulty for the average GCC user,
|
|---|
| 118 | meaning someone who is not skilled in the internals of GCC, and where
|
|---|
| 119 | difficulty is measured in terms of the time required to fix the bug.
|
|---|
| 120 | No alternative is better than any other; each has its benefits and
|
|---|
| 121 | disadvantages.
|
|---|
| 122 | * Fix it yourself. This alternative will probably bring results, if
|
|---|
| 123 | you work hard enough, but will probably take a lot of time, and,
|
|---|
| 124 | depending on the quality of your work and the perceived benefits
|
|---|
| 125 | of your changes, your code may or may not ever make it into an
|
|---|
| 126 | official release of GCC.
|
|---|
| 127 | * [34]Report the problem to the GCC bug tracking system and hope
|
|---|
| 128 | that someone will be kind enough to fix it for you. While this is
|
|---|
| 129 | certainly possible, and often happens, there is no guarantee that
|
|---|
| 130 | it will. You should not expect the same response from this method
|
|---|
| 131 | that you would see from a commercial support organization since
|
|---|
| 132 | the people who read GCC bug reports, if they choose to help you,
|
|---|
| 133 | will be volunteering their time.
|
|---|
| 134 | * Hire someone to fix it for you. There are various companies and
|
|---|
| 135 | individuals providing support for GCC. This alternative costs
|
|---|
| 136 | money, but is relatively likely to get results.
|
|---|
| 137 | _________________________________________________________________
|
|---|
| 138 |
|
|---|
| 139 | Does GCC work on my platform?
|
|---|
| 140 |
|
|---|
| 141 | The host/target specific installation notes for GCC include
|
|---|
| 142 | information about known problems with installing or using GCC on
|
|---|
| 143 | particular platforms. These are included in the sources for a release
|
|---|
| 144 | in INSTALL/specific.html, and the [35]latest version is always
|
|---|
| 145 | available at the GCC web site. Reports of [36]successful builds for
|
|---|
| 146 | several versions of GCC are also available at the web site.
|
|---|
| 147 | _________________________________________________________________
|
|---|
| 148 |
|
|---|
| 149 | Installation
|
|---|
| 150 |
|
|---|
| 151 | How to install multiple versions of GCC
|
|---|
| 152 |
|
|---|
| 153 | It may be desirable to install multiple versions of the compiler on
|
|---|
| 154 | the same system. This can be done by using different prefix paths at
|
|---|
| 155 | configure time and a few symlinks.
|
|---|
| 156 |
|
|---|
| 157 | Basically, configure the two compilers with different --prefix
|
|---|
| 158 | options, then build and install each compiler. Assume you want "gcc"
|
|---|
| 159 | to be the latest compiler and available in /usr/local/bin; also assume
|
|---|
| 160 | that you want "gcc2" to be the older gcc2 compiler and also available
|
|---|
| 161 | in /usr/local/bin.
|
|---|
| 162 |
|
|---|
| 163 | The easiest way to do this is to configure the new GCC with
|
|---|
| 164 | --prefix=/usr/local/gcc and the older gcc2 with
|
|---|
| 165 | --prefix=/usr/local/gcc2. Build and install both compilers. Then make
|
|---|
| 166 | a symlink from /usr/local/bin/gcc to /usr/local/gcc/bin/gcc and from
|
|---|
| 167 | /usr/local/bin/gcc2 to /usr/local/gcc2/bin/gcc. Create similar links
|
|---|
| 168 | for the "g++", "c++" and "g77" compiler drivers.
|
|---|
| 169 |
|
|---|
| 170 | An alternative to using symlinks is to configure with a
|
|---|
| 171 | --program-transform-name option. This option specifies a sed command
|
|---|
| 172 | to process installed program names with. Using it you can, for
|
|---|
| 173 | instance, have all the new GCC programs installed as "new-gcc" and the
|
|---|
| 174 | like. You will still have to specify different --prefix options for
|
|---|
| 175 | new GCC and old GCC, because it is only the executable program names
|
|---|
| 176 | that are transformed. The difference is that you (as administrator) do
|
|---|
| 177 | not have to set up symlinks, but must specify additional directories
|
|---|
| 178 | in your (as a user) PATH. A complication with --program-transform-name
|
|---|
| 179 | is that the sed command invariably contains characters significant to
|
|---|
| 180 | the shell, and these have to be escaped correctly, also it is not
|
|---|
| 181 | possible to use "^" or "$" in the command. Here is the option to
|
|---|
| 182 | prefix "new-" to the new GCC installed programs:
|
|---|
| 183 |
|
|---|
| 184 | --program-transform-name='s,\\\\(.*\\\\),new-\\\\1,'
|
|---|
| 185 |
|
|---|
| 186 | With the above --prefix option, that will install the new GCC programs
|
|---|
| 187 | into /usr/local/gcc/bin with names prefixed by "new-". You can use
|
|---|
| 188 | --program-transform-name if you have multiple versions of GCC, and
|
|---|
| 189 | wish to be sure about which version you are invoking.
|
|---|
| 190 |
|
|---|
| 191 | If you use --prefix, GCC may have difficulty locating a GNU assembler
|
|---|
| 192 | or linker on your system, [37]GCC can not find GNU as/GNU ld explains
|
|---|
| 193 | how to deal with this.
|
|---|
| 194 |
|
|---|
| 195 | Another option that may be easier is to use the --program-prefix= or
|
|---|
| 196 | --program-suffix= options to configure. So if you're installing GCC
|
|---|
| 197 | 2.95.2 and don't want to disturb the current version of GCC in
|
|---|
| 198 | /usr/local/bin/, you could do
|
|---|
| 199 |
|
|---|
| 200 | configure --program-suffix=-2.95.2 <other configure options>
|
|---|
| 201 |
|
|---|
| 202 | This should result in GCC being installed as /usr/local/bin/gcc-2.95.2
|
|---|
| 203 | instead of /usr/local/bin/gcc.
|
|---|
| 204 | _________________________________________________________________
|
|---|
| 205 |
|
|---|
| 206 | Dynamic linker is unable to find GCC libraries
|
|---|
| 207 |
|
|---|
| 208 | This problem manifests itself by programs not finding shared libraries
|
|---|
| 209 | they depend on when the programs are started. Note this problem often
|
|---|
| 210 | manifests itself with failures in the libio/libstdc++ tests after
|
|---|
| 211 | configuring with --enable-shared and building GCC.
|
|---|
| 212 |
|
|---|
| 213 | GCC does not specify a runpath so that the dynamic linker can find
|
|---|
| 214 | dynamic libraries at runtime.
|
|---|
| 215 |
|
|---|
| 216 | The short explanation is that if you always pass a -R option to the
|
|---|
| 217 | linker, then your programs become dependent on directories which may
|
|---|
| 218 | be NFS mounted, and programs may hang unnecessarily when an NFS server
|
|---|
| 219 | goes down.
|
|---|
| 220 |
|
|---|
| 221 | The problem is not programs that do require the directories; those
|
|---|
|
|---|