Setting GCC 4.2 as the default compiler on Mac OS X Leopard

前端 未结 6 1707
小蘑菇
小蘑菇 2020-11-29 18:53

I\'m sure there must be a way to do this. As you are probably aware the latest versions of Xcode (and in fact I think all versions of Xcode) on Leopard come with GCC 4.0.1 a

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 19:50

    Since I need to build things where CC env is ignored and I end up switching often, I wrote a simple minded gcc_select in Python. Thought I may as well post it here. Invoke it with arg either 4.0 or 4.2 or no arg to see current symlinks. Would need modification if you have versions other than 4.0 and 4.2:

    #!/usr/bin/python
    import sys
    import os
    
    os.chdir('/usr/bin')
    
    files = ['cc', 'gcc', 'c++', 'g++']
    
    if '4.0' in sys.argv:
      ver = '4.0'
    elif '4.2' in sys.argv:
      ver = '4.2'
    else:
      print "Unknown gcc version.  Current setting:"
      os.system('ls -al %s' % ' '.join(files))
      sys.exit(1)
    
    os.system('rm %s' % ' '.join(files))  
    for f in files:
      os.system('ln -s %s-%s %s' % (f, ver, f))
    
    print "Changed to gcc version %s" % ver
    

提交回复
热议问题