상세 컨텐츠

본문 제목

How To Gcc Compiler For Mac

카테고리 없음

by lobspupugen1989 2020. 1. 31. 04:38

본문

How To Gcc Compiler For Mac

Contents. Using XCode Most development of and is done in MacOS X and thus compiling on MacOS X is easy. The preferred method is to use XCode (but first you must ).

A complete XCode project is located at nairn-mpm-fea/Common/Projects/NairnMPM.xcodeproj This project is called NairnMPM, but it includes all MPM and FEA source code in two targets named NairnMPM and NairnFEA. Once, open the NairnMPM.xcodeproj to compile the code by:.

Fig.02: Installing gcc compiler on Mac OS X Xcode will download package and install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools. Jul 13, 2017  In OS X, GCC is part of Xcode's command tools, so first, open the Mac App Store and install Xcode for free. Then, open Xcode, go to Xcode menu (on the menu bar) > Preferences > Downloads, and install Command Line Tools.

Select the target to compile - either NairnMPM or NairnFEA. Choose build and they will compile and be saved in XCode's derived data folder. If a linking error occurs, you might have conflicting architectures between the XCode settings and the. To fix this problem edit both the project and target settings and under the 'Architectures' section, set the 'Architectures' option to match the architecture you used when or recompile xerces if needed. Compiling Xerces on MacOS X Before you can compile and run the project, however, you will need an installed version of the xerces library and a copy of the xerces header files. These compiling instructions assume they are installed in the default locations for MacOS X or at: /usr/local/lib/libxerces-c.dylib for the library and at /usr/local/include for the header files.

These can be changed if needed by editing the project and target settings. Since revision 274 of the nairn-mpm-fea project, this library must be xerces 3.0 or newer; prior to that revision, it had be xerces 2.8 or older. These libraries can be obtained by downloading the from the web site and then building and installing xerces with the following steps:. First. Open Terminal app and navigate to the xerces source folder expanded from the downloaded file. Configure the code with the command:./configure CFLAGS='-arch x8664' CXXFLAGS='-arch x8664' where the provided arch (or architecture) is the desired option for your machine. The main Mac options are i386 for 32 bit Intel processors, x8664 for 64 bit Intel processors, ppc for 32 bit PowerPC chips, or ppc64 for 64 bit PowerPC64 chips.

Although i386 will work on any Intel processor, you should use x8664 if you have a 64 bit processor, because the code will run faster. To determine how many bits your Intel chip has, chose 'About This Mac' from the Apple menu, click 'More Info.'

Button, and look up the processor name in the hardware section. The 'Intel Core Solo' and 'Intel Core Duo' are 32 bit chips and most others are 64 bit chips. When the configuration is done, use the following commands: cd src make sudo make install These commands make the library (but not the unneeded xerces examples). The final install command after make is done, installs both the library and the header files at the default locations listed above. It requires sudo for you to provide your administrator password needed to authenticate installation and the default location (which is /usr/local).

When working with nairn-mpm-fea on a new Mac, the xerces installation only needs to be done once. The only reason to repeat it is when a new xerces version is available and/or the project requires a new version for compatibility. MacOS X Command Line Compiling It also possible to compile on MacOS X using a command line approach (after and after installing xerces and its header files as making sure they are in the specified default locations).

You can compile using: cd nairn-mpm-fea/NairnMPM/build make SYSTEM=mac-clang and compile using: cd nairn-mpm-fea/NairnFEA/build make SYSTEM=mac-clang All source code will be compiled and the executables will be installed in nairn-mpm-fea/NairnMPM/input or nairn-mpm-fea/NairnFEA/input, respectively. You can use an additional make install command to copy each compiled executable to your /bin folder if desired. The above commands assume you have compiler. If you prefer to change the SYSTEM=mac-clang lines to SYSTEM=mac instead.

If the command-line compile does not work, the most likely explanation is a problem with the xerces installation. You either have to install it as specified or edit the makefile to recognize your custom installation.

