makefile:6:目标 'all' 的配方在 ubuntu-16.04 失败
makefile:6: recipe for target 'all' failed on ubuntu-16.04
g++ -std=c++11 -g -o run NumberNode.cpp LinkedList.cpp CarBST.cpp Queue.cpp CarNode.cpp Manager.cpp main.cpp NumberBST.cpp CarBST.h Queue.h CarNode.h Manager.h NumberBST.h NumberNode.h LinkedList.h
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberNode.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberNode.cpp: In destructor ‘NumberNode::~NumberNode()’:
NumberNode.cpp:13:9: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
number = NULL;
^
In file included from LinkedList.h:2:0,
from LinkedList.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarBST.h:2:0,
from CarBST.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarBST.cpp: In member function ‘void CarBST::Delete(int)’:
CarBST.cpp:90:21: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
int lastLocation = NULL; //leafNode \B0\E6\BF\EC \BAθ\F0\B3\EB\B5\E5\C0\C7 \B
^
In file included from Queue.h:2:0,
from Queue.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarNode.cpp:1:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarNode.cpp: In destructor ‘CarNode::~CarNode()’:
CarNode.cpp:12:12: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
carNumber = NULL;
^
CarNode.cpp:14:8: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from LinkedList.h:2:0,
from Manager.h:11,
from Manager.cpp:6:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from LinkedList.h:2:0,
from Manager.h:11,
from main.cpp:3:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberBST.h:2,
from NumberBST.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberBST.cpp: In member function ‘void NumberBST::Delete(int)’:
NumberBST.cpp:119:21: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
int lastLocation = NULL; //leafNode \B0\E6\BF\EC \BAθ\F0\B3\EB\B5\E5\C0\C7 \B
^
CarBST.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
Queue.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from Queue.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarNode.h:1:9: warning: #pragma once in main file
#pragma once
^
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
Manager.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from LinkedList.h:2:0,
from Manager.h:11:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberBST.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberBST.h:2:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberNode.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0,
from NumberNode.h:2:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
LinkedList.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from LinkedList.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
/tmp/ccYwuJus.o: In function `Manager::MOVE(int)':
/home/limsh/project/Manager.cpp:172: undefined reference to `CarBST::CarBST()'
/tmp/ccYwuJus.o: In function `Manager::Insert_BST(std::basic_ifstream<char, std::char_traits<char> >&)':
/home/limsh/project/Manager.cpp:363: undefined reference to `CarBST::CarBST()'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 1
我不知道如何解决这个问题。
此程序在 VS2017 上运行。
但在 ubuntu,无法解决此问题。
剂量 'makefile:6' 是什么意思?
我在 google 上找不到这个并且堆栈溢出.....
而且,我听说即使有警告也能正常工作。所以我没有检查这些警告。
无论如何,请帮忙..
这个
Makefile:6: recipe for target 'all' failed
意味着目标 'all' 在没有指定其他目标的情况下被隐式调用,它有错误并且它在 Makefile 的第 6 行定义。
根本错误是这个 linker 错误:
undefined reference to `CarBST::CarBST()'
这是您必须解决的问题。你用来编译和link的命令是:
g++ -std=c++11 -g -o run NumberNode.cpp LinkedList.cpp CarBST.cpp Queue.cpp CarNode.cpp Manager.cpp main.cpp NumberBST.cpp CarBST.h Queue.h CarNode.h Manager.h NumberBST.h NumberNode.h LinkedList.h
一个文件 CarBST.cpp
可能包含 class 定义,但是那里存在。看起来没有无参数的构造函数;向 class 添加一个或调用可用的构造函数。
此外,在编译器命令行中指定头文件 (*.h) 的情况并不常见,这些文件通常包含在源文件 (*.cpp) 中。
最后,您不应忽略警告并检查为什么将 NULL 指针分配给字符。这应该是
state = 0;
或类似。
g++ -std=c++11 -g -o run NumberNode.cpp LinkedList.cpp CarBST.cpp Queue.cpp CarNode.cpp Manager.cpp main.cpp NumberBST.cpp CarBST.h Queue.h CarNode.h Manager.h NumberBST.h NumberNode.h LinkedList.h
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberNode.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberNode.cpp: In destructor ‘NumberNode::~NumberNode()’:
NumberNode.cpp:13:9: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
number = NULL;
^
In file included from LinkedList.h:2:0,
from LinkedList.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarBST.h:2:0,
from CarBST.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarBST.cpp: In member function ‘void CarBST::Delete(int)’:
CarBST.cpp:90:21: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
int lastLocation = NULL; //leafNode \B0\E6\BF\EC \BAθ\F0\B3\EB\B5\E5\C0\C7 \B
^
In file included from Queue.h:2:0,
from Queue.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarNode.cpp:1:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarNode.cpp: In destructor ‘CarNode::~CarNode()’:
CarNode.cpp:12:12: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
carNumber = NULL;
^
CarNode.cpp:14:8: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from LinkedList.h:2:0,
from Manager.h:11,
from Manager.cpp:6:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from LinkedList.h:2:0,
from Manager.h:11,
from main.cpp:3:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberBST.h:2,
from NumberBST.cpp:1:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberBST.cpp: In member function ‘void NumberBST::Delete(int)’:
NumberBST.cpp:119:21: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
int lastLocation = NULL; //leafNode \B0\E6\BF\EC \BAθ\F0\B3\EB\B5\E5\C0\C7 \B
^
CarBST.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
Queue.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from Queue.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
CarNode.h:1:9: warning: #pragma once in main file
#pragma once
^
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
Manager.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from LinkedList.h:2:0,
from Manager.h:11:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberBST.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0,
from NumberNode.h:2,
from NumberBST.h:2:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
NumberNode.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from CarBST.h:2:0,
from NumberNode.h:2:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
LinkedList.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from LinkedList.h:2:0:
CarNode.h: In constructor ‘CarNode::CarNode(int)’:
CarNode.h:24:9: warning: converting to non-pointer type ‘char’ from NULL [-Wconversion-null]
state = NULL;
^
/tmp/ccYwuJus.o: In function `Manager::MOVE(int)':
/home/limsh/project/Manager.cpp:172: undefined reference to `CarBST::CarBST()'
/tmp/ccYwuJus.o: In function `Manager::Insert_BST(std::basic_ifstream<char, std::char_traits<char> >&)':
/home/limsh/project/Manager.cpp:363: undefined reference to `CarBST::CarBST()'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 1
我不知道如何解决这个问题。
此程序在 VS2017 上运行。
但在 ubuntu,无法解决此问题。
剂量 'makefile:6' 是什么意思?
我在 google 上找不到这个并且堆栈溢出.....
而且,我听说即使有警告也能正常工作。所以我没有检查这些警告。
无论如何,请帮忙..
这个
Makefile:6: recipe for target 'all' failed
意味着目标 'all' 在没有指定其他目标的情况下被隐式调用,它有错误并且它在 Makefile 的第 6 行定义。
根本错误是这个 linker 错误:
undefined reference to `CarBST::CarBST()'
这是您必须解决的问题。你用来编译和link的命令是:
g++ -std=c++11 -g -o run NumberNode.cpp LinkedList.cpp CarBST.cpp Queue.cpp CarNode.cpp Manager.cpp main.cpp NumberBST.cpp CarBST.h Queue.h CarNode.h Manager.h NumberBST.h NumberNode.h LinkedList.h
一个文件 CarBST.cpp
可能包含 class 定义,但是那里存在。看起来没有无参数的构造函数;向 class 添加一个或调用可用的构造函数。
此外,在编译器命令行中指定头文件 (*.h) 的情况并不常见,这些文件通常包含在源文件 (*.cpp) 中。
最后,您不应忽略警告并检查为什么将 NULL 指针分配给字符。这应该是
state = 0;
或类似。