Click here to Skip to main content
14,772,885 members
Home » Discussions » Linux Programming
   

Linux Programming

 
AnswerRe: Linking to library Pin
Vaclav_3-Mar-19 8:15
MemberVaclav_3-Mar-19 8:15 
GeneralRe: Linking to library Pin
k50543-Mar-19 8:44
mvek50543-Mar-19 8:44 
GeneralRe: Linking to library Pin
Vaclav_3-Mar-19 9:12
MemberVaclav_3-Mar-19 9:12 
GeneralRe: Linking to library Pin
k50543-Mar-19 10:04
mvek50543-Mar-19 10:04 
GeneralRe: Linking to library Pin
Richard MacCutchan3-Mar-19 22:34
mveRichard MacCutchan3-Mar-19 22:34 
GeneralRe: Linking to library Pin
Vaclav_4-Mar-19 5:28
MemberVaclav_4-Mar-19 5:28 
GeneralRe: Linking to library Pin
Richard MacCutchan4-Mar-19 5:56
mveRichard MacCutchan4-Mar-19 5:56 
GeneralRe: Linking to library Pin
k50544-Mar-19 8:42
mvek50544-Mar-19 8:42 
Looks like you learn something new every day (unless you're careful Smile | :) ). I did not know about the -l:<filename> option for ld. In the past, when I needed to link to static (.a) libs I'd use gcc flags -Wl,-Bstatic -l<lib> -l<lib> ... -Wl,-Bdynamic. The -l:<lib> is nicer, I think. Note that if you omit the trailing -Wl,-Bdyanmic in my solution, then any static system libs (e.g. libc, libstdc++, etc) get linked statically, too, which may not be what you want.

I just tried this and can confirm it works, but you need to use the full filename i.e. -l:libxxxx.a e.g.
$ ls /usr/lib64/lib*.a
/usr/lib64/libc_nonshared.a  /usr/lib64/libldc-jit-rt.a  /usr/lib64/libmvec_nonshared.a
/usr/lib64/libg.a            /usr/lib64/libmcheck.a      /usr/lib64/libpthread_nonshared.a
$ g++ hello.cpp -l:mcheck.a -o hello
/usr/bin/ld: cannot find -l:mcheck.a
collect2: error: ld returned 1 exit status
$ g++ hello.cpp -l:libmcheck.a -o hello
$
. That means if your lib actually is $PATH_TO_LIBS/bluetooth.a then -l:bluetooth.a is correct.
GeneralRe: Linking to library Pin
Richard MacCutchan4-Mar-19 10:47
mveRichard MacCutchan4-Mar-19 10:47 
GeneralRe: Linking to library Pin
k50544-Mar-19 13:45
mvek50544-Mar-19 13:45 
GeneralRe: Linking to library Pin
Richard MacCutchan4-Mar-19 22:44
mveRichard MacCutchan4-Mar-19 22:44 
QuestionSOLVED system call syntax ? Pin
Vaclav_7-Feb-19 7:40
MemberVaclav_7-Feb-19 7:40 
AnswerRe: system call syntax ? Pin
k50547-Feb-19 9:02
mvek50547-Feb-19 9:02 
GeneralRe: system call syntax ? Pin
Vaclav_7-Feb-19 11:23
MemberVaclav_7-Feb-19 11:23 
GeneralRe: system call syntax ? Pin
k50547-Feb-19 12:20
mvek50547-Feb-19 12:20 
AnswerRe: system call syntax ? Pin
Richard MacCutchan7-Feb-19 23:26
mveRichard MacCutchan7-Feb-19 23:26 
GeneralRe: system call syntax ? Pin
Vaclav_8-Feb-19 4:23
MemberVaclav_8-Feb-19 4:23 
GeneralRe: system call syntax ? Pin
Richard MacCutchan8-Feb-19 5:56
mveRichard MacCutchan8-Feb-19 5:56 
GeneralRe: system call syntax ? Pin
k50548-Feb-19 6:23
mvek50548-Feb-19 6:23 
GeneralRe: system call syntax ? Pin
Richard MacCutchan8-Feb-19 6:53
mveRichard MacCutchan8-Feb-19 6:53 
GeneralRe: system call syntax ? Pin
Vaclav_8-Feb-19 10:42
MemberVaclav_8-Feb-19 10:42 
GeneralRe: system call syntax ? Pin
k50548-Feb-19 11:03
mvek50548-Feb-19 11:03 
GeneralRe: system call syntax ? Pin
Vaclav_8-Feb-19 15:37
MemberVaclav_8-Feb-19 15:37 
GeneralRe: system call syntax ? Pin
Richard MacCutchan8-Feb-19 23:27
mveRichard MacCutchan8-Feb-19 23:27 
Questionfrom "ls" to C++ buffer? Pin
Vaclav_15-Jan-19 5:03
MemberVaclav_15-Jan-19 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.