how to install gcc on mac using command line? - macos

I need to install the gcc suite on an OS/X box using the command line. As far as I can tell, the only way to do this is to install Xcode, which appears to only have a GUI install. Surely, this can be done.

You can install any package using command line with installer - the GUI is merely a convenience, you don't need to use it. For example
sudo install -pkg Xcode.mpkg -target /
You can also pick individual packages from the Xcode installation if you wish, for example Packages/llvm-gcc4.2.pkg contains just the compiler.

I believe you are looking for this:
http://solarianprogrammer.com/2011/09/20/compiling-gcc-4-6-1-on-mac-osx-lion/
Mind you this is compiling the latest from source.

You can download pre-built binaries from: https://github.com/kennethreitz/osx-gcc-installer

Related

Differences between Apple LLVM and LLVM

I have Apple's command line tools version 9.1 installed and am working through an LLVM tutorial. I need to use some libraries like llvm/ADT and llvm/IR but get an error when I run the code.
main.cpp:1:10: fatal error: 'llvm/ADT/APFloat.h' file not found
#include "llvm/ADT/APFloat.h"
^~~~~~~~~~~~~~~~~~~~
1 error generated.
I also don't seem to have tools such as the assembler. Are these things not usable with Apple's version? And can I install LLVM without conflicting with Apple's version?
Apple's fork misses most of the library,headers and command-line tools in the llvm trunk.
I suggest you compile a new llvm copy from trunk.
Conflicting depends on how you configure everything. You can:
Install your new copy to global location, where your $PATH configuration is responsible for choosing which version to use.
Install as a separate Xcode Toolchain.
Here is a build script I've been using:
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_APPEND_VC_REV=on -DLLVM_ENABLE_EH=on -DLLVM_ENABLE_RTTI=on -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../LLVM
Running ninja install will install to global location, otherwise run ninja install-xcode-toolchain to install as a separate toolchain
In your case I suggest installing to global location to avoid the trouble of messing with CFLAGS/LDFLAGS/Header Search Path. Then remove the installation manually after you are done with the tutorial
EDIT: You might also want to check out the official build guide https://llvm.org/docs/CMake.html
For your use case, in-tree building is also a feasible option(Providing you are familiar with write cmake configs)
Actually, there is no need to build the LLVM yourself. You can get prebuilt version for your platform here: http://releases.llvm.org
In your case it would be something like this:
cd /opt
wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz
tar xvf clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz
mv clang+llvm-5.0.0-x86_64-apple-darwin llvm-5.0.0
After that you will have everything under /opt/llvm-5.0.0, e.g.:
/opt/llvm-5.0.0/bin/clang
/opt/llvm-5.0.0/bin/llvm-config
/opt/llvm-5.0.0/lib/libc++.a
etc.
P.S. I use /opt just as an example, feel free to pick any other directory that fits you best.

How can I compile Evince3 on Windows using msys2 from Evince3 Source Codes?

Evince3 Source Code link = http://ftp.gnome.org/pub/GNOME/sources/evince/3.26/
I downloaded the Evince3 pdf reader program source code from the above link. and installed msys2 with gcc and gtk3 librares. Evince3 created using gtk3 module in C. but I don't know how to compile source code of Evince3 for using this program on Windows. Is it possible ?
Thanks.
I was curious to learn how to build Gtk apps on windows, so I did it myself, and it took me around one hour.
I followed this guide, https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtk-application-on-windows.
Note that the author used gedit as example. To install evince, you need to download three files from this directory(get 32 or 64 version of install file), https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-evince.
Modify pkgver to 3.26.0 and sha256sum to the hash value in evince-3.26.0.sha256sum in PKGBUILD file, and follow the rest of instructions.
Other way: It's also possible to install pre-built package from mysys2 repo with compiling the source code. Open the msys2 console and give the following command to install Evince.
pacman -S mingw-w64-x86_64-evince

build libzmq on mac os x

I am trying to use ZMQ library to communicate between python and c++ code.
I downloaded the source zip from http://zeromq.org/area:download and built it for the windows by using visual studio 2010.
I need to support MAX OS X also. So I tried the same above process by using xcode.
-> I downloaded the code from http://zeromq.org/area:download "POSIX tarball".
-> extract content of zeromq-4.0.4.tar.gz which is downloaded in the above step
-> created the project on xcode
-> included all the files from zeromq-4.0.4/src and zeromq-4.0.4/inc in the xcode project
-> build
Xcode is giving an error while compiling i.e. Unsupported browser in file poller.hpp (77).
I tried to understand from the zmq website but I could not built it.
Can anybody pleas help me building the static lib for the MAC OS X
Thank you.
As per official documentation
brew install zeromq
On the zeromq download page that you reference:
To build on UNIX-like systems
If you have free choice, the most comfortable OS for developing with
ZeroMQ is probably Ubuntu.
Make sure that libtool, autoconf, automake are installed. Check
whether uuid-dev package, uuid/e2fsprogs RPM or equivalent on your
system is installed. Unpack the .tar.gz source archive. Run
./configure, followed by make. To install ZeroMQ system-wide run sudo
make install. On Linux, run sudo ldconfig after installing ZeroMQ. To
see configuration options, run ./configure --help. Read INSTALL for
more details.
Tells you pretty clearly that on Mac OS X compilation uses automake/autoconf. Instead of importing the files into Xcode, install the Xcode command-line tools and do a simple ./configure --enable-static && make to build the static library. The configure script will generate the right headers for you. This is pretty much the default way most libraries that use automake/autoconf are built...
Just use cmake described here:
git clone https://github.com/zeromq/libzmq
mkdir cmake-build && cd cmake-build
cmake .. && make -j 4
make test && make install && sudo ldconfig
I failed 2 test, 1 exception, the other time out.
But building is fine except ldconfig is not on Mac, so need to use dyld
(i am not sure this part)
But it seems working
P.S. Read INSTALL doesn't not give much info

XCode: Where is GCC installed?

I've installed XCode v3.1.3 and am having difficulties using the rumored GCC that is installed along with it. -- I'm certainly able to use the XCode IDE to compile my programs but would like the flexibility of also using the command line...
Where's GCC?
Look in /Developer/usr/bin
The most likely explanation is that when you installed the Developer tools you unchecked "UNIX Development Support", so the command line tools were never installed. Delete your /Developer/ directory and do a clean install of the tools; make sure to select "configure" during the installation process and ensure that the appropriate items are checked.
In /usr/bin you should find gcc-4.0 and gcc-4.2 and then there will be a symbolic link gcc which points to one of these (usually gcc-4.2).
As always, you can find out where any available command in your PATH is located using which, e.g.
$ which gcc

How do I to add gdb to cygwin?

How do I add gdb to cygwin? I have downloaded gdb tar package for cygwin from sourceforge. When extracting it there were many files, so I pasted the gdb.exe file from the package into the bin folder of cygwin. However, it's not working.
When you installed Cygwin the first time, you should have been given a setup program. If you have lost it, you can get it from the Cygwin website. Run this again and select gdb for installation.
For anyone else who runs into this, I had the same issue and attempted to re-run the Cygwin installation package but couldn't find the gdb package.
Looks like the mirror I used was missing some packages! Solution is to use an "official" Cygwin mirror to get access to the full library of packages.
When installing Cygwin (https://cygwin.com/), you have to select the gdb and gdb-debuginfo packages for installation. See required install packages for gdb at [https://cygwin.com/packages/summary/gdb-src.html]

Resources