我有以下makefile,并且还想使用GSL库。你知道我应该怎么做吗?
我暂时找不到正确的方法来编译我的代码。

INCLDIR := include
OBJDIR  := obj
SRCDIR  := src
BINDIR  := bin

CC      := g++
VPATH   :=
LDFLAGS := -L/home/path/gsl/lib
LIBRARY :=
CFLAGS  := -g -Wall -I $(INCLDIR)

#Source and object files (automatic)
SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(subst $(SRCDIR)/,$(OBJDIR)/, $(subst .cpp,.o, $(SRCS)))

# Define here your main source files separated by spaces (without suffix!)
EXEC = main

#Phony = do not represent a file
#.PHONY: all
all : makedir $(EXEC)

# For multiple binaries
$(EXEC) : %: %.cpp $(OBJS)
    $(CC) $(CFLAGS) -o $(BINDIR)/$@ $^

$(OBJDIR)/%.o : $(SRCDIR)/%.cpp
    $(CC) $(CFLAGS) -c -o $@ $<

#Clean: delete every binaries and object files
.PHONY: clean
clean :
    rm -rf $(OBJDIR)/*
    rm -rf $(BINDIR)/*
#Building folders (-p : no error if folder do not exist)
.PHONY: makedir
makedir :
    mkdir -p $(BINDIR)
    mkdir -p $(OBJDIR)

最佳答案

您的LDFLAGS缺少-lgsl。到目前为止,您只告诉链接器,除了默认目录外,还可以在哪里搜索。

10-08 04:11