I'm trying to learn OpenCV following this tutorial . But I cannot build the project.
When I try to build all I get this error:
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)
When I try to run I get this message:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Here is the content of the Make file:
################################################################################
# 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
Source code:
#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;
}
Why is it happening? How could I solve this?
This is not a problem
make: Nothing to be done for `all'.
it just means, that everything is already built and you're ready to go and test your executable.
The second one
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
is a runtime error.
It says, that somewhere you or OpenCV pass a NULL
pointer to a std::string
constructor, which is not allowed.
The only place, where this could happen in your code, might be
image = imread( argv[1], 1 );
when you call the executable without parameters. In this case argc
is one and argv[1]
is NULL
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.