非常简单的应用程序因“多个目标模式”而失败来自日食

发布于 2024-08-24 16:19:43 字数 2967 浏览 3 评论 0原文

由于我更喜欢​​使用 Eclipse,因此我想尝试从 Visual Studio 转换我的项目。昨天我尝试了一个非常简单的小测试。无论我尝试什么,make都会因“多个目标模式”而失败。 (这类似于这个未回答的问题。)

我有三个文件:

Application.cpp :

using namespace std;

#include "Window.h"

int main() {
    Window *win = new Window();
    delete &win;
    return 0;
}

Window.h:

#ifndef WINDOW_H_
#define WINDOW_H_

class Window {
public:
    Window();
    ~Window();
};

#endif

Window.cpp:

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

#include "Window.h"

const char* WINDOW_NAME = "MyApp";

Window::Window() {
    cvNamedWindow(WINDOW_NAME, CV_WINDOW_AUTOSIZE);
    cvResizeWindow(WINDOW_NAME, 200, 200);
    cvMoveWindow(WINDOW_NAME, 0, 0);
    int key = 0;
    while (true) {
        key = cvWaitKey(0);
        if (key==27 || cvGetWindowHandle(WINDOW_NAME)==0) {
            break;
        }
    }
}
Window::~Window() {
    cvDestroyWindow(WINDOW_NAME);
}

我已将以下路径添加到编译器包含路径 (-I):

"$(OPENCV)/cv/include"
"$(OPENCV)/cxcore/include"
"$(OPENCV)/otherlibs/highgui"

我已将以下库添加到链接器 (-l):

cv
cxcore
highgui

以及以下库搜索路径 (-L):

"$(OPENCV)/lib/"

Eclipse、编译器和链接器都成功包含头文件和库。我正在使用 GNU C/C++ 编译器 &来自 Cygwin 的链接器。

编译时,我收到以下 make 错误:

src/Window.d:1: *** 多个目标模式。停止。

Window.d 包含:

src/Window.d src/Window.o: ../src/Window.cpp \
  C:/Program\ Files/OpenCV/cv/include/cv.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxerror.h \
  C:/Program\ Files/OpenCV/cxcore/include/cvver.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp \
  C:/Program\ Files/OpenCV/cv/include/cvtypes.h \
  C:/Program\ Files/OpenCV/cv/include/cv.hpp \
  C:/Program\ Files/OpenCV/cv/include/cvcompat.h \
  C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.h ../src/Constants.h \
  ../src/Window.h
C:/Program\ Files/OpenCV/cv/include/cv.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h:
C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h:
C:/Program\ Files/OpenCV/cxcore/include/cxerror.h:
C:/Program\ Files/OpenCV/cxcore/include/cvver.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp:
C:/Program\ Files/OpenCV/cv/include/cvtypes.h:
C:/Program\ Files/OpenCV/cv/include/cv.hpp:
C:/Program\ Files/OpenCV/cv/include/cvcompat.h:
C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h:
../src/Window.h:

我尝试从 Window.d 中删除所有 OpenCV 标头(从第 2 行开始),但错误仍然存​​在。另外,我已经更新了Eclipse和OpenCV,但都无济于事。

您有什么值得尝试的想法吗?我什么都愿意尝试!

Since I'm more comfortable using Eclipse, I thought I'd try converting my project from Visual Studio. Yesterday I tried a very simple little test. No matter what I try, make fails with "multiple target patterns". (This is similar to this unanswered question.)

I have three files:

Application.cpp:

using namespace std;

#include "Window.h"

int main() {
    Window *win = new Window();
    delete &win;
    return 0;
}

Window.h:

#ifndef WINDOW_H_
#define WINDOW_H_

class Window {
public:
    Window();
    ~Window();
};

#endif

Window.cpp:

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

#include "Window.h"

const char* WINDOW_NAME = "MyApp";

Window::Window() {
    cvNamedWindow(WINDOW_NAME, CV_WINDOW_AUTOSIZE);
    cvResizeWindow(WINDOW_NAME, 200, 200);
    cvMoveWindow(WINDOW_NAME, 0, 0);
    int key = 0;
    while (true) {
        key = cvWaitKey(0);
        if (key==27 || cvGetWindowHandle(WINDOW_NAME)==0) {
            break;
        }
    }
}
Window::~Window() {
    cvDestroyWindow(WINDOW_NAME);
}

I have added the following paths to the compiler include path (-I):

"$(OPENCV)/cv/include"
"$(OPENCV)/cxcore/include"
"$(OPENCV)/otherlibs/highgui"

I have added the following libraries to the linker (-l):

cv
cxcore
highgui

And the following library search path (-L):

"$(OPENCV)/lib/"

Eclipse, the compiler and the linker all succeed in including the headers and libraries. I am using the GNU C/C++ compiler & linker from Cygwin.

When compiling, I get the following make error:

src/Window.d:1: *** multiple target patterns. Stop.

Window.d contains:

