Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My goal is to have one place to edit common class.
I have build standard Linux x.a library and it compiles.
The "problem" - the common class uses another library and the original "project"
was linked to such library.
I have included the required headers, now I need help to figure out how to link the additional library.

Using "standard" GCC to build x.a library project and I do not see a simple option(s) to simply link (except -l / -L) to another library.

What I have tried:

Headers are OK, but
I have not found any references on how to link libraries.

I have added gcc -lbluetooth .
The library complied, but still failed - cannot find references - when run from the "mother" project.
Posted
Updated 26-Jan-20 22:46pm
v3

Simply pass the filename (without -l) of the required library to gcc.
 
Share this answer
 
 
Share this answer
 
Comments
Vaclav_ 27-Jan-20 9:42am    
Thanks.
I am not sure how this "forum" works, but I like to ask follow-up questions Since I am not sure how the "mother" project actually links to "bluetooth" library - for this to work - does GCC wants full file name libbluetooth.a?
Do I have to supply path to the whatever file name is correct ( full or "castrated" )? It is falling now ( g++: error: libbluetooth.a: No such file or directory) and I am just fumbling around trying different ways.
I have implemented bluetooth library long time ago and I am sure it has "system " path - no (-L).
Richard MacCutchan 27-Jan-20 9:52am    
I answered your previous question about linking in Linux/UNIX back in April last year: Re: How to "include / link " to libbluetooth-dev (package?) ? - Linux Programming Discussion Boards[^].

When building a final executable object the linker needs to know where to find any libraries that are not part of the standard set. So you need to specify the name of the library in one of two ways with either -l or -L as described in the document at the link I provided in the above solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900