gpt4 book ai didi

c++ - 未定义对 `main' 的引用 - 但包含主要功能

转载 作者:太空宇宙 更新时间:2023-11-04 11:15:13 27 4
gpt4 key购买 nike

<分区>

我在尝试编译我的代码时遇到以下错误:

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

我正在使用以下命令:

g++ detectTemplatePoints.cpp -o SURF_TemplatePoints `pkg-config --cflags --libs opencv`

根据我在网上可以找到的信息,当您没有包含 main 入口点时,这似乎会发生,但我确实有,我的代码如下:

#include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;

void readme();
int main (int argc, char* argv[]) {
if( argc != 2 ) {
readme(); return -1;
}
Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
if( !img_1.data ) {
std::cout<< " --(!) Error reading images " << std::endl; return -1;
}
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1;
detector.detect( img_1, keypoints_1 );
Mat img_keypoints_1;
drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
imshow("Keypoints 1", img_keypoints_1 );
waitKey(0);
return 0;
}
void readme() {
std::cout << " Usage: ./detectTemplatePoints <img1>" << std::endl;
}

是什么导致了这个错误?

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