opencv make:在Eclipse CDT上不对'all'执行任何操作

7uzetpgm  于 2022-11-15  发布在  Eclipse
关注(0)|答案(1)|浏览(142)

我正在学习OpenCV,但是我不能建立这个项目。
当我试图构建所有我得到这个错误:

22:49:54 **** Incremental Build of configuration Debug for project OpenCVLearning ****
make all 
make: Nothing to be done for `all'.

22:49:55 Build Finished (took 135ms)

当我尝试运行时,收到以下消息:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid

下面是Make文件的内容:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: OpenCVLearning

# Tool invocations
OpenCVLearning: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: GCC C++ Linker'
    g++ -L/usr/local/lib -o "OpenCVLearning" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) OpenCVLearning
    -@echo ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets

源代码:

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
    {
      printf( "No image data \n" );
      return -1;
    }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}

为什么会这样?我该怎么解决这个问题?

jaxagkaj

jaxagkaj1#

这不是问题
make:对'all'没有什么可做的。
这只是意味着,一切都已经构建好了,您可以开始测试您的可执行文件了。
第二个

terminate called after throwing an instance of 'std::logic_error'  
  what():  basic_string::_S_construct null not valid

是执行阶段错误。
它说,在某处你或OpenCV传递一个NULL指针到一个std::string构造函数,这是不允许的。
代码中唯一可能发生这种情况的地方可能是

image = imread( argv[1], 1 );

在这种情况下,argc为1,argv[1]NULL

相关问题