Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How do I include easily new libraries(Explain how GCC C++ Compiler and GCC C++ Linker work)
How do I include easily new libraries [message #721321] Thu, 01 September 2011 13:17 Go to next message
demetrio  is currently offline demetrio Friend
Messages: 2
Registered: September 2011
Junior Member

In Eclipse Indigo, I surf to Properties>>C/C++ Build>>Settings>>GCC C++ Linker >> Miscellaneous >> Other Options (-Xlinker [option]), and I typed -lcurl? I am new in C++ and I have used Eclipse only for Java until one month ago. I spent long hours to start using Boost and now I spent more time to start using Curl. And soon I will need to use log4cpp and some more libraries. I was just trying to do a simple example. Now I am able to include both libraries but I have no idea what I have done. I just followed some suggestions but it took me long hours trying other suggestions before, even from official site.
It would be nice if I understood how to add some libraries without lost hours. About Boost, I did a very different way. I surfed Properties>>C/C++ Build>>Settings>>GCC C++ Compiler >> Includes and I wrote /usr/local/boost_1_47_0/ and, later, /usr/local/curl-7.21.7/. I noted that, after this, I could hold control key and clicked on variable type that Eclipse would be guide to proper file.h from boost or curl. But I only get the build code after I surfed Properties>>C/C++ Build>>Settings>>GCC C++ Linker >> Libraries and I wrote on Libraries (-l) boost_system and boost_filesystem and, on Library Search Path (-L) I wrote /usr/local/boost_1_47_0/libs. Why I put -lcurl on Miscellaneous but, about boost, I put boost_system and boost_filesystem on Libraries? I tried follow similar way to curl as I did for boost, but it doens't work.

Thanks in advance,
Demetrio
Re: How do I include easily new libraries [message #721572 is a reply to message #721321] Fri, 02 September 2011 06:57 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Here are steps to add an external library
http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_add_an_external_library_to_my_C.2B.2B_project.3F

1) in Properties>>C/C++ Build>>Settings>>GCC C++ Compiler >> Includes you must add the include path for the external library (where the header reside). This information is needed by the Eclipse indexer (code completion etc.) and the compiler

2) Properties>>C/C++ Build>>Settings>>GCC C++ Linker >> Libraries you must add the library search path (option -L) and the library you want to link against (option -l). This info is needed for the linker.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: How do I include easily new libraries [message #734255 is a reply to message #721572] Fri, 07 October 2011 09:13 Go to previous messageGo to next message
shaz  is currently offline shaz Friend
Messages: 10
Registered: September 2011
Junior Member
I tired these methods but the compiler says that the library (*.a) cannot be found in the said location. Although it actually exists.
Re: How do I include easily new libraries [message #734862 is a reply to message #734255] Mon, 10 October 2011 08:32 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
shaz wrote on Fri, 07 October 2011 11:13
I tired these methods but the compiler says that the library (*.a) cannot be found in the said location. Although it actually exists.

When your library is named libmylib.a you must enter "mylib" in the project properties. The linker will add the rest.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: How do I include easily new libraries [message #990999 is a reply to message #734862] Sun, 16 December 2012 18:17 Go to previous message
Margus Pärt is currently offline Margus PärtFriend
Messages: 2
Registered: December 2012
Junior Member
I was able to get it working by:

1. brew install mylibrary (headers went under /usr/local/include)
2. In Makefile "LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -lmylibary -o $@"


In step two, where would the correct place be to define used libary?
Previous Topic:Debugging complex application startup.
Next Topic:Code Templates not working
Goto Forum:
  


Current Time: Thu Mar 28 12:00:45 GMT 2024

Powered by FUDForum. Page generated in 0.05779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top