Problem Description
If you want to build a project, using the Cygwin tool chain, that has dependencies to a third party library, you might experience a “multiple target patterns” error.
The usual procedure to do build a project that uses a third party library involves two steps.
- Add the Includes required for compiling in the Project Properties > C/C++ General > Paths and Symbols > Includes dialog.
- Add the library directories in the Library Search Path section of the Project Properties > C/C++ Build > Settings > Tool Settings > Cygwin C++ Linker > Libraries dialog. Then, in the Libraries section of the same dialog add all of your third party libraries.
NOTE: When adding your third party libraries be aware that you need to specify them with neither the “lib” prefix nor the extension. For example, if you have a library called libboost_regex.a, you should type in just boost_regex.a in the appropriate dialog. This is how the g++ compiler works, the Unix way.
Tools Used/Affected
- Eclipse IDE for C/C++ Developers (Eclipse Platform Ganymede (3.4.0), CDT 5.0.200806171202)
- Cygwin GCC tool chain (Make 3.81, GCC 3.4.4)
Solution
The root cause of the problem is that the Cygwin GCC tool chain expects paths to be in the unix style, but when Eclipse uses the values you specified for includes, library paths, e.t.c. to automatically generate the appropriate make files, it does not convert these values in Unix style and therefore building fails.
You are going to experience a beautiful build if you change all the paths you entered in Windows format to Unix format (e.g. C:\Cygwin\home to /home).
If you do this though, there is another shortcoming ahead, fortunately smaller than the previous one.
Because Eclipse won’t recognize the Unix path style you’re going to loose content assist (code completion) for the includes you specified and you’ll also get a “Path Entry Problem” warning.
UPDATE: As volador pointed me out, you may use windows paths but with forward slashes.
Conclusion
Paths definition, for projects targeting the Cygwin tool chain, seems to have been problematic since long ago for the CDT environment. There’s a relevant bug report that has been arround since 2005.
Using windows pathnames with forward slashes works both with Eclipse and Cygwin. For example, instead of “c:\cygwin\home” one can write “c:/cygwin/home” and have both Cygwin tools and Eclipse happy.
Comment by volador — July 12, 2008 @ 11:35 am
This doesn’t appear to be 100% accurate.
Yes the application compiles but the error about multiple targets is still generated.
Comment by new eclipse CDT guy — August 7, 2008 @ 6:45 am
[...] – bookmarked by 1 members originally found by LekoBautista on 2008-08-12 *** multiple target patterns using CDT 5.0 http://dreamlusion.wordpress.com/2008/07/12/multiple-target-patterns-using-cdt-50/ – bookmarked by [...]
Pingback by Bookmarks about Cygwin — August 30, 2008 @ 9:15 pm