Reputation: 4599
I'm trying to build a app which is linked against a bunch of static and shared libraries. Which is done by following command :
arif@khost:~/sak/pjsip$ gcc -v -o /home/arif/pjsip-samples/sample_apps/playfile.out pjsip-apps/src/samples/playfile.o `pkg-config --libs libpjproject`
Where pkg-config --libs libpjproject
spits out :
arif@khost:~/sak/pjsip$ pkg-config --libs libpjproject
-pthread -L/opt/pjsip/lib -L/opt/ffmpeg/lib -lpjmedia-videodev-x86_64-unknown-linux-gnu -lpjmedia-audiodev-x86_64-unknown-linux-gnu -lpjmedia-x86_64-unknown-linux-gnu
............(other libraries are omitted)
The relevant libraries are
[1]pjmedia-audiodev
[2]`pjmedia
The linking error which is reported here :
/opt/pjsip/lib/libpjmedia-x86_64-unknown-linux-gnu.a(endpoint.o): In function `pjmedia_endpt_create':
endpoint.c:(.text+0x14f): undefined reference to `pjmedia_aud_subsys_init'
endpoint.c:(.text+0x1b0): undefined reference to `pjmedia_aud_subsys_shutdown'(etc)
Now it should not be the case because :
arif@khost:~/sak/pjsip$ nm /opt/pjsip/lib/libpjmedia-x86_64-unknown-linux-gnu.a | grep pjmedia_aud_subsys
U pjmedia_aud_subsys_init
U pjmedia_aud_subsys_shutdown
U pjmedia_aud_subsys_get_pool_factory
U pjmedia_aud_subsys_init
U pjmedia_aud_subsys_shutdown
`
I'm aware of the fact that linking order is very important for shared libraries, I thought it should not be the case because we are copying the object file anyway.
Am i missing something?
UPDATE 1
My bad, The symbol is not in pjmedia but in pjmedia-auddev :
arif@khost:/opt/pjsip/lib$ nm -C libpjmedia-audiodev-x86_64-unknown-linux-gnu.a | grep pjmedia_aud_subsys_init
0000000000000720 T pjmedia_aud_subsys_init
So there is clearly linking order problem here. Because libpjmedia
using libpjmedia-auddev
but in command line its given in wrong order.
The problem is solved if i take libpjmedia
before libpjmedia-auddev
.
Upvotes: 1
Views: 1007
Reputation: 1
You need -lpjmedia-x86_64-unknown-linux-gnu before -lpjmedia-videodev-x86_64-unknown-linux-gnu inclusion.
Upvotes: 0
Reputation: 3701
U pjmedia_aud_subsys_init
U
in this output means that the symbol is undefined. When it's defined in this library, this column of output should have t
or T
, and address of the symbol is output on the left.
You should find the library which actually defines these symbols and add it to command line.
Upvotes: 2