The process is documented in the makefile and involves editing the xercesSo and headersPath variables for your different settings. You can pass additional parameters to the make command to alter the compilation process ( e.g., a CC option can pick a compiler installed on your computer). See comments in the makefile for all the latest options. Installing XCode All compiling on Mac requires that you install Xcode (even if you do not plan to use it for anything else).

You can get Xcode from the Mac App Store or from the Apple Developer site. It is a large install.

Once installed, you then need to. Unfortunately, the compilers provided in Apple's 'Command Line Tools' do not support OpenMP used to make these code engines parallel. The two supported solutions are to (and lose all advantages of multiprocessor execution) or to. Some notes below explain how to. The current check out is configured to compile in XCode using. Prior check outs are set up to use earlier versions of clang-mp or various version of GCC. It is be easy to convert any checkout to use the compiler you prefer by making a few changes in the.

Alternatively, you can use command line compilation and Whenever you update your MacOS or Xcode, you may need to before you can return to compiling the code engines. The following sections have more details on installations needed for compiling the code engines. Installing Command Line Tools Apple used to install command line tools by default, but stopped doing that in MacOS Lion.

You now have to manually install the tools before you can compile code. These steps should work:. After on a recent MacOS, launch the app and agree to all options. Once that is done, install command line tools by opening Terminal app and enter: xcode-select -install. If this step does not work, you can see for possible new instructions.

You can also get the command line tools from the and search for command line tools (being sure to get the correct tools for you current Xcode and MacOS versions). You may need to be signed up as an Apple developer for this method. You may need to agree to XCode license by using Terminal app to enter: sudo xcodebuild -license. Most tools should now be available. You should be able to make and install the. To compile the code engines for parallel code, you will additionally need to install a compiler that works with OpenMP (none is provided in the command line tools). With each new system, Apple seems to creating road blocks to keep you from using you computer for interesting programming.

For now, by using a few tricks it is still possible to get around their road blocks. Hopefully these tricks will continue to work in the future. One issue in the XCode project is that it might not find your xerces library, even if it is in the standard location. If it is not found, the library may be in red in the 'External Frameworks and Libraries' folder (or may not). A potential solution is to delete the reference to the library and then add it back.

The problem is that you cannot navigate to the /usr/local/lib folder anymore (another new Apple 'feature'). Here is a trick to get there:. In the Finder, use the 'Go to Folder.' Menu command and enter ' /usr/local'. After it opens, choose the 'Add To Sidebar' menu command. This folder will now appear in all file selection boxes.

Go back to XCode and use command to add files for adding the xerces library. Go through your new 'local' folder and select the xerces library file in /usr/local/lib. Install Clang-mp The currently recommended methods to compile with OpenMP on a Mac and when using XCode is to install the clang-mp compiler.

A good way is to install clang-mp is to use. Once MacPorts tool is installed (and ), the installation of clang-mp is easy. All you need is to open the Terminal app and enter: sudo port selfupdate sudo port install clang-7.0 ld64 +ld64xcode The first command above is only needed to make sure your MacPorts is up to date. The second step will install the compiler at /opt/local/bin/clang-mp-7.0 You can change to different version number if needed or when available. See if you want to remove an old version and replace with a newer one. To use clang-mp in XCode, you will need to add some.

For, you may need to update the makefile to use you new compiler (see comments in makefile for details). Alternatively, you can use the CC option to specify path to any compiler, such as: make SYSTEM=mac CC=/opt/local/bin/clang-mp-4.0 XCode Build Settings Compiling using a clang-mp compiler in Xcode requires some specific project build settings. Various versions of the checkout may have settings for one specific compiler, but you should be able to easily switch to your preferred settings using the details below:. Using clang-mp.

Compiler for C/C/Objective-C: select the default compiler. Use menu command Editor→Add Build Setting→Add User-Defined Setting and add setting for CC with value /opt/local/bin/clang-mp-7.0 (using version number you installed).

Use menu command Editor→Add Build Setting→Add User-Defined Setting and add setting for LDPLUSPLUS with value /opt/local/bin/clang-mp-7.0 (using version number you installed). Other C Flags: add -fopenmp. Other C Flags: add $(OTHERCFLAGS) to have same flags used for C compile as well. Other Linker Flags: add -fopenmp. Enable Modules (C and Objective-C): set to No. Header Search Paths: add /opt/local/include/libomp.

Compiling Without OpenMP. Compiler for C/C/Objective-C: select the default compiler. Other C Flags: remove -fopenmp. Other C Flags: remove -fopenmp. Other Linker Flags: none. Comment out #define USEOPENMP in the MPMPrefix.hpp and FEAPrefix.hpp files. Note that compiling without OpenMP will create serial code.

Because it will be mush slower than parallel code, that option is only recommended when no other option works (for some reason). Possible Changes Needed After Updating MacOS or XCode Unfortunately, Apple does not do a very good job of preserving your prior settings after a major upgrade and you will often need a complete reinstall of anything installed using MacPorts. Some things that might be needed with each MacOS upgrade are:. Get the latest version of XCode (from developer web site or app store).

Reinstall command line tools in Terminal app by entering xcode-select -install. Agree to Xcode license in Terminal app using sudo xcodebuild -license (and provide your admin password).

You may need to uninstall all installed MacPorts, reinstall MacPorts, and then reinstall all previously installed options. The process is explained here. To compile in XCode, you may need more changes (but hard to predict what Apple will require next). Compiling Old Version of the Code If you need to compile old versions of the code, the XCode project may not work well (because of changes in XCode versions, build settings, or compiler you have installed). One option to compile old version (such as when searching for bugs) is to compile using command line and your currently installed compiler. For example, if working with current code on Mac and the clang-mp compiler, you may be able to compile old versions using the build folders and the command make CC=/opt/local/bin/clang-mp-7.0 xercesSo=/usr/local/lib/libxerces-c.dylib CFLAGS='-c -O3 -fopenmp -std=c11 -I/opt/local/include/libomp' LFLAGS='-fopenmp -lc' The above uses several lines, but it all should be on a single command line. Deprecated Compiler Options Use of the GCC compiler is no longer recommended when working with XCode.

It may not even work in XCode 8 or newer (at least by methods described below). The GCC compiler does work fine, however, if using only.

The following sections may provide useful information for installing it for that use. Install GCC 4.8 or Newer GCC 4.9 or new supports OpenMP and may have some uses ( GCC 4.8 and older should be avoided). If you want to use it, a good way to install GCC 4.9 or newer is to use. Once MacPorts tool is installed, the installation is explained in this. In brief, all you need is to open the Terminal app and enter: sudo port selfupdate sudo port install gcc49 The first command above is only needed to make sure your MacPorts is up to date. The second step will install the compiler at /opt/local/bin/g-mp-4.9 You can change to different version number if needed or when available.

How

If you want to remove an older version of GCC after updating, such as removing GCC 4.8, you should be able to use sudo port uninstall -follow-dependents gcc48 To use GCC in XCode, you will need. For, you may need to update the makefile to use you new compiler (see comments in makefile for details). Alternatively, you can use the CC option to specify path to any compiler, such as: make SYSTEM=mac CC=/opt/local/bin/g-mp-4.9 Using GCC 4.9 or Newer in XCode Using GCC requires a hack. Fortunately, a friend of this project (Hammd Mazhar) has provided a solution. The process is explained on this (for XCode 4.x) with an (so far).

Warning: Although the hack still allows one to compile in XCode 8.x, it no long appears possible to link the code using GCC. One alternative is to switch to. In brief, the goal is to install a custom plug in. The shortest approach is download a plug in and install it:. For GCC 4.8 or GCC 4.9 installed as explained, download this or this. For GCC newer then 4.9, you might find a plug in in the repository. For XCode 6.x through 8.x (and probably 5.x), the plug in must be installed in the application at: /Applications/Xcode.app/Contents/Plugins/Xcode3Core.ideplugin/Contents /SharedSupport/Developer/Library/Xcode/Plug-ins/.

