2 Replies
      Latest reply on Mar 12, 2020 4:09 PM by spineda226
      spineda226 Level 1 Level 1 (0 points)

        When I try to compile a simple hello.c file that prints "hello" with gcc, my terminal just hangs. (I also have this issue when trying to use a Makefile or cmake). I have tried using the gcc with Xcode, command line tools, and homebrew. If I wait for it to finish, my internet eventually goes out and my terminal needs to be restarted.


        Occasionally, the compilation finishes quickly, but most of the time it does not complete or produces a bad executable.


        I have tried restarting my laptop, reinstalling my OS, reinstalling Xcode, and reinstalling command line tools. I've also talked with Apple support and went into the Apple store, but they just suggested I post on these forums.


        I am using a MacBook Air, my Xcode version is 11.3.1, and I am using Catalina 10.15.3. Does anyone have any suggestions on what to do?

        • Re: gcc compilation hangs
          jonprescott Level 3 Level 3 (100 points)

          You need to elaborate a little more about your setup.


          1 - Use clang.  The gcc that is part of the Xcode command line tools is actually a wrapper around clang/llvm.  Probably going away in the near future.  Plus, that version of gcc is stopped at 4.2.1, because of the adoption of the GNU V3 license by the Free Software Foundation.  Apple refuses to use GNU V3 licensed software anymore.


          2 - Why does the internet have anything to do with compiling source code on your Mac?  What terminal program are you using?  If you are using the Terminal.app, located in /Applications/Utilities, doesn't require an Internet connection at all.  If you are using Xterm with XQuartz, still shouldn't be a problem if you are using it on a local machine.


          3 - Just compiled a test program for Objective-C with gcc, same setup as yours.  Build an object file faster than I could time.  More lines of code than hello world.

            • Re: gcc compilation hangs
              spineda226 Level 1 Level 1 (0 points)

              1. When I type clang hello.c, I run into the same issue of the terminal hanging.


              gcc --version produces the following output:


              Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1

              Apple clang version 11.0.0 (clang-1100.0.33.17)

              Target: x86_64-apple-darwin19.3.0

              Thread model: posix

              InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


              2. Internet does not have anything to do with compiling the source code. I was just noting that this was a strange side effect that I do not know how to explain; when my terminal hangs, my google chrome windows say that I lost internet connection for some reason.

              Also, yes I am using the Terminal.app from /Applications/Utilities


              3. I'm not too sure what else to be trying at this point. I haven't found anyone/anything online with this similar issue. I've called two different Apple support people and have visited the Apple store in-person with no luck unfortunately. Thank you for trying to help though!