usrlibgccx86

    技术2022-05-19  21

    自己写了一个简单的hello.c

     

     

    #include "stdio.h"

     

     

    void

    hello (const char * name)

    {

    printf ("Hello, %s!/n", name);

    }

     

    $gcc hello.c

    就会出现/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start'

    :

    (.text+0x20): undefined reference to `main'

    collect2: ld returned 1 exit status

     

    解决方法:只要把hello函数名改为main就没错了! 最好主函数名为main

     

     

     

    #include "stdio.h"

     

    void

    main (const char * name)

    {

    printf ("Hello, %s!/n", name);

    }

     

    $gcc hello.c

     

    ok!

     

     

     


    最新回复(0)