未定义对"main"的引用 [英] Undefined reference to 'main'

查看:212
本文介绍了未定义对"main"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您必须喜欢链接器错误*讽刺*.无论如何,我正在使用pspsdk随附的allegro的psp端口开发一个psp游戏.在我修复了所有其他未定义的引用之后,这一点让我很困惑.完整的错误消息,makefile和下面的代码:

You got to love linker errors *sarcasm*. Any way, I am developing a psp game using the psp port of allegro which came with pspsdk. And after I fixed all the other undefined references this one stumps me. The full error message and makefile and code below:

错误详细信息

1>------ Build started: Project: PSP Pong, Configuration: Debug Win32 ------
1>  psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o main.o main.cpp
1>  psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L. -LC:/pspsdk/psp/sdk/lib   main.o -lalleg -lpspgu -lpspirkeyb -lm -lpsppower -lpspaudio -lpsprtc  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o main.elf
1>  c:/pspsdk/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib/crt0.o: In function `_main':
1>  ../../../../pspsdk/src/startup/crt0.c (86) : undefined reference to `main'
1>  C:\pspsdk\bin\make: *** [main.elf] Error 1
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

MakeFile

TARGET = main
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = PSP Pong
LIBS = -lalleg -lpspgu -lpspirkeyb -lm -lpsppower -lpspaudio -lpsprtc 
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

main.cpp

#include <allegro.h>
int main()
{

    allegro_init();
    install_mouse();

    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT,480,272,0,0);

    clear_bitmap(screen);
    while (!(mouse_b & 2))
    {
        poll_mouse();
        putpixel(screen,mouse_x,mouse_y,0xFFFFFFFF);
        vsync();
    }
    clear_bitmap(screen);

    return 0;
}
END_OF_MAIN();

P.S我认为链接器不是在谈论main.cpp中的主要功能,而是其他一些主要功能,但是我不知道,因此,任何建议,更正以及任何可帮助我解决此问题的方法都将受到赞赏.

P.S I think the linker is not talking about the main function in main.cpp but some other main but I have no clue so any advice, corrections, any thing to help me solve this will be appreciated.

推荐答案

在包含allegro之前,请尝试添加以下定义:

Just before including allegro, try adding this define:

#define ALLEGRO_NO_MAGIC_MAIN

来源:

http://allegro-psp.webcindario.com/

这篇关于未定义对"main"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