Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Adding C static library to my project(How to add an external static library to my C project and use its functions)
Adding C static library to my project [message #1769764] Thu, 03 August 2017 09:04 Go to next message
Mahmoud Mahdi is currently offline Mahmoud MahdiFriend
Messages: 6
Registered: August 2017
Junior Member
I've been working on a project for embedded system and it needs SSL/TLS functionality.

I downloaded SSL project from GitHub (WolfSSL to be specific), compiled it with autotools, then created a static library libwolfssl.a using ar from libtools which archived all the .o files

I need to use the functions implemented in WolfSSL in my code, for example SSL_Library_Init()

How can I add the static library and use the functions using Eclipse IDE ?

I tried the following:

Added library path to the C linker -L: ${workspace_loc:/${ProjName}/lib}
Added library name to -l : wolfssl where the library name is libwolfssl.a
When I try to build the project, anything related to SSL is not recognized yet, ex: SSL_Library_Init and so on
Is this the correct way to do this?
Re: Adding C static library to my project [message #1769822 is a reply to message #1769764] Thu, 03 August 2017 17:01 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 397
Registered: June 2014
Senior Member
You have done this correctly, based on the information you provided.

Please include the command line and error message from the Console so that we can have a better understanding of what "not recognized" means in this context.
Re: Adding C static library to my project [message #1769825 is a reply to message #1769764] Thu, 03 August 2017 18:01 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 357
Registered: August 2014
Senior Member
If you did not specify it separately, Autotools will compile object files for the computer the translation is done on. It may need special handling to cross-compile the library for your embedded system.


--

Tauno Voipio
Re: Adding C static library to my project [message #1769844 is a reply to message #1769764] Fri, 04 August 2017 06:32 Go to previous messageGo to next message
Mahmoud Mahdi is currently offline Mahmoud MahdiFriend
Messages: 6
Registered: August 2017
Junior Member
index.php/fa/30272/0/
I collected all the object files that "make" command generate as per the above image attached
index.php/fa/30269/0/
I executed the comman "ar" to create a static library out of those files and I called it libwolfsll.a
index.php/fa/30271/0/
The above images shows how I added this library to Eclipse
index.php/fa/30270/0/
The SSL functions I need to call are in the file shown in this image, I tried to #include it in the fine tls_funcs.c that needs to call them but I am getting many errors that they are not declared as if the library is not there at all.

Am I doing it correctly?
  • Attachment: arcmd.PNG
    (Size: 1.09KB, Downloaded 153 times)
  • Attachment: sslfuncs.png
    (Size: 91.99KB, Downloaded 155 times)
  • Attachment: libs.PNG
    (Size: 3.47KB, Downloaded 154 times)
  • Attachment: ofiles.PNG
    (Size: 41.87KB, Downloaded 167 times)
Re: Adding C static library to my project [message #1769845 is a reply to message #1769764] Fri, 04 August 2017 06:33 Go to previous messageGo to next message
Mahmoud Mahdi is currently offline Mahmoud MahdiFriend
Messages: 6
Registered: August 2017
Junior Member
Duplicate**

[Updated on: Fri, 04 August 2017 06:36]

Report message to a moderator

Re: Adding C static library to my project [message #1769876 is a reply to message #1769845] Fri, 04 August 2017 12:01 Go to previous messageGo to next message
David Vavra is currently offline David VavraFriend
Messages: 627
Registered: October 2012
Senior Member
The first error is saying there is no definition for SSL3_RANDOM_SIZE.
The second and third are saying that what ssl is pointing toward is declared only as a forward declaration such as "struct ssl_;" .
I would think that the build had stopped before reaching the link stage so your questions about linking the library appear premature.
You should fix the depicted problems first.

Your post suggests a misunderstanding of what is going on.
The -L,-l are options telling the linker where to find the compiled functions which have been collected into an archive.
The compiler is interested only in the interface to those functions.
These are usually specified in an included header (.h) file.

[Updated on: Fri, 04 August 2017 12:20]

Report message to a moderator

Re: Adding C static library to my project [message #1769877 is a reply to message #1769876] Fri, 04 August 2017 12:15 Go to previous messageGo to next message
Mahmoud Mahdi is currently offline Mahmoud MahdiFriend
Messages: 6
Registered: August 2017
Junior Member
Yes the build has stopped before linking.
These definitions are implemented in the library I am trying to link to.
ex: SSL_RANDOM_SIZE and so on
They are within the build library
I need to call them explicitly and be able to recognize them.
Re: Adding C static library to my project [message #1769879 is a reply to message #1769877] Fri, 04 August 2017 12:23 Go to previous message
David Vavra is currently offline David VavraFriend
Messages: 627
Registered: October 2012
Senior Member
I edited my post to say:

Quote:
Your post suggests a misunderstanding of what is going on.
The -L,-l are options telling the linker where to find the compiled functions which have been collected into an archive.
The compiler is interested only in the interface to those functions.
These are usually specified in an included header (.h) file.


The header file you used appears incomplete.

Previous Topic:Adding external static library to C project
Next Topic:"Run Configuration " dialogue blues
Goto Forum:
  


Current Time: Thu Dec 14 13:28:11 GMT 2017

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

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