Refresher on gcc port and the executables

Lawrence Velázquez larryv at macports.org
Wed May 22 16:15:00 PDT 2013


On May 22, 2013, at 8:17 AM, Ryan Schmidt <ryandesign at macports.org> wrote:

> On May 22, 2013, at 05:25, Tabitha McNerney wrote:
> 
>> Its been some time since I looked more deeply at the GCC ports. On a new Mac recently I installed MacPorts and then specifically installed gcc47 into my port prefix path /opt/local
>> 
>> I looked today and realized there are several binaries (in /opt/local/bin), such as:
>> 
>> gcc-ranlib-mp-4.7
>> gcc-nm-mp-4.7
>> gcc-mp-4.7
>> gcc-ar-mp-4.7
>> g++-mp-4.7
>> 
>> and:
>> 
>> x86_64-apple-darwin12-gcc-ranlib-mp-4.7
>> x86_64-apple-darwin12-gcc-nm-mp-4.7
>> x86_64-apple-darwin12-gcc-mp-4.7
>> x86_64-apple-darwin12-gcc-ar-mp-4.7
>> x86_64-apple-darwin12-gcc-4.7.2
>> x86_64-apple-darwin12-g++-mp-4.7
>> 
>> I forgot what the difference means in the above examples.

There is no difference. They're hard links to the same files:

    % for f in {gcc{-ranlib,,-nm,-ar},g++}-mp-4.7; do  
    for>            stat -f 'inode %i: %N' /opt/local/bin/{,x86_64-apple-darwin12-}$f;
    for>            echo;
    for> done
    inode 40693975: /opt/local/bin/gcc-ranlib-mp-4.7
    inode 40693975: /opt/local/bin/x86_64-apple-darwin12-gcc-ranlib-mp-4.7

    inode 40693973: /opt/local/bin/gcc-mp-4.7
    inode 40693973: /opt/local/bin/x86_64-apple-darwin12-gcc-mp-4.7

    inode 40693974: /opt/local/bin/gcc-nm-mp-4.7
    inode 40693974: /opt/local/bin/x86_64-apple-darwin12-gcc-nm-mp-4.7

    inode 40693972: /opt/local/bin/gcc-ar-mp-4.7
    inode 40693972: /opt/local/bin/x86_64-apple-darwin12-gcc-ar-mp-4.7

    inode 40693966: /opt/local/bin/g++-mp-4.7
    inode 40693966: /opt/local/bin/x86_64-apple-darwin12-g++-mp-4.7

The argv[0] each executable sees does depend on the name used to call it, so runtime behavior might be different, or even incorrect. (I have not tried it.) But they're still just different names for the same files.

>> If I want to compile some C or C++ code without any help from Apple's tools (for example the way I might do on a Linux system), would I simply use the top list (gcc* and g++*) and avoid the bottom list (x86*)?
> 
> Yes.

How divorced are you hoping to get from "Apple's tools"? Our GCC ports still use, at a minimum, Apple's assembler and archiver (via cctools) and linker (via ld64), as well as OS X's bundled zlib.

>> I also have Xcode installed on this Mac and for some code to compile I do not want to use Apple's gcc bundled with Xcode. So given the above, do I need to use gcc_select and if so any suggestions on how best to do so? 
> 
> If you want "gcc" to be a MacPorts compiler instead, use "sudo port select gcc" (which was several years ago known as "gcc_select"). You can learn more about how to use "port select" by running "port help select".

You might also be able to configure Xcode to run your desired compiler directly (e.g., "/opt/local/bin/gcc-mp-4.7").

vq


More information about the macports-users mailing list