C libraries installation on Mac OSX - c

I have recently switched from Windows to Mac . I was told that Xcode has the C/C++ libraries(GCC) included. Apparently, the new Xcode 5 doesn't have them. As IDE, I have CodeBlocks downloaded. How do I install the libraries for CodeBlocks in Mac?

Apple deprecated gcc in XCode5 (after giving warning for quite a few releases). The main reason for this was that clang is now the system compiler, along with libc++, its accompanying standard library. One of the motivations for the move to clang is that the IDE makes heavy use of the compiler's modular architecture for code syntax highlighting, indexing and refactoring.
I can't imagine many reasons why you actually would specifically need GCC if building software on MacOSX and iOS. Clang has had the edge of GCC in both compilation speed and standards compliance for some time.
What you may need to do, if you haven't already, is install the optional XCode5 command-line tools package (the UI for this changed a few versions ago - google for the solution to your version of XCode5). This installs clang and other command-line tools (or more likely symlinks to them) in /usr, which where external tools and build and configuration tools such as cmake and autoconf expect them to be. clang is also aliased to cc.

Related

MinGW-W64: Which Install Options (Archtitecture, Threads, ...) must/should I Use for Native Windows Development

I want to install MinGW-W64 for Windows 10 64 Bit (must run on Version 1607!). First problem is which MinGW should I download, there are 3 versions on download page: 1) "MingW-W64-builds", 2) "Msys2", 3) "Win-Builds". I have choosen 1). If this was wrong for my purpose (see below) please tell me.
When I start the installer I have to choose the following options, which I'm not clear what to choose:
Architetcture: i686 or x86_64
Threads: posix or win32
Exception: dwarf or sjlj
Purpose (What I want to do)
I want (later) to install the CLang C++ 64 bit Compiler, which AFAIK requires the libraries from MinGW-64.
I want to write native Windows 64 bit C++ (at least C++ 14) and C applications (compiled with either GCC or CLang). I don't need a bash (or someone tells me a good reason why I should use it instead of the excellent Windows Powershell).
At a later time I want to be able to install an IDE (like Eclipse) which especially integrates the debugger (the one for GCC and if it is a different one for CLang that for CLang).
The sources should be as compatible as possible to sources which can be compiled with Visual Studio and the produced binaries should also be as compatible as possible with code produced with Visual Studio (unfortunately I cannot use VS Community version because of license reasons).
(Maybe this is usefull for answering: Python 2.7.11 and Python 3.7 are installed on my machine)
MSYS2 is an environment that gives you a UNIX-like shell.
You can use this if you need to use UNIX-like build tools (like autoconf).
If that's not what you need, don't install it.
Certainly don't build for MSYS as it's closer to Cygwin POSIX emulation than native Windows.
You will need a GCC compiler build against MinGW-w64.
For example one of the MinGW-w64-builds from: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/
However, there don't seem to be any recent builds posted there, while there were newer releases of both GCC and the MinGW-w64 libraries. So I have built more recent versions and published them at: http://winlibs.com/
On http://winlibs.com/ there are also some instructions on how to compile from the command line and how to set up the compiler in the Code::Blocks IDE.
If you need Clang instead of GCC there are Windows binaries available at: http://releases.llvm.org/
However, you will still need the MinGW-w64 libraries to build for Windows using CLang. So if you're new to this, maybe you should just start with GCC before moving on to CLang.
Keeping your code compatible between compilers or even operating systems is up to the programmer.
The key rule there is to avoid anything compiler or operating specific, and if you really must then enclose them in conditional defined (e.g. put the specific code between #ifdef __MINGW32__ or #ifdef _WIN32 and #endif).

How can I install intel Cilk for C/C++ parallel programming on windows 10?

I would like to experiment with intel's Cilk extension for C/C++ parallel programming but I am having a hard time figuring out how to install it on Windows. I tried consulting the official site but I couldn't find any Windows oriented guide. Switching to Linux is not convenient right now and I would prefer to leave it as a last resort.
I also tried to get a free trial version of Parallel Studio, but apparently it does not support CILK anymore.
If someone could guide me step-by-step, I would be very grateful.
I use Code Blocks, which includes the gnu gcc compiler.
(To start with, excuse me, I've never used Cilk personally).
First of all, it's deprecated:
https://en.wikipedia.org/wiki/Cilk#Obsolescence
https://software.intel.com/en-us/forums/intel-cilk-plus/topic/745556
If you want to try it with GCC, you need to get GCC (perhaps, versions from 4.9 to 8.0; support deprecated in 7.1 and removed in 8.1) compiled with Cilk support.
And then it should work in a very simple way, e.g.:
$ gcc -fcilkplus -lcilkrts <OTHER_FLAGS> mycode1.c
$ g++ -fcilkplus -lcilkrts <OTHER_FLAGS> mycode2.cpp
(I've tried to add these flags when compiling a non-Cilk C source on my Debian 9 GNU/Linux (amd64) system, and it seems to work; libcilkrts5 package seems to get installed there along with GCC 6.3.0, by default).
Here is a list of popular binary GCC builds:
https://gcc.gnu.org/install/binaries.html
Unfortunately, most GCC binaries for MS Windows I can find come without Cilk enabled;
e.g., I didn't find it in the following packages:
http://codeblocks.org/downloads/binaries
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/
At least, it can be found in Cygwin (it has gcc-cilkplus & libcilkrts5 in its package list):
https://cygwin.com/packages/package_list.html
Alternatively, you can probably try Intel C++ Compiler (no experience with that, sorry).
https://en.wikipedia.org/wiki/Cilk#Intel_Cilk_Plus
https://www.cilkplus.org/build-gcc-cilkplus
Cilk is alive and kicking at MIT as OpenCilk
You can either build it or even download a binary, but only linux, Mac or source is offered

OpenMP support on OSX 10.11, gcc errors with "file omp.h not found"

I have been using gcc version 5.3.0. It says that it comes with openmp support. But every time when I compile a program using either gcc [by terminal] or via xCode 7, I get same error, "file omp.h not found". I have searched too much on this issue and tried almost everything I found.
First I tried to locate omp.h on my mac. I found some files; then in header file, I used that specific location of omp.h but no help [it gave me linker error].
I installed gcc version 6.0 (pre-release) but no help. I tried changing C_INCLUDE_PATH [which is now, and previously set to none] but that didn't helped me as well.
I reinstalled clang-omp but no help.
I am using llvm compiler version 7.0. Although i have installed clang-omp, there is no omp.h in my /usr/include/*
I changed the compiler and now I am able to run it. [It was issue of clang, which I couldn't solve].
I am a student and Intel is giving Intel Parallel Studio 1 year licence for free to students.
So I downloaded, and installed it.
In xCode, under build settings, I set my compiler to 'Intel C/C++ compiler' and in parallalization, I turned it to 'yes'. That was it. Then it compiled successfully. But, note that you won't be using header file 'omp.h' anymore.
By the way, I am still looking for answers, just to know what I was doing wrong.
You can install 'clang-omp' or 'gcc' (corresponds to GCC 5.3 right now) packages via Homebrew, both of which support OpenMP.
The built in GCC is based upon GCC 4.2.1 abs uses LLVM back end via Dragonegg, which is why it doesn't support OpenMP.
As noted already, Intel compilers support OpenMP on Mac.
I don't use Xcode editor so I don't know how to use any of these from there, but all will work from terminal just as they do on Linux.
the compiler on the mac is clang (based on llvm 3.5) which does not support openmp.
you can try install llvm/clang/openmp from source or using prebuild binaries, but I must admit it does not work as advertised for me…
edit unless you use the -fopenmp=libomp flag.

Can I cross compile with gcc for an old version of a Linux distro on my Ubuntu 9.10?

I have some old hardware with an old version of say SuSE linux running on it. Now I have this fancy development machine running Ubuntu 9.10. Some of the tools I use to compile my C app (written in Python 2.6.x) are not available on the old SuSe box. So... is it possible to compile for that old machine on my dev box?
I have the following steps in mind, but would like to cross-check before venturing off into this quest:
1. Find out which static/shared libs my app needs and find/build target version of them
2. Also find the corresponding header files
3. Feed the correct flags to gcc to use the target headers and libraries
4. Feed the correct flags to gcc to use the correct architecture (i386/i686), or do I need a cross-compilation toolchain.
5. Compile, upload and enjoy ;-)
I regularly use avr-gcc and cc65, both are cross compiling. I know that you set up a coss compiler for developing something like a gumstix, so it should be possible to do the same for old/other Linux distros, not?
C
The way I would approach this is grab your oldmachine:/usr/lib and oldmachine:/usr/include so you have e.g. newmachine:/oldmachinecompiler/usr/{lib|include} then build a cross compiler setting --sysroot to newmachine:/oldmachinecompiler/
This is really the only way to ensure that any library requirements (including libc) in your program are compatible with oldmachine.

Which version of gcc to install with MinGW?

If compiling and linking with MinGW gcc v3 is painfully slow, and gcc v4 is not the default install option: What, for a beginner are the advantages/disadvantages of installing one version or another?
Say for example with gcc v4, I want to use PDCurses or other GNU libraries will I first have to recompile these from source?
I'm only asking here about C and not C++.
I've been using MinGW with GCC4 for some time and didn't encounter any problems, so I'd say go for it. Also, there's no need for recompilation as the C ABI on Windows has been stable for a long time.
The TDM GCC/MinGW32 builds installer includes gcc 4.4.x and all the core binary packages required for basic Windows development, including gdb. It's widely used without any unusual problems.
One advantage of gcc4 is that you can compile recent QT4.6, as it is compiled with gcc4.
Of course some new additions, like OpenMP need new gcc versions.
However, there are complains about MingW port of gcc4 to be unstable for certain applications.

Resources