-2

Looking for small C/C++ compiler available for OS X Catalina without the need of installing both xcode and command line tools. CLT itself takes over a Gig, xcode even more. Preferably around or below 100Mb if possible.
Please kindly advice.

P.S. writing scripts for fluid dynamics, not even in need for OOP, just wonder why compilers nowadays weight over USB-sticks capacities from 2000s :(

P.P.S Also considering installing server linux distributive just for C sake. Happy to listen to different opinions.

t.niese
  • 39,256
  • 9
  • 74
  • 101
  • Asking for recommendations is off-topic on SO – UnholySheep Jun 04 '20 at 09:03
  • 1
    @UnholySheep Sir could you redirect pls? –  Jun 04 '20 at 09:04
  • 1
    https://softwarerecs.stackexchange.com/ – Clifford Jun 04 '20 at 09:05
  • What about this: https://osxdaily.com/2012/07/06/install-gcc-without-xcode-in-mac-os-x/ – Jerry Jeremiah Jun 04 '20 at 09:12
  • 2
    Possible duplicate of https://stackoverflow.com/questions/29592943/makefile-without-xcode-on-mac https://stackoverflow.com/questions/114884/is-there-a-way-to-install-gcc-in-osx-without-installing-xcode https://stackoverflow.com/questions/5307433/install-gcc-on-mac-osx-without-installing-xcode https://stackoverflow.com/questions/15093772/gcc-on-mac-without-xcode https://stackoverflow.com/questions/4360110/installing-gcc-to-mac-os-x-leopard-without-installing-xcode – Jerry Jeremiah Jun 04 '20 at 09:15
  • Can't see a big market for C compilation tools for a platform that provides them for free. clang is not Apple's compiler, is it a non-Apple compiler you specifically need or rather just a small compiler. You'd still need Apple's toolchain to deal with signing your code for deployment to get it past GateKeeper. I don't think there is much avoiding it. If you just want to code and compile simple C code without installing a compiler at all, use an on-line compiler such as https://www.onlinegdb.com/ (has the distinct advantage over most on-line tools of having a debugger). – Clifford Jun 04 '20 at 09:18
  • You would only need xcode core (the command line tools and utilities), not the IDE and other extras. That should be much smaller than the whole package. I don't have a Mac, so I don't know whether you can install it separately. On the other hand, what's your problem with a GB on a Mac? – Peter - Reinstate Monica Jun 04 '20 at 09:28
  • @Clifford online compiler for numeric tasks? You can hire the cloud computing power - but it is rather expensive – 0___________ Jun 04 '20 at 09:28
  • @JerryJeremiah all of these recommend Command Line tools which I try to avoid. –  Jun 04 '20 at 09:41
  • @Clifford thnx for advise, with online compilers won't be able to get the output files plots/gifs unforts –  Jun 04 '20 at 09:43
  • @P__J__ yes, I overlooked the PS/PPS. I struggle to see what the problem is if it is just a matter of toolchain footprint. Why does it matter I wonder? – Clifford Jun 04 '20 at 11:09
  • @Clifford OPs ideology probably and archaic "ZX Spectrum like" approach. – 0___________ Jun 04 '20 at 11:26

2 Answers2

2

Looking for small C/C++ compiler available for OS X Catalina

C and C++ are different languages. Read and compare both n1570 (the C11 standard) and n3337 (the C++11 standard).

P.S. writing scripts for fluid dynamics, not even in need for OOP, just wonder why compilers nowadays weight over USB-sticks capacities from 2000s :(

Because recent C or C++ compilers are capable of very tricky optimizations, which programs on fluid dynamics practically need (be aware of OpenACC and of OpenMP and of OpenCL; your probably need one of them). See this draft report explaining more them.

If you need an unoptimizing C compiler, consider using tinycc or nwcc (and port them perhaps to MacOSX). Both are capable of compiling C code on MacOSX or Linux. Both are open source and coded in C.

You could use vim or GNU emacs as your source code editor. Or whatever Apple is giving on your Macbook. Choose also a good build automation tool (e.g. GNU make or ninja) to drive your C or C++ compiler and of course compile on the command line ...

But you probably could take advantage in your field of the many optimizations that either recent GCC (i.e. g++ for C++, gcc for C) or recent Clang (i.e. clang++ for C++, clang for C) are capable of. And both compilers have dozen of millions of source code lines.

If you want a scripting language to drive fluid dynamics libraries, consider using an existing one: Lua, Python, Guile, Ocaml ... comes to mind and can embed other huge libraries.

See also LinuxFromScratch

If you have lots of time to spend (and a few gigabytes of disk space) consider the following route: download some old C compiler; use it to compile nwcc from source code. Download the source code of GCC 4.5 (it is coded in C). Compile it. You have now a C++ compiler g++-4.5. Download the source code of GCC 9. Compile it with g++-4.5. You have now an optimizing C++11 compiler g++-9. That could take a week of your time.

Also considering installing server linux distribution just for C sake.

That choice is large, and matter of opinion. I would recommend a recent Debian or Ubuntu.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
  • I suppose the suggestion to essentially bootstrap a g++ 9 is beyond the OP's scope. I would also think it is not as straightforward as you make it seem. – Peter - Reinstate Monica Jun 04 '20 at 09:37
  • @Peter: It is not straightforward: I did wrote: *if your have lots of time to spend*. I don't have that much time, even if I do occasionally compile both GCC and Clang from their source code (and I contributed to GCC) – Basile Starynkevitch Jun 04 '20 at 09:38
  • thank you for the reply! using vim for few years and feeling okay with it so far. other IDE's feel like an overkill. –  Jun 04 '20 at 09:38
  • You can configure nicely your `vim` to run `make` at a single keystroke. – Basile Starynkevitch Jun 04 '20 at 09:39
  • @BasileStarynkevitch Did you compile it for Mac? I suppose there is a reason that Apple customizes it. – Peter - Reinstate Monica Jun 04 '20 at 09:43
  • No. I ideologically hate Apple and was very disappointed by a MacBook G4 I bought in 2004. It physically broke 1 month after end of warranty. So even if you give me a macbook, I would probably refuse it. I am using Linux both at work and home (on desktops and laptops and VPS) since 1993. Apple hardware is IMHO very costly: the apple logo doubles the price (w.r.t. equivalent PC hardware) – Basile Starynkevitch Jun 04 '20 at 09:49
  • 1
    @BasileStarynkevitch MAC is not for the numerical tasks. The price is insane. In the UK tower MAC is more expensive than several hundreds times more powerful numerical workstation. – 0___________ Jun 04 '20 at 10:09
2

Preferably around or below 100Mb if possible.

Why does 1 or 5 GBs bother you? For complex math calculations you need a very strong computer. Storage is cheap (1TB SSD for ~$120). I rather think that you will need to invest in the decent NVIDIA GPU and calculate there. We have (small business running waves simulations) $100k server with plenty Teslas and it is not fast enough :).

Forget the program sizes - it is the least important, no one cares about it.

You need a modern computer, a lots of RAM and plenty fast storage. Start from it. Compiler size does not matter

0___________
  • 60,014
  • 4
  • 34
  • 74
  • its about storage efficiency. both of my 2tb of storage are full of valuable cfd data (or not so valuable). it just feels like using a rocket to travel 2 blocks. –  Jun 04 '20 at 09:34
  • 1
    @DvaNapasa You should be able to clear out 2/1000 of that data, or dump it on some external storage, or buy another disk for 50 bucks. If you are a researcher the time you spent thinking about it (not to mention ours) is worth more than that. – Peter - Reinstate Monica Jun 04 '20 at 09:38
  • @Peter-ReinstateMonica the issue with a rocket to move from one room to another within the house remains though :( –  Jun 04 '20 at 09:39
  • @DvaNapasa In a place where a rocket costs 50 bucks it doesn't matter. Besides, the "rocket" does a lot of nice things to you (build system, IDE, debugging, optimizing...). – Peter - Reinstate Monica Jun 04 '20 at 09:40
  • DvaNapasa: if your disk is almost full, consider compressing (e.g. with [bzip2](https://en.wikipedia.org/wiki/Bzip2)) some of the less needed files. But I agree with *Peter* : your time is worth more than a cheap SSD disk – Basile Starynkevitch Jun 04 '20 at 09:44
  • @DvaNapasa you focus on non important problems. If you are going to spend months to save some space - it is up to you. No one doing some serious work cares about it. – 0___________ Jun 04 '20 at 09:45
  • @Peter-ReinstateMonica our comments become like an ideology war and off-topic. –  Jun 04 '20 at 09:45
  • @BasileStarynkevitch bad idea - delete all junk you have an it :). After this operationyou will have plenty space – 0___________ Jun 04 '20 at 09:46
  • @DvaNapasa: My guess is that your actual problem is not technical, but about management and funding (and *spending your valuable time* ...). My recomendation is to ask your boss to buy you a cheap SSD disk. – Basile Starynkevitch Jun 04 '20 at 09:46
  • 1
    @DvaNapasa it is up to you. Not my problem. You can ignore all the advices – 0___________ Jun 04 '20 at 09:47
  • @BasileStarynkevitch yes it is not technical. just looking for a light compiler. –  Jun 04 '20 at 09:48
  • 1
    @DvaNapasa none exists. Compiler is only the part of it. You need libraries, the whole toolchain, debugger - sorry maybe you write the code with no bugs. I am programmer for almost 40y and have to debug my software. – 0___________ Jun 04 '20 at 09:50
  • @P__J__: **my first program was on punched cards, 1974** for IBM 370/168, in PL/1. **I still make bugs too even in 2020.** – Basile Starynkevitch Jun 04 '20 at 09:54
  • 1
    @BasileStarynkevitch OT, but: Punch cards in 1981 over here, too. Nothing beats the feeling of data safety when your program sits in a tupper box on your shelf :-). – Peter - Reinstate Monica Jun 04 '20 at 10:40