在Mac OS X上自定义igraph igraph_get_shortest_paths_dijkstra函数

时间:2021-11-02 12:41:32

To make a custom version of the function igraph_get_shortest_paths_dijkstra I made a copy of it from the file:structural_properties.c. I've yanked it out and put it in my local .c file and one of the modifications to my Makefile is the following, but I get an error:

要创建函数igraph_get_shortest_paths_dijkstra的自定义版本,我从文件中复制了它:structural_properties.c。我把它拉出来放在我的本地.c文件中,我的Makefile的一个修改如下,但是我收到一个错误:

gcc  -I/usr/local/include/igraph -I/Users/saguinag/ToolSet/igraph-0.7.1/src -I/Users/saguinag/ToolSet/igraph-0.7.1   -o mycc comp_catpath.o -L/usr/local/lib -ligraph
Undefined symbols for architecture x86_64:
  "_saguinag_get_shortest_path", referenced from:
  _main in comp_catpath.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mycc] Error 1

Where my Makefile starts out as:

我的Makefile开头的地方是:

## Author: Sal Aguinaga (c) 2015
CC=gcc
INCLUDES=-I/usr/local/include/igraph \
    -I/Users/saguinag/ToolSet/igraph-0.7.1/src \
    -I/Users/saguinag/ToolSet/igraph-0.7.1
LFLAGS=-L/usr/local/lib
LIBS=-ligraph
OUT=comp_catpath
OBJS=comp_catpath.o 

# define the C source files
SRCS = comp_catpath.c

OBJS = $(SRCS:.c=.o)

# define the executable file 
MAIN = mycc


.PHONY: depend clean

all:    $(MAIN)
    @echo  Simple compiler named mycc has been compiled

$(MAIN): $(OBJS) 
    $(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)

# this is a suffix replacement rule for building .o's from .c's
# # it uses automatic variables $<: the name of the prerequisite of
# # the rule(a .c file) and $@: the name of the target of the rule (a .o file) 
# # (see the gnu make manual section about automatic variables)
.c.o:
    $(CC) $(CFLAGS) $(INCLUDES) -c $<  -o $@
#
clean:
    $(RM) *.o *~ $(MAIN)
#
depend: $(SRCS)
    makedepend $(INCLUDES) $^
#
# DO NOT DELETE THIS LINE -- make depend needs it

do I need to specify the architecture? My machine is a MacBook Pro. When I type make -v I get that it's GNU Make 3.81 with the last line saying "This program built for i386-apple-darwin11.3.0" Is there a better way to do this?

我需要指定架构吗?我的机器是MacBook Pro。当我键入make -v时,我得到它的GNU Make 3.81,最后一行说“为i386-apple-darwin11.3.0构建的这个程序”有更好的方法吗?

1 个解决方案

#1


2  

You are compiling and linking a single source file, comp_catpath.c. In this file, you have defined the function main, and in main you try to call the function saguinag_get_shortest_path. However, you haven't defined the function saguinag_get_shortest_path in comp_catpath.c and it's also not defined in the igraph library or in the C standard library.

您正在编译和链接单个源文件comp_catpath.c。在此文件中,您已定义函数main,并在main中尝试调用函数saguinag_get_shortest_path。但是,您尚未在comp_catpath.c中定义函数saguinag_get_shortest_path,并且它也未在igraph库或C标准库中定义。

If you already put the definition of saguinag_get_shortest_path in another .c file, you need to include that file's name in the definition of SRCS in your Makefile. If you didn't define saguinag_get_shortest_path anywhere, you need to write a definition for it, either in comp_catpath.c or in a new file (that you then add to SRCS).

如果已经将saguinag_get_shortest_path的定义放在另一个.c文件中,则需要在Makefile的SRCS定义中包含该文件的名称。如果没有在任何地方定义saguinag_get_shortest_path,则需要在comp_catpath.c或新文件(然后添加到SRCS)中为其编写定义。

#1


2  

You are compiling and linking a single source file, comp_catpath.c. In this file, you have defined the function main, and in main you try to call the function saguinag_get_shortest_path. However, you haven't defined the function saguinag_get_shortest_path in comp_catpath.c and it's also not defined in the igraph library or in the C standard library.

您正在编译和链接单个源文件comp_catpath.c。在此文件中,您已定义函数main,并在main中尝试调用函数saguinag_get_shortest_path。但是,您尚未在comp_catpath.c中定义函数saguinag_get_shortest_path,并且它也未在igraph库或C标准库中定义。

If you already put the definition of saguinag_get_shortest_path in another .c file, you need to include that file's name in the definition of SRCS in your Makefile. If you didn't define saguinag_get_shortest_path anywhere, you need to write a definition for it, either in comp_catpath.c or in a new file (that you then add to SRCS).

如果已经将saguinag_get_shortest_path的定义放在另一个.c文件中,则需要在Makefile的SRCS定义中包含该文件的名称。如果没有在任何地方定义saguinag_get_shortest_path,则需要在comp_catpath.c或新文件(然后添加到SRCS)中为其编写定义。