Marcus Tik
Marcus Tik

Reputation: 1811

How to add a library to an Eclipse project

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

Library: gdi32.lib -> In 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'

Upvotes: 15

Views: 47925

Answers (3)

SAJEEVAN K
SAJEEVAN K

Reputation: 1

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

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

Problem remained unsolved till I do this.

Upvotes: 0

ntcong
ntcong

Reputation: 800

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

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

Upvotes: 21

mmmmmm
mmmmmm

Reputation: 32710

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

Upvotes: 7

Related Questions