0

我正在尝试在我的 x86 Ubuntu VM 上编译 C 程序。我已经为我的系统安装了 libconfig。当我尝试编译时,我收到此错误:

/usr/bin/x86_64-linux-gnu-ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libconfig.so when searching for -lconfig
/usr/bin/x86_64-linux-gnu-ld: skipping incompatible //usr/lib/x86_64-linux-gnu/libconfig.a when searching for -lconfig
/usr/bin/x86_64-linux-gnu-ld: cannot find -lconfig

要编译,我使用以下命令:

make EXTRA_CFLAGS="-std=gnu99 -Wall -Wextra -fno-strict-aliasing -pipe -m32 -msse -msse2 -D__X86__"

我有两个makefile:第一个makefile 引用第二个makefile。第一个是:

CC ?= gcc
INC_PATH ?= $(realpath ../inc)
LIB_PATH ?= $(realpath ../lib)
LIBS ?= -litsg5_v2xcast -pthread -lrt -lm -lzmq -lconfig
EXTRA_CFLAGS =
CFLAGS += $(EXTRA_CFLAGS)
export CFLAGS INC_PATH LIB_PATH LIBS

EXAMPLES := itsmsg its 
SUBDIRS := libitsmsg its
    
.PHONY: all $(EXAMPLES)

all: $(EXAMPLES)

itsmsg:
    make -C libitsmsg

its:
    make -C its

clean:
    $(foreach d, $(SUBDIRS), make -C $(d) clean;)

其文件夹内的第二个 makefile 是:

CC ?= gcc
INC_PATH ?= $(realpath ../inc)
LIB_PATH ?= $(realpath ../lib)
LIBS ?= $(wildcard $(LIB_PATH)/*.a) -pthread -lrt -lm -lconfig
LDFLAGS :=-g -L$(LIB_PATH)
CFLAGS +=-g -I$(INC_PATH)

EXAMPLES=its

.PHONY: all

all: $(EXAMPLES)

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

its: its.o  frozen.o
    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) -Wl,-rpath,'$$ORIGIN/../../lib'

clean:
    rm -f *~ *.o $(EXAMPLES)
4

0 回答 0