This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Copy, rename, or what "gcc-4" to "gcc"


Bill Klein wrote:

> When I did a complete re-install of Cygwin and selected ONLY the gcc4
> packages (core, C compiler, g++) after the install was done, I had a "gcc-4"
> executable in my /bin directory, but no "gcc" executable.  When I install
> V3, I get both gcc-3 and gcc.

  Yes, gcc-4 has always supplied only a gcc-4 executable.  'gcc' used to be
the gcc-3 exe, now it's a symlink via the alternatives system to get there.

> If I just want gcc4, am I supposed to copy gcc-4 to gcc (or rename it) or
> something else?

  No, you're not supposed to do that, you're supposed to use it with that name
directly.  The conventional way is to add "CC=gcc-4" (and maybe "CXX=g++-4" to
your configure command line, or makefile flags, depending on how the build
system for the code you're working with operates.

> Is it intentional that when running setup, if you ONLY select gcc4, that you
> won't end up with any "gcc" executable?  

  Yep.  It's always been that way.  There is no way to ship two different
"gcc.exe"s in two different distros, so the name "gcc.exe" has so far belonged
to the gcc-3 version.

> If not, is there some documentation
> on making certain that you end up with "valid executables" (with the
> expected names, if you only want gcc4?

  With this update, absolutely nothing has changed in the way you have been
using gcc up until now.  With the next gcc-4 update, options will be added to
the alternatives system to allow gcc-4 to indeed become the one true
"gcc.exe".  Until now, creating a copy of gcc-4.exe, or a symlink to it, has
been the only way to have v4 as the plain "gcc.exe", and that would have
broken gcc-3 - until now, when there's a version-suffixed gcc-3.

  If you really can't wait, you could set up some alternatives by hand, by
following these steps:

1.  Create a file "/etc/setup/preremove/gcc4-core.sh", with this content:

#!/bin/bash
/usr/sbin/update-alternatives \
    --remove "gcc" "/usr/bin/gcc-4.exe"

2.  Create another file "/etc/setup/preremove/gcc4-g++.sh", with this:

#!/bin/bash
/usr/sbin/update-alternatives \
    --remove "g++" "/usr/bin/g++-4.exe"

3.  Run the following two commands at the commandline:

/usr/sbin/update-alternatives \
  --install "/usr/bin/g++.exe" "g++" "/usr/bin/g++-4.exe" 30 \
  --slave "/usr/bin/c++.exe" "c++" "/usr/bin/c++-4.exe" \
  --slave "/usr/bin/i686-pc-cygwin-c++.exe" "i686-pc-cygwin-c++" \
	"/usr/bin/i686-pc-cygwin-c++-4.exe" \
  --slave "/usr/bin/i686-pc-cygwin-g++.exe" "i686-pc-cygwin-g++" \
	"/usr/bin/i686-pc-cygwin-g++-4.exe" \
  --slave "/usr/share/man/man1/g++.1.gz" "g++.1.gz" \
	"/usr/share/man/man1/g++-4.1.gz"

/usr/sbin/update-alternatives \
  --install "/usr/bin/g++.exe" "g++" "/usr/bin/g++-4.exe" 30 \
  --slave "/usr/bin/c++.exe" "c++" "/usr/bin/c++-4.exe" \
  --slave "/usr/bin/i686-pc-cygwin-c++.exe" "i686-pc-cygwin-c++" \
	"/usr/bin/i686-pc-cygwin-c++-4.exe" \
  --slave "/usr/bin/i686-pc-cygwin-g++.exe" "i686-pc-cygwin-g++" \
	"/usr/bin/i686-pc-cygwin-g++-4.exe" \
  --slave "/usr/share/man/man1/g++.1.gz" "g++.1.gz" \
	"/usr/share/man/man1/g++-4.1.gz"


  You can then switch gcc and g++ separately (but should almost certainly
always switch both at once) to default to either -3 or -4 by running
"/usr/sbin/update-alternatives --config gcc" or "/usr/sbin/update-alternatives
--config g++".  The gcc-4.3.2-2 release will have a script to handle switching
all the sub-languages for you simultaneously.


    cheers,
      DaveK




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]