亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 27409 | 回復(fù): 4
打印 上一主題 下一主題

[Linux] (.text+0x18): undefined reference to `main' [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2012-11-16 00:02 |只看該作者 |倒序?yàn)g覽
本帖最后由 只為你飄的雪 于 2012-11-16 00:09 編輯

gcc -o main.c path_malloc_2_3.c open_max_2_4.c
/usr/lib/gcc/i686-redhat-linux/4.5.1/../../../crt1.o: In function `_start':
(.text+0x1: undefined reference to `main'
collect2: ld 返回 1
然后main.c就沒(méi)有了。這是為什么?求高人賜教!
open_max.c:#include "main.h"

#ifdef OPEN_MAX
static long openmax = OPEN_MAX;
#else
static long openmax = 0;
#endif

/*
* if OPEN_MAX is indeterminate, we are not guaranteed that this is adequate*/
#define OPEN_MAX_GUESS 256

long open_max(void)
{
        if (openmax == 0)
        {
                errno = 0;
                if ((openmax = sysconf(_SC_OPEN_MAX)) < 0)
                        if (errno == 0)
                                openmax = OPEN_MAX_GUESS;
                        else
                                perror("sysconf error";
        }

        return (openmax);
}

path_alloc.c:#include "main.h"

#ifdef PATH_MAX
static int pathmax = PATH_MAX;
#else
static int pathmax = 0;
#endif

#define SUSV3 200112L
static long posix_version = 0;
/*if path_max indeterminate , no guarantee this is adequate */
#define PATH_MAX_GUESS 1024

char *path_alloc(int *sizep) /*also return allocated size, if nonnull */
{
        char *ptr;
        int size;

        if (posix_version == 0)
                posix_version = sysconf(_SC_VERSION);

        if (pathmax == 0)   //first time through
        {
                errno = 0;
                if ((pathmax = pathconf("/", _PC_PATH_MAX)) < 0)
                {
                        if (errno == 0)
                                pathmax = PATH_MAX_GUESS;   //it is indterminats
                        else
                                perror("pathmax error for _pc_path_max";
                }
                else
                        pathmax++;
        }
                if (posix_version < SUSV3)
                        size = pathmax +1;
                else size = pathmax;

                if ((ptr = malloc(size)) == NULL)
                        perror("malloc error";
                if (sizep != NULL)
                        *sizep = size;
                return (ptr);
}

main.h:#ifndef _MAIN_H_
#define _MAIN_H_

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>

char *path_alloc(int *);
long open_max(void);

#endif

論壇徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46處女座
日期:2013-10-24 14:25:01酉雞
日期:2014-04-07 11:54:15
2 [報(bào)告]
發(fā)表于 2012-11-16 11:28 |只看該作者
沒(méi)有main函數(shù).

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2012-11-16 11:50 |只看該作者
本來(lái)有main函數(shù)的,用gcc編譯之后,就沒(méi)有了。回復(fù) 2# linux_c_py_php


   

論壇徽章:
4
水瓶座
日期:2013-09-06 12:27:30摩羯座
日期:2013-09-28 14:07:46處女座
日期:2013-10-24 14:25:01酉雞
日期:2014-04-07 11:54:15
4 [報(bào)告]
發(fā)表于 2012-11-16 11:54 |只看該作者
gcc -o main.c path_malloc_2_3.c open_max_2_4.c

你這命令...

-o是指定output name, 你把編譯+鏈接path_malloc_2_3.c open_max_2_4.c 的結(jié)果輸出到main.c文件了, 并且因?yàn)閜ath_malloc_2_3.c open_max_2_4.c 里沒(méi)有main函數(shù),鏈接還失敗報(bào)錯(cuò)了。。。

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2012-11-16 12:11 |只看該作者
我擦,我想了好久,原來(lái)是命令有問(wèn)題。≈x謝了。我以為是一個(gè).C文件必須配對(duì)一個(gè).h 文件呢,⊙﹏⊙b汗回復(fù) 4# linux_c_py_php


   
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP