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.)
由于使用Eclipse更舒服,所以我想尝试从Visual Studio中转换项目。昨天我做了一个非常简单的测试。无论我尝试什么,都不能用“多目标模式”。(这与这个未回答的问题类似。)
I have three files:
我有三个文件:
Application.cpp:
Application.cpp:
using namespace std;
#include "Window.h"
int main() {
Window *win = new Window();
delete &win;
return 0;
}
Window.h:
Window.h:
#ifndef WINDOW_H_
#define WINDOW_H_
class Window {
public:
Window();
~Window();
};
#endif
Window.cpp:
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
):
我在编译器中添加了以下路径,包括path (-I):
"$(OPENCV)/cv/include"
"$(OPENCV)/cxcore/include"
"$(OPENCV)/otherlibs/highgui"
I have added the following libraries to the linker (-l
):
我已将下列库添加到链接器(-l):
cv
cxcore
highgui
And the following library search path (-L
):
和以下的库搜索路径(-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.
Eclipse、编译器和链接器都成功地包括了头和库。我使用的是Cygwin的GNU C/ c++编译器和链接器。
When compiling, I get the following make
error:
在编译时,我得到如下错误:
src/Window.d:1: *** multiple target patterns. Stop.
src /窗口。d:1: ***多个目标模式。停止。
Window.d contains:
窗口。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:
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.
我试着从窗口移除所有OpenCV标题。d(从第2行开始),但错误仍然存在。另外,我已经更新了Eclipse和OpenCV,这些都没用。
Do you have any ideas worth trying? I'm willing to try anything!
你有什么想法值得尝试吗?我愿意尝试任何事情!
9 个解决方案
#1
23
Are you working from a Cygwin installation?
你是在用Cygwin装置工作吗?
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.
在使用Cygwin之前,我已经看到了这个问题——基本上,make看到了:在path中,并且认为它是另一个目标定义,因此是错误的。
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.
如果您正在使用Cygwin安装,您可以尝试替换c:/ with /cygdrive/c/。如果没有,您可以尝试使用相对路径或使用网络挂载,并查看是否修复它。
#2
6
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.
根据其他互联网消息来源,这与cygwin制作的windows路径名称有关,特别是c:。对我来说,设置相对路径是没问题的。
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/
)
只需添加. ./mymodule/header /在编译器的项目配置中包含路径,这将找到头文件。并将生成具有相对路径的文件。编译器命令将会有-I../ mymodule里/头/)
looks like execution directory is always the project base directory.
看起来执行目录总是项目的基础目录。
#3
4
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:
在Cygwin上,由默认设置程序提供的GNU make版本3.81-1不适用于编译器生成的自动头文件依赖项。您将看到的错误消息将会是这样的:
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
这里有两个建议的修复:-尝试获得前一个版本(3.80)—获得一个固定的3.81版本,例如http://www.cmake.org/files/cygwin/make.exe。
src: https://projects.coin-or.org/BuildTools/wiki/current-issues
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.
只需将“C:\cygwin\bin\”文件夹(或任何cygwin安装的地方)的文件替换为上面提到的“固定”文件。
#4
1
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.
看起来有一个简单的方法来解决这个问题。只需将“当前构建器”从“GNU Make Builder”改为“CDT内部构建器”,在项目属性中——>C/ c++ Builder->工具链编辑器——>当前构建器就可以了。
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.
对我来说,这个问题是由“XXX”自动生成的。d“调试目录中的依赖文件(或版本:),由gcc -MF生成,作为gcc -c的副作用。但是,当-MF时,GNU显然忘了在文件名称周围添加引用。
"CDT Internal Builder" does not use makefile nor GNU make at all. Eclipse manage the build process itself.
“CDT内部构建器”不使用makefile,也不使用GNU。Eclipse管理构建过程本身。
If you insist to use GNU make, this doesn't work
如果你坚持使用GNU,这就行不通了。
#5
1
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.
在windows/cygwin上使用eclipse时,我还发现了多个目标模式的问题。我仅用相对路径解决了上述问题。我没有意识到我有绝对路径,但是当我使用项目目录指定一个包含目录时,eclipse将它扩展到完整的路径中。
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.
例如,如果您添加一个相对于工作空间的路径,eclipse会生成“${workspace_loc:/include}”,它将扩展到以“c:\”开头的内容。这就是为什么它会发生在我的案例中。
I simply replaced the complex string above with "../../include" and it solved my problem.
我只是用“../.. ..”替换了上面的复杂字符串。包括“它解决了我的问题”。
#6
0
You can also delete *.d files under output folders and then build
你也可以删除*。d文件在输出文件夹下,然后生成。
Debug/src/
#7
0
I'm working in the Cygwin environment, on Windows 7 (64bit), using Eclipse Kepler CDT for C++.
我在Cygwin环境中工作,在Windows 7(64位)上,使用Eclipse Kepler CDT为c++。
In Eclipse, goto
在Eclipse中,转到
Project --> Properties --> C++ Builder --> Settings --> Tool Settings Tab
项目——>属性——> c++ Builder——>设置——>工具设置选项卡。
Cygwin C++ Compiler --> Includes
Cygwin c++编译器——>包括。
In the Include paths (-I) add 2 paths: "C:\cygwin64\usr\include\libxml2"
在Include路径中(-I)添加两条路径:“C:\cygwin64\usr\包括\libxml2”
and "/cygdrive/c\cygwin64\usr\include\libxml2"
和“/ cygdrive / c \ cygwin64 \ usr \ \ libxml2”包括
#8
0
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.
为我工作的一个变化(我将Cygwin和SSH终端并行地使用到SVN服务器)是删除.d文件。当我调用Cygwin的make -f makefile时,它会破坏一些东西。我通常从Putty终端编译,然后从我的项目中删除。d文件后,它停止抱怨多个目标。
#9
0
The error "multiple target patterns. Stop." will occur because src/Window.d have the paths generated by compiler in windows platform as:
错误“多个目标模式”。会发生因为src/窗口。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 \
C:/程序\文件/ OpenCV / cv / include / cv。h \ C:\ /程序文件/ OpenCV / cxcore / include / cxcore。h \ C:\ /程序文件/ OpenCV / cxcore / include / cxtypes。h \ C:\ /程序文件/ 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:
如果您将这个项目导入到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 \
/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:/
如果你使用cygwin,同样适用。cygwin的路径格式是linux like format /cygdrive/c/而不是c:/。
#1
23
Are you working from a Cygwin installation?
你是在用Cygwin装置工作吗?
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.
在使用Cygwin之前,我已经看到了这个问题——基本上,make看到了:在path中,并且认为它是另一个目标定义,因此是错误的。
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.
如果您正在使用Cygwin安装,您可以尝试替换c:/ with /cygdrive/c/。如果没有,您可以尝试使用相对路径或使用网络挂载,并查看是否修复它。
#2
6
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.
根据其他互联网消息来源,这与cygwin制作的windows路径名称有关,特别是c:。对我来说,设置相对路径是没问题的。
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/
)
只需添加. ./mymodule/header /在编译器的项目配置中包含路径,这将找到头文件。并将生成具有相对路径的文件。编译器命令将会有-I../ mymodule里/头/)
looks like execution directory is always the project base directory.
看起来执行目录总是项目的基础目录。
#3
4
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:
在Cygwin上,由默认设置程序提供的GNU make版本3.81-1不适用于编译器生成的自动头文件依赖项。您将看到的错误消息将会是这样的:
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
这里有两个建议的修复:-尝试获得前一个版本(3.80)—获得一个固定的3.81版本,例如http://www.cmake.org/files/cygwin/make.exe。
src: https://projects.coin-or.org/BuildTools/wiki/current-issues
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.
只需将“C:\cygwin\bin\”文件夹(或任何cygwin安装的地方)的文件替换为上面提到的“固定”文件。
#4
1
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.
看起来有一个简单的方法来解决这个问题。只需将“当前构建器”从“GNU Make Builder”改为“CDT内部构建器”,在项目属性中——>C/ c++ Builder->工具链编辑器——>当前构建器就可以了。
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.
对我来说,这个问题是由“XXX”自动生成的。d“调试目录中的依赖文件(或版本:),由gcc -MF生成,作为gcc -c的副作用。但是,当-MF时,GNU显然忘了在文件名称周围添加引用。
"CDT Internal Builder" does not use makefile nor GNU make at all. Eclipse manage the build process itself.
“CDT内部构建器”不使用makefile,也不使用GNU。Eclipse管理构建过程本身。
If you insist to use GNU make, this doesn't work
如果你坚持使用GNU,这就行不通了。
#5
1
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.
在windows/cygwin上使用eclipse时,我还发现了多个目标模式的问题。我仅用相对路径解决了上述问题。我没有意识到我有绝对路径,但是当我使用项目目录指定一个包含目录时,eclipse将它扩展到完整的路径中。
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.
例如,如果您添加一个相对于工作空间的路径,eclipse会生成“${workspace_loc:/include}”,它将扩展到以“c:\”开头的内容。这就是为什么它会发生在我的案例中。
I simply replaced the complex string above with "../../include" and it solved my problem.
我只是用“../.. ..”替换了上面的复杂字符串。包括“它解决了我的问题”。
#6
0
You can also delete *.d files under output folders and then build
你也可以删除*。d文件在输出文件夹下,然后生成。
Debug/src/
#7
0
I'm working in the Cygwin environment, on Windows 7 (64bit), using Eclipse Kepler CDT for C++.
我在Cygwin环境中工作,在Windows 7(64位)上,使用Eclipse Kepler CDT为c++。
In Eclipse, goto
在Eclipse中,转到
Project --> Properties --> C++ Builder --> Settings --> Tool Settings Tab
项目——>属性——> c++ Builder——>设置——>工具设置选项卡。
Cygwin C++ Compiler --> Includes
Cygwin c++编译器——>包括。
In the Include paths (-I) add 2 paths: "C:\cygwin64\usr\include\libxml2"
在Include路径中(-I)添加两条路径:“C:\cygwin64\usr\包括\libxml2”
and "/cygdrive/c\cygwin64\usr\include\libxml2"
和“/ cygdrive / c \ cygwin64 \ usr \ \ libxml2”包括
#8
0
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.
为我工作的一个变化(我将Cygwin和SSH终端并行地使用到SVN服务器)是删除.d文件。当我调用Cygwin的make -f makefile时,它会破坏一些东西。我通常从Putty终端编译,然后从我的项目中删除。d文件后,它停止抱怨多个目标。
#9
0
The error "multiple target patterns. Stop." will occur because src/Window.d have the paths generated by compiler in windows platform as:
错误“多个目标模式”。会发生因为src/窗口。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 \
C:/程序\文件/ OpenCV / cv / include / cv。h \ C:\ /程序文件/ OpenCV / cxcore / include / cxcore。h \ C:\ /程序文件/ OpenCV / cxcore / include / cxtypes。h \ C:\ /程序文件/ 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:
如果您将这个项目导入到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 \
/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:/
如果你使用cygwin,同样适用。cygwin的路径格式是linux like format /cygdrive/c/而不是c:/。