For Xcode 4.x it can alternatively be installed at /Library/Application Support/Developer/Shared/Xcode/Plug-ins/. In your XCode project under 'Other Warning Flags' remove the -Wmost option (if needed). You should now be able to select GCC 4.8 or GCC 4.9 from the compiler pop-up menu and compile code using that compiler. Note that this approach fails in El Capitan with XCode 7.x and fails when trying to link to the.

One way to compile in El Capitan with XCode 7.x is:. Install GCC 4.9. Go to /opt/local/lib/gcc49 and create a symbolic link to the xerces library using: ln -s /usr/local/lib/libxerces-c-3.1.dylib libxerces-c-3.1.dylib Note that the symbolic link is to a versioned xerces file and not the standard libxerces-c.dylib because linking to this link did not work.

Because the xerces version is hard coded into the name, you will need to update when xerces is changed or alter the '3.1' if using a different version now. Although it should be possible to set Library Search Paths instead of creating this link, I could not get that approach to work, while the link did work.

Make sure to select compiler GCC 4.9 in XCode. Add -fopenmp to 'Other C Flags' to make sure it is compiled with OpenMP. Add -lgomp to 'Other Linker Flags' to link to OpenMP library. The second approach is to build the plug in yourself (this approach can also be used to customize the plug ins downloaded above).

Scope of Article All of the solutions provided can be used in the writing of the kinds of code beginners write: 20 to 50 lines of code that assist with the learning of C. Stdin and stdout are the focus. Others can do much more. The writing of a full-featured GUI app for macOS is not covered. The article could also be used by professionals who’ve already been doing professional C on, say, a corporate Linux system.

However, it may not be clear how to get started and which tools to use in a transition to a Mac. This article provides an overview of five good ways to write C on a Mac. There may be more. Most discussed are free, but one incurs a modest cost. Some are full featured, and some have limitations.

For example some solutions presented don’t lend themselves to debugging thanks to decisions Apple has made. For all these reasons, it’s hard to rank the various solutions by some standard. After you’ve read about them, it may well be that one is the obvious way to proceed initially. See the spreadsheet on page 6. First, a bit of nomenclature.

How To Compile Gcc Mac

We’ll talk here about an Integrated Development Environment (IDE).: An integrated development environment (IDE) is a software suite that consolidates the basic tools developers need to write and test software. Typically, an IDE contains a code editor, a compiler or interpreter and a debugger that the developer accesses through a single graphical user interface (GUI). What follows is a thumbnail sketch of each approach. As always, it’s up to the student to install and learn the nuances of each one. We’ll provide merely a grand tour and some overall guidance. Finally, in the screen shots below, for clarity, the important area only is shown. That’s because showing the entire window often makes the key region too small to read.

Apple’s Xcode IDE As mentioned above, Apple’s Xcode is a free, full featured IDE for native apps. However, it’s not very hard to press it into service for beginning C code on a Mac, and it includes a GUI debugger. Note that Xcode is designed specifically for developers to write macOS, iOS, tvOS and watchOS applications in Swift or Objective-C.

Because of that, it’s not widely used in industry or education as a C development system. In those situations, the focus is on Linux and Java-based IDEs. But Xcode is free, powerful and turns out to be amazingly useful for the student with a Mac. All you need is a (free) and then you can download it from the Mac App Store found in macOS: Apple Menu App Store.

The latest version as of this writing is 8.3.3 and is designed to work with macOS Sierra. Yep Visual Studio for Mac is lacks C confirmed on Microsoft docs, support and forum 1.

Docs: Microsoft: Introducing Visual Studio for Mac Language support Visual Studio for Mac supports development in C# and F# 2. Support: VisualStudio: How can we improve Microsoft Visual Studio for Mac? Support C in Visual Studio for Mac Visual Studio for Mac enables developers to create applications using.NET and C# only. Visual Studio for Mac should also provide support for C development, using compilers available on the system (gcc, Clang, etc.) 3. Forum: How do I get c to work on Read more ».

How To Gcc Compiler For Mac