0

如果我构建我的程序,它会给我很多错误和警告。一切都来自编译的最高源文件 - main.o。

...
./main.o:16:819: warning: null character(s) ignored [enabled by default]
./main.o:16:824: warning: null character(s) ignored [enabled by default]
./main.o:16:829: warning: null character(s) ignored [enabled by default]
./main.o:16:844: warning: null character(s) ignored [enabled by default]
./main.o:16:854: warning: null character(s) ignored [enabled by default]
./main.o:16:864: warning: null character(s) ignored [enabled by default]
./main.o:16:886: error: too many decimal points in number
./main.o:16:892: error: invalid suffix "ubuntu5" on integer constant
./main.o:16:902: error: too many decimal points in number
./main.o:16:907: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\24’ in program
./main.o:16:914: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:924: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:2: error: stray ‘\20’ in program
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:2: error: stray ‘\33’ in program
./main.o:16:2: error: stray ‘\7’ in program
./main.o:16:2: error: stray ‘\10’ in program
./main.o:16:2: error: stray ‘\220’ in program
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:935: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\34’ in program
./main.o:16:938: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\34’ in program
./main.o:16:942: warning: null character(s) ignored [enabled by default]
./main.o:16:950: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\16’ in program
./main.o:16:2: error: stray ‘\20’ in program
./main.o:16:2: error: stray ‘\206’ in program
./main.o:16:2: error: stray ‘\2’ in program
In file included from <command-line>:0:0:
./main.o:17:1: error: stray ‘\6’ in program
./main.o:17:1: error: stray ‘\2’ in program

....

哪里有问题?这些错误是由“-include”命令和源文件/usr/include/glib-2.0/glib/gregex.h 到makefile 引起的。但是如果我删除这个命令,它会给我“未定义的引用...”的错误......来自 glib 的声明。问题在于使用 glib。在我尝试之前(没有效果):

INCLUDES =  -I/usr/include/glib-2.0 \
        -I/usr/include/glib-2.0/glib
LIBS :=     -lglib-2.0

有没有人用 glib 有正确的 makefile 命令?谢谢

编辑:我想创建一个程序,它使用 streamripper 来录制互联网音频流。

CC = gcc    
CFLAGS = -g -Wall $(shell pkg-config --cflags glib-2.0)  -D__UNIX__
LFLAGS =    -L/usr/include/x86_64-linux-gnu \
            -L/usr/local/lib/ \
            -L/usr/include/x86_64-linux-gnu 
SRCS =  main.c \
        streamripper.c #\
        /usr/include/glib-2.0/glib/gregex.h
OBJS = $(SRCS:.c=.o)
MAIN = radio
INCLUDES =  -I/home/honza/workspace/Radio_processing/streamripper/libmad-0.15.1b \
            -I/usr/include \
            -I/usr/include/x86_64-linux-gnu \
            -I/usr/include/x86_64-linux-gnu/4.6/include \
            -I/usr/include/x86_64-linux-gnu/4.6/include-fixed \
            -I/usr/local/include \
            -I/usr/lib/x86_64-linux-gnu/glib-2.0/include \
            -I/usr/lib/x86_64-linux-gnu/glib-2.0 \
            -I/usr/include/glib-2.0 \
            -I/usr/include/glib-2.0/glib
LIBS :=      -lm libmad.a libstreamripper.a -glib -lglib-2.0 \
             $(shell pkg-config --libs glib-2.0)
             #-lavcodec -lavutil -lavformat   -lpthread

all: $(MAIN)

    @echo 'My makefile finished'

$(MAIN): $(OBJS)
    $(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS) 

.c.o:
    $(CC) $(CFLAGS) $(INCLUDES) -c $<  -o $@

clean:
    $(RM) *.o *~ $(MAIN)

depend: $(SRCS)
    makedepend $(INCLUDES) $^
4

1 回答 1

1

一切都来自编译的最高源文件 - main.o

再次编译目标文件,或者将源文件命名为目标文件,这很奇怪。

.o 通常是来自 .c 文件的编译步骤。

于 2013-06-16T16:54:49.747 回答