makefile在raspbian上工作,但在ubuntu上工作

时间:2019-05-21 16:24:53

标签: ubuntu makefile

我正在尝试在ubuntu中编译c项目。 该项目以raspbian编译。 但是,不能在ubuntu上编译

制作文件:

CFLAGS =  -g -Wall -W -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC
LIBS = -lpthread -lcurl -lm
OBJS = dvb2dvb_server.o psi_read.o psi_create.o crc32.o json.o parse_config.o ringbuffer.o
TESTS = test.o psi_read.o psi_create.o crc32.o json.o parse_config.o ringbuffer.o

all: dvb2dvb_server

dvb2dvb_server: $(OBJS)
    $(CC) $(CFLAGS) $(LIBS) -o dvb2dvb_server $(OBJS)

test: $(TESTS)
    $(CC) $(CFLAGS) $(LIBS) -o test $(TESTS)


dvb2dvb_server.o: dvb2dvb_server.c dvb2dvb_server.h psi_read.h psi_create.h crc32.h ringbuffer.h
    $(CC) $(CFLAGS) -c -o dvb2dvb_server.o dvb2dvb_server.c

psi_create.o: psi_create.c dvb2dvb_server.h psi_create.h crc32.h
    $(CC) $(CFLAGS) -c -o psi_create.o psi_create.c

psi_read.o: psi_read.c dvb2dvb_server.h psi_read.h crc32.h
    $(CC) $(CFLAGS) -c -o psi_read.o psi_read.c

crc32.o: crc32.c crc32.h
    $(CC) $(CFLAGS) -c -o crc32.o crc32.c

json.o: json.c json.h
    $(CC) $(CFLAGS) -c -o json.o json.c -lm

parse_config.o: parse_config.c parse_config.h
    $(CC) $(CFLAGS) -c -o parse_config.o parse_config.c

ringbuffer.o: ringbuffer.c ringbuffer.h
    $(CC) $(CFLAGS) -c -o ringbuffer.o ringbuffer.c


clean:
    rm -f dvb2dvb_server $(OBJS) *~

如何在ubuntu中进行编译? Error screen

错误日志:

cc -g -Wall -W -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -lpthread -lcurl -lm -o dvb2dvb_server dvb2dvb_server.o psi_read.o psi_create.o crc32.o json.o parse_config.o ringbuffer.o
dvb2dvb_server.o: In function `curl_thread':
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:205: undefined reference to `curl_easy_init'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:206: undefined reference to `curl_easy_setopt'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:207: undefined reference to `curl_easy_setopt'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:208: undefined reference to `curl_easy_setopt'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:209: undefined reference to `curl_easy_setopt'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:210: undefined reference to `curl_easy_perform'
/home/ubuntu/Desktop/dvb2dvb-server/dvb2dvb_server.c:212: undefined reference to `curl_easy_cleanup'

已更新:
将错误日志添加为文本

1 个答案:

答案 0 :(得分:0)

我更新为@John Bollinger

dvb2dvb_server: $(OBJS)
    $(CC) $(CFLAGS) -o dvb2dvb_server $(OBJS) $(LIBS)

而且,我可以毫无问题地编译