【问题标题】:makefile:6: recipe for target 'all' failed on ubuntu-16.04makefile:6:目标“所有”的配方在 ubuntu-16.04 上失败
【发布时间】:2018-09-30 16:54:14
【问题描述】:
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' 是什么意思?

我在谷歌上找不到这个并且堆栈溢出.....

而且,我听说它甚至可以在出现警告的情况下工作。所以我没有检查这些警告。

无论如何,请帮助..

【问题讨论】:

    标签: c++ visual-studio makefile ubuntu-16.04


    【解决方案1】:

    这个

    Makefile:6: recipe for target 'all' failed
    

    意味着,如果没有指定其他目标,则隐式调用的目标“所有”有错误,并且它在第 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 指针分配给字符。这应该是

    state = 0;
    

    或类似的。

    【讨论】:

      猜你喜欢
      • 2018-11-24
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 2018-06-06
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多