試圖讓C++程序拆分一條線並創建2個std::vector
以保存來自所述線的元素。 這就是我所說的功能:鏈接時未定義的功能引用
void readConf(const char *name, std::vector<t_objectLibrary> libs, std::vector<IObject *> &objs, std::vector<IObject *> &timer)
我放在裏面config.hpp它有它的原型:
void readConf(const char *name, std::vector<t_objectLibrary> libs,std::vector<IObject *> &objs, std::vector<IObject *> timer);
,並在主我這樣稱呼它:
int main(int ac, char **av)
{
std::vector<IObject *> objs;
std::vector<IObject *> timer;
std::vector<t_objectLibrary> libs;
libs = lib_read("./src/objectLibrary");
readConf("config.txt", libs, objs, timer);
...
}
但我用Makefile編譯時遇到了這個錯誤信息。一切都很好,直到編輯的最後一條消息是這樣說:
這裏是我的Makefile使用(在評論中問道):
11 │ SRC = src/getvalue.cpp \
12 │ src/iobject.cpp \
13 │ src/attributes.cpp \
14 │ src/dynamic_lib.cpp \
15 │ src/config.cpp \
16 │ src/color.cpp \
17 │ src/main.cpp
18 │
19 │ OBJ = $(SRC:.cpp=.o)
20 │
21 │ NAME = conf
22 │
23 │ CXX = g++ -std=c++11 -Wall -Wextra -lsfml-graphics -lsfml-window -lsfml-system -fPIC
24 │
25 │ RM = rm -f
26 │
27 │ all: $(NAME) $(OBJ)
28 │
29 │ $(NAME): $(OBJ)
30 │ $(CXX) $(OBJ) -o $(NAME) -ldl
31 │
32 │ clean:
33 │ $(RM) $(OBJ)
34 │
35 │ fclean: clean
36 │ $(RM) $(NAME)
37 │
38 │ re: fclean all
39 │
40 │ .phony: all clean fclean re
不是「超鏈接」,我想輸入「鏈接」或「鏈接」,對不起 – Romain
嚴格地說,你的程序*不會*編譯,它只是不*鏈接*。 :)請發佈您正在使用的命令行或makefile。 –
你確實在某處定義了'readConf'並且鏈接到包含該定義的目標文件嗎? – TartanLlama