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

  • SEARCH
  • Home
  • 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 6813143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:32:08+00:00 2026-05-26T20:32:08+00:00

I have a main function, but when tcc goes to link everything together, it

  • 0

I have a main function, but when tcc goes to link everything together, it says its undefined. Why is this?

I’m using a python build script, and arguments are passed as lists:

['v:/exe/tcc/tcc.exe', '-odist/***.exe', '-Llib/', '-llua5.1', '-lsoil', '-lSDL', '-lopengl32', 'build/luainterface\\msL.o', 'build/luainterface\\vector.o', 'build/rendering\\renderutil.o', 'build/structures\\crtree.o', 'build/structures\\uniqueid.o', 'build/structures\\vector.o', 'build/world\\blocklib.o', 'build/world\\chunk.o', 'build/world\\world.o', 'build/main.o']

The output is simply:

tcc: undefined symbol 'main'

My main function is defined in the file main.c (and doesn’t have a header), with a couple of static functions.
Main function:

int main(int argc, char *argv[])
{
    SDL_Surface* screen = render_initialize(1024,768);

    lua_State* L = luaL_newstate();
    //lua_atpanic(L,&Lpanic);

    msL_registerState(L);
    msL_openAllLibs(L);

    int fail = luaL_dofile(L,"lua/main.luac");
    if(fail)
    {
        fprintf(stderr, "Lua error: %s\n", lua_tostring(L,-1));
        doexit(1);
    }

    lua_getfield(L,LUA_GLOBALSINDEX,"draw");
    if(!lua_isfunction(L,-1))
    {
        lua_pop(L,1);
        fprintf(stderr, "No draw function defined in global scope\n");
        doexit(1);
    }
    lua_setfield(L,LUA_REGISTRYINDEX,"msL_drawfunction");

    while(1)
    {
        lua_getfield(L,LUA_REGISTRYINDEX,"msL_drawfunction");
        assert(lua_isfunction(L,-1));
        int err = lua_pcall(L,0,0,0);
        if(err)
        {
            fprintf(stderr,"Lua error: ");
            switch(err)
            {
                case LUA_ERRRUN:
                    fprintf(stderr,"%s",lua_tostring(L,-1));
                    break;
                case LUA_ERRMEM:
                    fprintf(stderr,"out of memory");
                    break;
                default:
                    fprintf(stderr,"unknown error");
            }
            fprintf(stderr,"\n");
            doexit(1);
        }

        render_flipbuffers(screen);
    }
    doexit(0);
}

EDIT: I ran the code through tcc with preprocessing only. Apparently the main function is being renamed to SDL_main, through some macro in SDL.

  • 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-05-26T20:32:09+00:00Added an answer on May 26, 2026 at 8:32 pm

    Add -lSDLmain to linker flags.

    http://wiki.libsdl.org/moin.cgi/FAQWindows#I_get_.22Undefined_reference_to_.27WinMain.4016.27.22

    Although things may be a little different in tcc.

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

Sidebar

Related Questions

I have main site to which i put code using require function, but when
In python, a module doesn't have to have a main function, but it is
I have a function thats the main bottleneck of my application, because its doing
I have a main function but NetBeans needs a main class in order for
I'm trying to simulate a token ring using python with sockets, but I have
In a C project, I have a main() function in several files. When I
I have a main thread that invokes a child thread function at different times
Okay here's the program I have typed up(stdio.h is included also): /* function main
I have a function to load a html part into a element in main
I have a number of iframes calling a function in my main page. Is

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.