日期:2014-05-16  浏览次数:20834 次

makefile链接库问题
lanet源程序中的makefile文件,make之后提示如下distribute_components.cpp:243: more undefined references to `gsl_rng_uniform' follow,找不到定义。但是我链接库已经制定了,环境变量也设置了,问题在哪呢。
makefile:
#C++
GCC=g++

VPATH=src

OBJ=obj

#All relevant -I options here
INCLUDES= -I src 

#Add other options for ocamlc here
CFLAGS=-O5 $(INCLUDES) -g -lgsl -lblas 

#There must be one line per program
PROGRAM_OBJS=types.o uniform.o graph_builder.o graph_builder_txt.o graph_node_names.o graph_node_colors.o log.o vertex.o graph_kcores.o graph_kcores_components.o graph_kdenses.o graph_kdenses_components.o graph_of_triangles.o graph_triangled_kcores.o graph.o clique.o connectedcomponent.o connectivity.o network.o kcores_component.o kdenses_component.o parameters.o povray_renderer.o svg_renderer.o povray.o svg.o graphics_kcores.o graphics_kdenses.o ff_routine.o distribute_components.o utils.o main.o

#move must be at the end
all: deldoc lanet

lanet: $(PROGRAM_OBJS)
    @echo Linking $@...
    @$(GCC) -o  $@ $(CFLAGS) $+ 

deldoc:
    @rm -r -f doc/

#Common rules
.SUFFIXES: .cpp .o
.cpp.o:
    @echo Compiling $<
    @$(GCC) $(CFLAGS) -c  $<

#Clean up
clean:
    @rm -f src/*.o
    @rm -f *.o
    @rm -f src/*~
    @rm -f *~
------解决方案--------------------
gsl_rng_uniform  这个东东在哪个.c里面定义的呢?
------解决方案--------------------
CFLAGS=-O5 $(INCLUDES) -g  -L<库文件路径> -lgsl -lblas
------解决方案--------------------
"#All relevant -I options here
INCLUDES= -I src
"

“-I”后面不能有空格,改为“-I./src”
------解决方案--------------------
引用:
Quote: 引用:

CFLAGS=-O5 $(INCLUDES) -g  -L<库文件路径> -lgsl -lblas


不行啊。。

那你有这个函数吗 gsl_rng_uniform
------解决方案--------------------
“CFLAGS=-O5”改成“CFLAGS=-O”试试!