Adding External Library

*nix specific usage questions
Boo025
Blank Cone
Blank Cone
Posts: 26
Joined: 24 Sep 2008 16:54

Adding External Library

Postby Boo025 » 31 Oct 2008 16:33

I have a external library file that I want to link with one of the module in the VLC. How do I go about doing this?

I've tried modifying the Makefile directly (although I shouldn't) and tried adding the -l parameter, but it seems to just ignore the parameter. Which file should I edit?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 01 Nov 2008 16:39

Messages?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Boo025
Blank Cone
Blank Cone
Posts: 26
Joined: 24 Sep 2008 16:54

Re: Adding External Library

Postby Boo025 » 03 Nov 2008 15:14

Error message is just "undefined referenced to '<function>'" I've included the header for the API and the function is in the library.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 03 Nov 2008 15:31

Usualy you have to modify configure.ac and Modules.am if you add a module.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Boo025
Blank Cone
Blank Cone
Posts: 26
Joined: 24 Sep 2008 16:54

Re: Adding External Library

Postby Boo025 » 03 Nov 2008 16:15

I've changed the Module.ac to include the codes I've added, as for the Configure.ac I didn't make any changes since my code reside in one of the already existing module folder.

Usually, in g++/gcc I think you can use the -l to link library (such as to include anything that's in lib*.a). However, I'm not sure where I need to make to change in Configure.ac to do this.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 03 Nov 2008 16:20

It depends what module it is, but usually adding the good -l in configure.ac for the module is enough.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Boo025
Blank Cone
Blank Cone
Posts: 26
Joined: 24 Sep 2008 16:54

Re: Adding External Library

Postby Boo025 » 03 Nov 2008 16:37

Can you tell me whereabouts of which line I should edit to add the -l ?
My code resides in 'access_output' module.

xtophe
Big Cone-huna
Big Cone-huna
Posts: 1209
Joined: 24 Nov 2003 10:12
Location: Bristol, England

Re: Adding External Library

Postby xtophe » 04 Nov 2008 14:32

Have you read HACKING?

In configure.ac, just look at another libraries as example.
I would suggest looking at libnotify if your library use pkg-config
or at the mpc demux if it deosn't
Xtophe

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 19 Feb 2009 20:05

Hi, i have the same problem in adding new library to vlc.

My library is name PJlib and I try many method to link it with hotkeys.c file. however it wont works. Here is what I do:

I make install the PJlib and its library, "libpjlib-util-i686-pc-linux-gnu.a" is in the folder /usr/local/include. According to the HACKING file and the suggestion above, I add the lib follow the way of mpc demux library being add in the configure.ac file. The code show below:

Code: Select all

dnl dnl mpc demux plugin dnl AC_ARG_ENABLE(mpc, [ --enable-mpc Mpc demux support (default enabled)]) if test "${enable_mpc}" != "no" then AC_CHECK_HEADERS(mpcdec/mpcdec.h, [ VLC_ADD_PLUGINS([mpc]) VLC_ADD_LDFLAGS([mpc],[-lmpcdec])]) fi dnl dnl pjlib plugin dnl AC_ARG_ENABLE(pjlib, [ --enable-pjlib pjlib support (default enabled)]) if test "${enable_pjlib}" != "no" then AC_CHECK_HEADERS(pjlib.h, [ VLC_ADD_PLUGINS([pjlib]) VLC_ADD_LDFLAGS([pjlib],[-lpjlib])]) fi
is any wrong in my code to link the library to the file hotkeys.c in vlc/module/control/ folder? I wanna know the way to link library to hotkeys.c file?

Thanks. I googling around and found no information about that and hope you all can help.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 19 Feb 2009 21:20

why link to hotkeys.c ?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 20 Feb 2009 06:10

It is because I want to have use the function that when I press an hotkey, then it will send a sip instant message to other sip user. So I plan to link the sip library to hotkey.c. Is any method can link both together? I'm using ubuntu 7.10 and VLC-0.8.6f.

xtophe
Big Cone-huna
Big Cone-huna
Posts: 1209
Joined: 24 Nov 2003 10:12
Location: Bristol, England

Re: Adding External Library

Postby xtophe » 20 Feb 2009 12:39

You're adding -lpjlib to the ldflags for the pjlib module

That's not the ldflags for the hotkey module
Xtophe

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 20 Feb 2009 13:54

Thanks for your help, Xtopher.

But I'm not very good in dealing with Makefile. Can anyone give me example on how to link hotkeys module to the Pjlib? briefly give me a guide pls?
I do that because I found that the liblirc.a are also in /usr/lib which have similar manner as my library, so i just follow what it do only.

can i write my code as:
AC_CHECK_HEADERS(pjlib.h, [
VLC_ADD_PLUGINS([pjlib])
VLC_ADD_LDFLAGS([hotkeys],[-lpjlib])])

???
or i should modified Makefile.am also instead of configure.ac
Hope to heard from you all soon.

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 07 Mar 2009 04:37

Hi, thanks for all the advice previously. Currently I think the library i need was linked. The pjlib is pkg-config and has been sudo make install to /usr/local.
I link add in the following code in the configure.ac file.

Code: Select all

dnl dnl pj plugin dnl AC_ARG_ENABLE(PJ, [ --enable-pj pj support (default enabled)]) if test "${enable_pj}" != "no" then PKG_CHECK_MODULES(PJ,libpj, [ AC_CHECK_HEADERS(pjlib-util.h, [], [AC_MSG_ERROR([Missing header file pjlib-util.h.])] ) AC_CHECK_HEADERS(pjlib.h, [], [AC_MSG_ERROR([Missing header file pjlib.h.])] ) AC_CHECK_HEADERS(pjsua-lib/pjsua.h, [], [AC_MSG_ERROR([Missing header file pjsua-lib/pjsua.h.])] ) VLC_ADD_PLUGINS([pj]) VLC_ADD_LDFLAGS([hotkeys pj],[$PJ_LIBS] -lpjnath -lssl -lilbccodec-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu) VLC_ADD_CFLAGS([hotkeys pj],[$PJ_CFLAGS])]) fi
and then I run ./bootstrap && ./configure && make.

The "-lpjnath -lssl -lilbccodec-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu" are 3rd party library that required by Pjlib.

There is no problem until make. However, the problem exist when run the ./vlc -vvv.

Code: Select all

VLC media player 0.8.6f Janus [00000001] main private debug: checking builtin modules [00000001] main private debug: checking plugin modules [00000001] main private debug: loading plugins cache file /home/ims/.vlc/cache/plugins-04041e.dat [00000001] main private debug: recursively browsing `modules' [00000001] main private warning: cannot load module `modules/control/libhotkeys_plugin.so' (modules/control/libhotkeys_plugin.so: undefined symbol: pj_hmac_sha1_init) [00000001] main private debug: recursively browsing `/usr/local/lib/vlc' [00000001] main private debug: recursively browsing `plugins' [00000001] main private debug: module bank initialized, found 216 modules [00000001] main private debug: opening config file /home/ims/.vlc/vlcrc
The pj_hmac_sha1_init() function is defined in a header file name "hmac_sha1.h " and I had add the code "#include <pjlib-util/hmac_sha1.h>" in the source code of hotkeys. Can anyone please give me some help??

Sincerely I need helps from you all because I not really understand how is VLC link its library

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 10 Mar 2009 08:05

This is usually a -l flag missing.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 11 Mar 2009 02:34

Thanks for your all help, i found out which -l flag missing already. thanks a lot.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 11 Mar 2009 10:55

-ljp or similar?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 11 Mar 2009 18:27

Code: Select all

dnl dnl pjsua plugin dnl AC_ARG_ENABLE(hotkeys, [ --enable-hotkeys pj-hotkey support (default enabled)]) if test "${enable_hotkeys}" != "no" then PKG_CHECK_MODULES(PJ,libpj, [ AC_CHECK_HEADERS(pjlib-util.h, [], [AC_MSG_ERROR([Missing header file pjlib-util.h.])] ) AC_CHECK_HEADERS(pjlib.h, [], [AC_MSG_ERROR([Missing header file pjlib.h.])] ) AC_CHECK_HEADERS(pjsua-lib/pjsua.h, [], [AC_MSG_ERROR([Missing header file pjsua-lib/pjsua.h.])] ) VLC_ADD_PLUGINS([hotkeys pj]) VLC_ADD_LDFLAGS([hotkeys pj],[$PJ_LIBS -lpjnath -lpjlib-util -lssl -lilbccodec-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu -lm -lasound]) VLC_ADD_CFLAGS([hotkeys],[$PJ_CFLAGS])]) fi
This is the code I add in configure.ac file. Since the whole PJ library is in PKG-config package, so I follow similar to what libnotify do. "-lilbccodec-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu" library are come together with the PJproject package.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Adding External Library

Postby Jean-Baptiste Kempf » 11 Mar 2009 23:10

Use nm and objdump to find the missing symbols in the libraries.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

wssoh85
Blank Cone
Blank Cone
Posts: 20
Joined: 20 Dec 2008 10:52

Re: Adding External Library

Postby wssoh85 » 19 Mar 2009 17:48

ALright, thanks a lot for your help :)


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 15 guests