简体   繁体   English

如何在Eclipse中运行用MinGW编译的C ++程序? 如何“链接(?)”?

[英]How to run a C++ program compiled with MinGW in Eclipse? How to “link(?)”?

before I start: sorry for my lack of english, I hope you can help me anyway, I'm a beginner. 在我开始之前:对不起,我没有英语,我希望你能为我提供帮助,我是一个初学者。

I have the following problem. 我有以下问题。 I want to run a C++ program in Eclipse which uses the boost library and other librarys. 我想在使用boost库和其他库的Eclipse中运行C ++程序。 I use the MinGW Compiler, but when I try to debug / run the program I get this Error: 我使用MinGW编译器,但是当我尝试调试/运行程序时,出现此错误:

cannot find -lC:\\Users*myusername*\\Desktop\\git\\include cannot find -lC:\\Users*myusername*\\Desktop\\git\\include\\boost 找不到-lC:\\ Users * myusername * \\ Desktop \\ git \\ include找不到-lC:\\ Users * myusername * \\ Desktop \\ git \\ include \\ boost

I included the libraries in the following way: Project -> Properties -> C++ General -> Path and Symbols -> Libraries -> Here I added those 2 folders (include and boost). 我以以下方式包括库:项目->属性-> C ++常规->路径和符号->库->在这里,我添加了这两个文件夹(包括和boost)。 In Library Paths I just included the "include" folder. 在库路径中,我只包含了“ include”文件夹。 I also included "include" in the includes-tab. 我还在includes标签中添加了“ include”。

I also made changes here: Project -> Properties -> C++ Build -> Settings -> Tool Settings. 我还在这里进行了更改:项目->属性-> C ++构建->设置->工具设置。 I filled the 2 fields (-l and -L) with both "include" and "boost". 我用“ include”和“ boost”填充了两个字段(-l和-L)。

I have no clue what I could do to fix this. 我不知道该如何解决。 Do I have to add both the include and the boost folder? 我是否必须同时添加include和boost文件夹? The reason why I ask this is because the boost folder is in the include folder (as you can see in the error-text). 我之所以这样问,是因为boost文件夹在include文件夹中(如您在错误文本中所见)。

My question is now: How can I avoid/fix those mistakes? 我现在的问题是:如何避免/纠正这些错误?

In "Libraries" tab you must specify only libraries names, like "boost" in your case, not the folders. 在“库”选项卡中,您只能指定库名称(例如您的情况下的“ boost”),而不是文件夹。 In Library Paths add full paths to every library, specified at "Libraries" tab, so compiler could find it. 在“库路径”中,向“库”选项卡上指定的每个库添加完整路径,以便编译器可以找到它。 On the "Includes" tab you have to specify paths to your folders with program headers, i suppose adding "C:\\Users*yourusername*\\Desktop\\git\\include" will work good. 在“包含”选项卡上,您必须使用程序标头指定文件夹的路径,我想添加“ C:\\ Users *您的用户名* \\ Desktop \\ git \\ include”会很好。 And after that you don't have to manually fill fields at Tool Settings screen, you did it already on another tabs. 之后,您不必在“工具设置”屏幕上手动填写字段,而已在其他选项卡上完成了此操作。


Added: By the look of your error i can suggest that you added full paths to folders at "Libraries" tab, not the libraries names. 补充:从您的错误来看,我可以建议您在“库”选项卡上添加完整路径到文件夹,而不是库名称。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM