Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:26:01+00:00 2026-06-15T08:26:01+00:00

I am attempting to write very basic x86 code and call it in a

  • 0

I am attempting to write very basic x86 code and call it in a C program. I’m running OSX 10.8.2. Here is the code I have:

start.c:

#include <stdio.h>

void _main();  // inform the compiler that Main is an external function

int main(int argc, char **argv) {
    _main();
    return 0;
}

code.s

.text

.globl _main
_main:
    ret

I run the following commands to attempt compilation:

gcc -c -o code.o code.s
gcc -c -o start.o start.c
gcc -o start start.o code.o

Which then returns this output after the final command:

Undefined symbols for architecture x86_64:
  "__main", referenced from:
      _main in start.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Am I missing something in my compiler calls? Do I need to update something/install something different? I just can’t find a definitive answer anywhere since this is such a general output. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:26:02+00:00Added an answer on June 15, 2026 at 8:26 am

    You need an extra underscore in your asm _main symbol:

    .text
    
    .globl __main
    __main:
        ret
    

    C symbols get an underscore prefix when compiled, so your C main is actually _main and an extern C _main actually needs to be defined as __main if you write it in asm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to write a very basic script using javascript. What I want to
I have been attempting to write a VBA Script that can parse out other
I am attempting to write my first Dynamics Crm 2011 plugin. I have therefore
So, here's the deal. I am attempting to write a quick python script that
I am attempting to write a very simple rake task (and merge it into
I have been attempting recently to write a web service that returns a custom
I'm attempting to create an iOS 5 app with some very basic FTP functionality
I am attempting to write a C++ wrapper of OpenVG, which is very Open-GL
I have an SSIS package I am developing. I am attempting to write data
I'm attempting to write my very own custom parser (in C#) for (X)HTML5 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.