Results 1 to 2 of 2
  1. #1
    VSC not working on MacOS
    When trying to compile a simple program I am getting this error using Visual Studio Code on my MacBook Pro. Trying to avoid using Pico as my editor because it sucks. Please help!

    eph525@Anthonys-MBP MAE 2360 % g++ Test.c
    clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-W
    deprecated]
    Undefined symbols for architecture x86_64:
    "_main", referenced from:
    implicit entry/start for main executable
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    eph525@Anthonys-MBP MAE 2360 %

    My code is this:

    #include<stdio.h>

    int main()
    {
    printf("Hello world");
    return 0;
    }

  2. #2
    VSC not working on MacOS
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,415
    Rep Power
    24
    A couple of things. You are writing a C program and should be using 'gcc' to compile it. 'g++' is used for C++ development.

    My version of your Hello World application is:
    Code:
    #include <stdio.h>
    
    
    int main(void) {
        printf("Hello World\n");
        return 0;
    }
    I compile with
    Code:
    gcc -o hello hello.c
    Not providing the '-o' option means you get a.out which can be confusing.

    Now, I did use 'g++' to compile my code and beyond that (correct) warning, it did compile and run.

    The fact that you are getting the other errors means that you don't have the command line build tools install, ensure you do so with
    Code:
    xcode-select --install
    You should then have the C Library necessary to run your program.

    You should also likely install Xcode which is an awesome IDE for for your development needs. You can write programs in C, C++ and Objective-C for macOS, iOS, WatchOS and so on in there.
    --
    Regards
    ...Ashwin


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to Use macOS? Recovery in macOS Catalina
    By OneMoreThing... in forum RSS News
    Replies: 0
    Last Post: 01-07-2020, 03:10 PM
  2. Working with macOS Snapshots
    By OneMoreThing... in forum RSS News
    Replies: 0
    Last Post: 12-11-2019, 12:00 PM
  3. Replies: 6
    Last Post: 10-23-2018, 05:29 PM
  4. iCloud Sync Stops Working MacOS to iOS
    By Ítre in forum iOS and Apps
    Replies: 3
    Last Post: 12-24-2016, 07:58 PM
  5. got windows 7 ultimate working, but after few days working, now black screen
    By barbet in forum Running Windows (or anything else) on your Mac
    Replies: 3
    Last Post: 07-08-2010, 05:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •