我的编译器出现以下错误:" movie.c :(。text + 0xd0):未定义引用`Ariel_32'"
现在我有以下文件,Movie.c(Witch包含主类)
#include <stdio.h>
#include <dirent.h>
#include "Graphics.h"
#include "Fonts/Font.h"
int main(int argc, char* argv[])
{
int i;
Color c;
GRAP_Init();
c.RGB = 0xB69C;
GRAP_DrawString(20, 20, &Ariel_32, &path, c);
return 0;
}
我有一个名为Fonts witch contains的子文件夹,Font.h
#ifndef GLOBAL_FONT_H_
#define GLOBAL_FONT_H_
typedef struct
{
unsigned char width; //width of this specific character
unsigned char height; //height of this specific character
}Size;
typedef struct
{
Size size; //Actual space needed for this symbol
unsigned char *data; //First instance of array
}Symbol;
typedef struct
{
Size size; //Maximum size that the symbols take
unsigned char firstChar; //first character
unsigned char symbolSize; //size of symbol
unsigned char symbolCount; //number of symbols
}FontHeader;
typedef struct
{
FontHeader header;
Symbol *symbols;
}Font;
extern Font Ariel_32;
#endif
它还包含Ariel_32.c
#include "Font.h"
#define _firstChar 0x20 //First character
#define _maxWidth 0x2D //Max width in px
#define _maxHeight 0x29 //Max height in px
#define _symbolSize 0x00F6 //Bytes needed per symbol
#define _symbolCount 0x5F //How many symbol in this font
#define _symbolFile "Ariel_32.sym" //Symbol file witch contains the character data
static struct
{
Size size;
unsigned char data[_symbolSize];
}
const fontsym[_symbolCount] =
{
#include _symbolFile
};
Font Ariel_32 =
{
{{_maxWidth,_maxHeight},_firstChar,_symbolSize,_symbolCount}, //Font header
fontsym
};
编辑: 我也将makefile放在这里,因为我不知道那些我用过别人的人。 (我应该真的找到时间太过分了一部分:))
program_NAME := movie
program_C_SRCS := $(wildcard *.c)
program_CXX_SRCS := $(wildcard *.cpp)
program_C_OBJS := ${program_C_SRCS:.c=.o}
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
program_INCLUDE_DIRS :=
program_LIBRARY_DIRS :=
program_LIBRARIES :=
CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
.PHONY: all clean distclean
all: $(program_NAME)
$(program_NAME): $(program_OBJS)
$(LINK.cc) $(program_OBJS) -o $(program_NAME)
clean:
@- $(RM) $(program_NAME)
@- $(RM) $(program_OBJS)
distclean: clean
答案 0 :(得分:0)
您需要在C sources变量中包含Fonts
子目录。
program_C_SRCS := $(wildcard *.c) $(wildcard Fonts/*.c)
然后它将编译子目录中的字体文件,并将它们链接到程序中。