0

所以我正在尝试编译我的应用程序(注意:我的第一个 makefile)并且我已经验证了这些库在 /usr/lib 中,所以我真的不确定为什么在运行 make 时会出现这个错误:

Linking bin/Pathing...
/usr/bin/ld: cannot find -llibboost_filesystem
/usr/bin/ld: cannot find -llibboost_thread-mt
/usr/bin/ld: cannot find -llibboost_system
collect2: ld returned 1 exit status
make: *** [bin/Pathing] Error 1

相关行:LDFLAGS = -L/usr/lib -llibboost_filesystem -llibboost_thread-mt -llibboost_system

你觉得这里有什么明显的错误吗?(如果重要的话,尝试在 64 位 Ubuntu 11.10 上编译......)

那些好奇的人的整个makefile:

# this variable is used to set the executable name
APP      = Pathing

# this  variable is used to set the extension of files to be compiled
SRCEXT   = cpp

#this variable sets to top files hierarchy
SRCDIR   = Pathing

# intermediate object files will be organized under this directory (value of OBJDIR)
OBJDIR   = obj

#Executable file will be under $BINDIR
BINDIR   = bin

#This command will look for all source files to be compiled
SRCS    := $(shell find $(SRCDIR) -name '*.$(SRCEXT)')

#this command is used to determine the subdiretories tree
SRCDIRS := $(shell find . -name '*.$(SRCEXT)' -exec dirname {} \; | uniq)


OBJS    := $(patsubst %.$(SRCEXT),$(OBJDIR)/%.o,$(SRCS))

DEBUG    = -g
INCLUDES = -I./libs/PlistCpp/src -I/usr/local/include/thrift -I./thrift/gen-cpp  -I./Pathing  -I./libs/Detour -I./libs/DetourCrowd -I./libs/DetourTileCache
CFLAGS   = -DHAVE_NETINET_IN_H -Wall -pedantic -ansi -c $(DEBUG) $(INCLUDES)
LDFLAGS  = -L/usr/lib -llibboost_filesystem -llibboost_thread-mt -llibboost_system         

ifeq ($(SRCEXT), cpp)
CC       = $(CXX)
else
CFLAGS  += -std=gnu99
endif

.PHONY: all clean distclean


all: $(BINDIR)/$(APP)

$(BINDIR)/$(APP): buildrepo $(OBJS)
        @mkdir -p `dirname $@`
        @echo "Linking $@..."
        @$(CC) $(OBJS) $(LDFLAGS) -o $@

$(OBJDIR)/%.o: %.$(SRCEXT)
        @echo "Generating dependencies for $<..."
        @$(call make-depend,$<,$@,$(subst .o,.d,$@))
        @echo "Compiling $<..."
        @$(CC) $(CFLAGS) $< -o $@

clean:
        $(RM) -r $(OBJDIR)

distclean: clean
        $(RM) -r $(BINDIR)

buildrepo:
        @$(call make-repo)

define make-repo
   for dir in $(SRCDIRS); \
   do \
        mkdir -p $(OBJDIR)/$$dir; \
   done
endef


# usage: $(call make-depend,source-file,object-file,depend-file)
define make-depend
  $(CC) -MM       \
        -MF $3    \
        -MP       \
        -MT $2    \
        $(CFLAGS) \
        $1
endef

这是一个显示 /usr/lib 中的文件的示例:

-rw-r--r--  1 root root   48666 2011-06-03 16:30 libboost_system.a
lrwxrwxrwx  1 root root      17 2011-06-03 16:30 libboost_system-mt.a -> libboost_system.a
lrwxrwxrwx  1 root root      25 2011-06-03 16:30 libboost_system-mt.so -> libboost_system.so.1.46.1
lrwxrwxrwx  1 root root      25 2011-06-03 16:30 libboost_system.so -> libboost_system.so.1.46.1
-rw-r--r--  1 root root   14568 2011-06-03 16:30 libboost_system.so.1.46.1
4

1 回答 1

1

想通了,从库名中删除“lib”...

于 2012-07-17T16:14:03.947 回答