Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 538
Marcus Tik Avatar asked Aug 29 '09 15:08

Marcus Tik


People also ask

How do I add a library to an existing project in Eclipse?

Right-click the project and select "Build Path » Add Libraries..." from the pop-up menu. From the dialog window that pops up, select "User Library" and click the "Next" button.

How do I add a library to my project?

Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.


1 Answers

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.

like image 112
ntcong Avatar answered Sep 21 '22 20:09

ntcong