src/Window.d src/Window.o: ../src/Window.cpp \
  C:/Program\ Files/OpenCV/cv/include/cv.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxerror.h \
  C:/Program\ Files/OpenCV/cxcore/include/cvver.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp \
  C:/Program\ Files/OpenCV/cv/include/cvtypes.h \
  C:/Program\ Files/OpenCV/cv/include/cv.hpp \
  C:/Program\ Files/OpenCV/cv/include/cvcompat.h \
  C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h \
  C:/Program\ Files/OpenCV/cxcore/include/cxcore.h ../src/Constants.h \
  ../src/Window.h
C:/Program\ Files/OpenCV/cv/include/cv.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h:
C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h:
C:/Program\ Files/OpenCV/cxcore/include/cxerror.h:
C:/Program\ Files/OpenCV/cxcore/include/cvver.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp:
C:/Program\ Files/OpenCV/cv/include/cvtypes.h:
C:/Program\ Files/OpenCV/cv/include/cv.hpp:
C:/Program\ Files/OpenCV/cv/include/cvcompat.h:
C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h:
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h:
../src/Window.h:

I tried removing all OpenCV headers from Window.d (from line 2 onwards), but the error remains. Also, I've updated Eclipse and OpenCV, all to no avail.

Do you have any ideas worth trying? I'm willing to try anything!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

吖咩 2024-08-31 16:19:43

您是否在 Cygwin 安装中工作?

我在使用 Cygwin 之前就见过这个问题——基本上,make 看到路径中的 : 并认为它是另一个目标定义,因此出现错误。

如果您使用 Cygwin 安装,则可以尝试将 c:/ 替换为 /cygdrive/c/。如果没有,您可以尝试使用相对路径或使用网络安装,看看是否可以解决问题。

Are you working from a Cygwin installation?

I've seen this problem before using Cygwin--basically, make sees the : in the path and thinks it is another target definition, hence the error.

If you are working from a Cygwin installation, you might try replacing the c:/ with /cygdrive/c/. If not, you might try using relative paths or using a network mount and see if that fixes it.

烟─花易冷 2024-08-31 16:19:43

根据其他互联网来源,这与 cygwin make 的 Windows 路径名问题有关,特别是 c:。
对我来说,设置相对路径效果很好。

例如,如果您有类似的内容,

proj/mymodule/headers/afile.h
proj/mymodule/source/abc/afile.c

