如何将库添加到 Eclipse 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1351712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:54:28  来源:igfitidea点击:

How to add a library to an Eclipse project

eclipseeclipse-cdt

提问by Marcus Tik

I'm trying to add a Library to Eclipse Galileo and it won't work out.

我正在尝试向 Eclipse Galileo 添加一个库,但它不会成功。

Library: gdi32.lib -> In MinGW: libgdi32.a

库:gdi32.lib -> 在 MinGW 中:libgdi32.a

Whatever I try, it doesn't work. Can anyone tell me EXACTLY what to enter where, to accomplish this ?

无论我尝试什么,它都不起作用。任何人都可以告诉我确切地输入什么,以完成此操作吗?

Details:

细节:

I have the function call:

我有函数调用:

wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

... lead's to error:

...导致错误:

WinMain.o: In function `WinMain':
Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:29: 
  undefined reference to `GetStockObject@4'

And I have the function call:

我有函数调用:

TextOut(hdc, 0, 0, TEXT("Hello World!"), 12);

... lead's to error:

...导致错误:

WinMain.o: In function `WndProc':
Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:88: 
  undefined reference to `TextOutA@20'

回答by ntcong

right click to project -> Properties -> C/C++ Build, go to Library and add it there.

右键单击项目-> 属性-> C/C++ 构建,转到库并将其添加到那里。

if the library is libgdi32.a, you should add gdi32in the library section.

如果库是libgdi32.a,则应添加gdi32到库部分。

回答by user151019

If on eclipse 3.5 the place to add is project->properties->C++ Build->Settings Then choose the tool chain you are using then in Libraries and add the library name to the top box and the path to the bottom

如果在 eclipse 3.5 上添加的地方是 project->properties->C++ Build->Settings 然后在 Libraries 中选择您正在使用的工具链并将库名称添加到顶部框并将路径添加到底部

回答by SAJEEVAN K

I have the similar problem. As Mark suggested, in project->properties->C++ Build->Settings, we have to add

我有类似的问题。正如马克所建议的,在项目->属性->C++ Build->设置中,我们必须添加

1) library name (for eg: libsnap7.so, only snap7 is the name) 2) library path (eg: /usr/lib)

1) 库名称(例如:libsnap7.so,只有 snap7 是名称) 2) 库路径(例如:/usr/lib)

Problem remained unsolved till I do this.

在我这样做之前,问题仍未解决。