如何在linux上修复编译错误

时间:2013-07-26 05:53:12

标签: linux compilation makefile

我正在使用交叉编译器(arm-none-linux-gnueabi),我想构建一个libs3-2.0 source,但是当我尝试编译时出现以下错误。

libs3-2.0$ sudo make
make: *** No rule to make target `libxml/parser.h', needed by `build/obj/simplexml.do'.  Stop.

我该怎么做才能解决这个问题?下面是(GNU)Makefile。

working directory: /home/usrname/prj/app/framework/camera/cdma_manage/<br>
///////////////////////////////////////////////////////////////////////////////////////////

LIBS3_VER_MAJOR ?= 2
LIBS3_VER_MINOR ?= 0
LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)

ifdef VERBOSE
    VERBOSE = true
    VERBOSE_ECHO = @ echo
    VERBOSE_SHOW =
    QUIET_ECHO = @ echo > /dev/null
else
    VERBOSE = false
    VERBOSE_ECHO = @ echo > /dev/null
    VERBOSE_SHOW = @
    QUIET_ECHO = @ echo
endif

ifndef BUILD
    ifdef DEBUG
        BUILD := build-debug
    else
        BUILD := build
    endif
endif

ifndef DESTDIR
    DESTDIR := /usr
endif

ifndef CURL_LIBS
    CURL_LIBS := $(shell curl-config --libs)
endif

ifndef CURL_CFLAGS
    CURL_CFLAGS := $(shell curl-config --cflags)
endif

    ifndef LIBXML2_LIBS
        LIBXML2_LIBS := $(shell xml2-config --libs)
    endif

    ifndef LIBXML2_CFLAGS
        LIBXML2_CFLAGS := $(shell xml2-config --cflags)
    endif

    ifndef LIBXML2_LIBS
        LIBXML2_LIBS := -L../libxml2-2.7.2/.libs -lxml2 -lm
    endif

    ifndef LIBXML2_CFLAGS
        LIBXML2_CFLAGS := -I/home/usrname/prj/app/framework/camera/cdma_manage/libxml2-2.7.2/include
    endif

    ifndef CFLAGS
        ifdef DEBUG
            CFLAGS := -g
        else
            CFLAGS := -O3
        endif
    endif

CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
        $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
        -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
        -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
        -DLIBS3_VER=\"$(LIBS3_VER)\" \
        -D__STRICT_ANSI__ \
        -D_ISOC99_SOURCE \
        -D_POSIX_C_SOURCE=200112L

LDFLAGS = $(CURL_LIBS) $(LIBXML2_LIBS) -lpthread

.PHONY: all
all: exported test

.PHONY: exported
exported: libs3 s3 headers

.PHONY: install
install: exported
        $(QUIET_ECHO) $(DESTDIR)/bin/s3: Installing executable
        $(VERBOSE_SHOW) install -Dps -m u+rwx,go+rx $(BUILD)/bin/s3 \
        $(DESTDIR)/bin/s3
        $(QUIET_ECHO) \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER): Installing shared library
        $(VERBOSE_SHOW) install -Dps -m u+rw,go+r \
        $(BUILD)/lib/libs3.so.$(LIBS3_VER_MAJOR) \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER)
        $(QUIET_ECHO) \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR): Linking shared library
        $(VERBOSE_SHOW) ln -sf libs3.so.$(LIBS3_VER) \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR)
        $(QUIET_ECHO) $(DESTDIR)/lib/libs3.so: Linking shared library
        $(VERBOSE_SHOW) ln -sf libs3.so.$(LIBS3_VER_MAJOR) $(DESTDIR)/lib/libs3.so
        $(QUIET_ECHO) $(DESTDIR)/lib/libs3.a: Installing static library
        $(VERBOSE_SHOW) install -Dp -m u+rw,go+r $(BUILD)/lib/libs3.a \
        $(DESTDIR)/lib/libs3.a
        $(QUIET_ECHO) $(DESTDIR)/include/libs3.h: Installing header
        $(VERBOSE_SHOW) install -Dp -m u+rw,go+r $(BUILD)/include/libs3.h \
        $(DESTDIR)/include/libs3.h

.PHONY: uninstall
uninstall:
        $(QUIET_ECHO) Installed files: Uninstalling
        $(VERBOSE_SHOW) \
        rm -f $(DESTDIR)/bin/s3 \
        $(DESTDIR)/include/libs3.h \
        $(DESTDIR)/lib/libs3.a \
        $(DESTDIR)/lib/libs3.so \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR) \
        $(DESTDIR)/lib/libs3.so.$(LIBS3_VER)

$(BUILD)/obj/%.o: src/%.c
        $(QUIET_ECHO) $@: Compiling object
        @ mkdir -p $(dir $(BUILD)/dep/$<)
        @ /opt/armv7/codesourcery/bin/arm-none-linux-gnueabi-gcc $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \
        -o $(BUILD)/dep/$(<:%.c=%.d) -c $<
        @ mkdir -p $(dir $@)
        $(VERBOSE_SHOW) /opt/armv7/codesourcery/bin/arm-none-linux-gnueabi-gcc $(CFLAGS) -o $@ -c $<

$(BUILD)/obj/%.do: src/%.c
        $(QUIET_ECHO) $@: Compiling dynamic object
        @ mkdir -p $(dir $(BUILD)/dep/$<)
        @ /opt/armv7/codesourcery/bin/arm-none-linux-gnueabi-gcc $(CFLAGS) -M -MG -MQ $@ -DCOMPILINGDEPENDENCIES \
        -o $(BUILD)/dep/$(<:%.c=%.dd) -c $<
        @ mkdir -p $(dir $@)
        $(VERBOSE_SHOW) /opt/armv7/codesourcery/bin/arm-none-linux-gnueabi-gcc $(CFLAGS) -fpic -fPIC -o $@ -c $< 

LIBS3_SHARED = $(BUILD)/lib/libs3.so.$(LIBS3_VER_MAJOR)
LIBS3_STATIC = $(BUILD)/lib/libs3.a

.PHONY: libs3
libs3: $(LIBS3_SHARED) $(LIBS3_STATIC)

LIBS3_SOURCES := acl.c bucket.c error_parser.c general.c \
        object.c request.c request_context.c \
        response_headers_handler.c service_access_logging.c \
        service.c simplexml.c util.c

$(LIBS3_SHARED): $(LIBS3_SOURCES:%.c=$(BUILD)/obj/%.do)
        $(QUIET_ECHO) $@: Building shared library
        @ mkdir -p $(dir $@)
        $(VERBOSE_SHOW) /opt/armv7/codesourcery/bin/arm-none-linux-gnueabi-gcc -shared -Wl,-soname,libs3.so.$(LIBS3_VER_MAJOR) \
        -o $@ $^ $(LDFLAGS)

$(LIBS3_STATIC): $(LIBS3_SOURCES:%.c=$(BUILD)/obj/%.o)
        $(QUIET_ECHO) $@: Building static library
        @ mkdir -p $(dir $@)
        $(VERBOSE_SHOW) $(AR) cr $@ $^

... abbriviated.
//////////////////////////////////////////////////////////////////////////////////////////////

2 个答案:

答案 0 :(得分:0)

问题似乎是make没有找到libxml / parser.h,但需要构建其他东西。您是否检查过该文件是否在包含路径中?

答案 1 :(得分:0)

ifndef LIBXML2_CFLAGS
        LIBXML2_CFLAGS := -I/home/usrname/prj/app/framework/camera/cdma_manage/libxml2-2.7.2/include
endif

应该在

之前添加
ifndef LIBXML2_CFLAGS
        LIBXML2_CFLAGS := $(shell xml2-config --cflags)
endif