只需添加 ../mymodule/headers/
作为编译器项目配置中的包含路径,这将找到头文件 afile.h 并生成具有相对路径的 make 文件。
(编译器命令将包含语句 -I../mymodule/headers/

看起来执行目录始终是项目基目录。

according to other internet sources this is related to a problem that cygwin make has with windows path names, specially the c:.
For me it workes fine with setting relative paths instead.

e.g. if you have something like

proj/mymodule/headers/afile.h
proj/mymodule/source/abc/afile.c

just add ../mymodule/headers/
as include path in the project configuration for the compiler this will find the header afile.h and will generate make files with relative path.
(compiler command will have the statement -I../mymodule/headers/ )

looks like execution directory is always the project base directory.

你的呼吸 2024-08-31 16:19:43

在 Cygwin 上,默认安装程序提供的 GNU make 版本 3.81-1 不适用于编译器生成的自动头文件依赖项。由于此错误,您将看到的错误消息如下所示:

以下是两个建议的修复方法:
- 尝试获取以前的版本(3.80)
- 获取固定的 3.81 版本,例如从 http://www.cmake.org/files /cygwin/make.exe

src:https://projects.coin -or.org/BuildTools/wiki/current-issues

只需将“C:\cygwin\bin\”文件夹(或安装 cygwin 的任何位置)中的 make 文件替换为上面提到的“固定”make 文件即可。

On Cygwin, GNU make version 3.81-1 delivered by the default setup program doesn't work with the automatic header file dependencies, generated by the compilers. The error message you will see because of this bug will look something like this:

Here are two suggested fixes:
- Try to obtain the previous version (3.80)
- Obtain a fixed 3.81 version, for example from http://www.cmake.org/files/cygwin/make.exe

src: https://projects.coin-or.org/BuildTools/wiki/current-issues

Simply replace the make file in your "C:\cygwin\bin\" folder (or wherever cygwin is installed) with the "fixed" make file mentioned above.

疏忽 2024-08-31 16:19:43

看起来有一个简单的方法可以解决这个问题。
只需在项目属性->C/C++ Builder->工具链编辑器->Current Builder 中将“Current Builder”从“GNU Make Builder”更改为“CDT Internal Builder”即可。

对我来说,这个问题是由 Debug 目录(或release:)中自动生成的“XXX.d”依赖文件引起的,这些文件是由 gcc -MF 作为 gcc -c 的副作用生成的。但是 GNU make 显然忘记在 -MF 时在文件名周围添加引号。

“CDT Internal Builder”根本不使用 makefile 或 GNU make。 Eclipse 自行管理构建过程。

如果你坚持使用 GNU make,这是行不通的

Looks like there is a simple way to solve this.
Just change the "Current Builder" from "GNU Make Builder" to "CDT Internal Builder" in Project properties->C/C++ Builder->Tool Chain Editor->Current Builder will do.

To me, this problem is caused by the automatically generated "XXX.d" dependency files in Debug directory (or release :), which were generated by gcc -MF as a side-effect to gcc -c. But GNU make obviously forgot to add quotations around file names when -MF.

"CDT Internal Builder" does not use makefile nor GNU make at all. Eclipse manage the build process itself.

If you insist to use GNU make, this doesn't work

四叶草在未来唯美盛开 2024-08-31 16:19:43

在 windows/cygwin 上使用 eclipse 时,我还遇到了 make 报告的多个目标模式的问题。我通过仅使用相对路径解决了上面建议的问题。我没有意识到我有绝对路径,但是当我使用项目目录指定包含目录时,eclipse将其扩展为完整路径。

例如,如果添加相对于工作空间的路径,Eclipse 会生成“${workspace_loc:/include}”,它将扩展为以“c:\”开头的内容。这就是我的例子中发生这种情况的原因。

我只是用“../../include”替换了上面的复杂字符串,它解决了我的问题。

I also had the problem of multiple target patterns reported by make when using eclipse on windows/cygwin. I solved the problem as suggested above by using only relative paths. I didn't realize that I had absolute paths, but when I specified an include directory using the project directory, eclipse expanded it into the full path.

For instance, if you add a path relative to the workspace, eclipse generates ""${workspace_loc:/include}"" which will expand to something starting with "c:\". This is why it was happening in my case.

I simply replaced the complex string above with "../../include" and it solved my problem.

╰◇生如夏花灿烂 2024-08-31 16:19:43

您还可以删除输出文件夹下的 *.d 文件,然后构建

Debug/src/

You can also delete *.d files under output folders and then build

Debug/src/
夜雨飘雪 2024-08-31 16:19:43

我在 Windows 7(64 位)的 Cygwin 环境中工作,使用 Eclipse Kepler CDT for C++。

在 Eclipse 中,转到

项目 -->属性--> C++ 构建器 -->设置-->工具设置
标签

Cygwin C++ 编译器 -->包括

在包含路径 (-I) 中添加 2 个路径:"C:\cygwin64\usr\include\libxml2"

"/cygdrive/c\cygwin64\usr\include\libxml2"

I'm working in the Cygwin environment, on Windows 7 (64bit), using Eclipse Kepler CDT for C++.

In Eclipse, goto

Project --> Properties --> C++ Builder --> Settings --> Tool Settings
Tab

Cygwin C++ Compiler --> Includes

In the Include paths (-I) add 2 paths: "C:\cygwin64\usr\include\libxml2"

and "/cygdrive/c\cygwin64\usr\include\libxml2"

尬尬 2024-08-31 16:19:43

对我有用的一项更改(我并行使用 Cygwin 和 SSH 终端进入 SVN 服务器)是删除 .d 文件。当我从 Cygwin 调用 make -f makefile 时,它破坏了一些东西。我通常从 Putty 终端进行编译,从项目中删除 .d 文件后,它不再抱怨多个目标。

One change that worked for me (I use Cygwin and SSH terminal into an SVN server in parallel) was to delete the .d files. When I called the make -f makefile from Cygwin, it broke something. I usually compile from the Putty terminal, and after deleting the .d files from my project it stopped complaining about the multiple targets.

爱殇璃 2024-08-31 16:19:43

错误“多个目标模式。停止。”会发生,因为 src/Window.d 具有 Windows 平台中编译器生成的路径:

C:/Program\ Files/OpenCV/cv/include/cv.h \
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h \
C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h \
C:/Program\ Files/OpenCV/cxcore/include/cxerror.h \

如果您将此项目导入到 Linux 平台的 Eclipse 中,我建议您进行干净的构建,以便下次构建生成 Linux 中的路径格式为:

/home/user/OpenCV/cv/include/cv.h \
/home/user/OpenCV/cxcore/include/cxcore.h \
/home/user/OpenCV/cxcore/include/cxtypes.h \
/home/user/OpenCV/cxcore/include/cxerror.h \

如果您使用 cygwin,则同样适用。 cygwin 中的路径格式类似于 linux 格式 /cygdrive/c/ 而不是 C:/

The error "multiple target patterns. Stop." will occur because src/Window.d have the paths generated by compiler in windows platform as:

C:/Program\ Files/OpenCV/cv/include/cv.h \
C:/Program\ Files/OpenCV/cxcore/include/cxcore.h \
C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h \
C:/Program\ Files/OpenCV/cxcore/include/cxerror.h \

If you import this project into Eclipse in Linux platform, I would recommend you to give a clean build so that next build generates the path in Linux format as:

/home/user/OpenCV/cv/include/cv.h \
/home/user/OpenCV/cxcore/include/cxcore.h \
/home/user/OpenCV/cxcore/include/cxtypes.h \
/home/user/OpenCV/cxcore/include/cxerror.h \

The same is applicable, if you are using cygwin. The path format in cygwin is linux like format /cygdrive/c/ instead of C:/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文