gpt4 book ai didi

c++ - 生成文件:6:目标 'all' 的配方在 ubuntu-16.04 上失败

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:04:45 24 4
gpt4 key购买 nike

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”是什么意思?

我在谷歌和堆栈溢出中找不到这个.....

而且,我听说即使有警告也能正常工作。所以我没有检查这些警告。

无论如何,请帮助..

最佳答案

这个

Makefile:6: recipe for target 'all' failed

意味着,如果没有指定其他目标,则隐式调用的目标“all”有错误,并且它在第 6 行的 Makefile 中定义。

底层错误是这个链接器错误:

undefined reference to `CarBST::CarBST()'

这是您必须解决的问题。你用来编译链接的命令是:

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 文件可能包含类定义,但存在于此。看起来没有无参数的构造函数;向类中添加一个或调用可用的构造函数。

此外,在编译器命令行指定头文件(*.h)并不常见,这些文件通常包含在源文件(*.cpp)中。

最后,您不应该忽略警告并检查为什么将 NULL 指针分配给 chars。应该是这样

state = 0;

或类似的。

关于c++ - 生成文件:6:目标 'all' 的配方在 ubuntu-16.04 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52580082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com