Page 1 of 1

Adding External Library

Posted: 31 Oct 2008 16:33
by Boo025
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?

Re: Adding External Library

Posted: 01 Nov 2008 16:39
by Jean-Baptiste Kempf
Messages?

Re: Adding External Library

Posted: 03 Nov 2008 15:14
by Boo025
Error message is just "undefined referenced to '<function>'" I've included the header for the API and the function is in the library.

Re: Adding External Library

Posted: 03 Nov 2008 15:31
by Jean-Baptiste Kempf
Usualy you have to modify configure.ac and Modules.am if you add a module.

Re: Adding External Library

Posted: 03 Nov 2008 16:15
by Boo025
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.

Re: Adding External Library

Posted: 03 Nov 2008 16:20
by Jean-Baptiste Kempf
It depends what module it is, but usually adding the good -l in configure.ac for the module is enough.

Re: Adding External Library

Posted: 03 Nov 2008 16:37
by Boo025
Can you tell me whereabouts of which line I should edit to add the -l ?
My code resides in 'access_output' module.

Re: Adding External Library

Posted: 04 Nov 2008 14:32
by xtophe
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

Re: Adding External Library

Posted: 19 Feb 2009 20:05
by wssoh85
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.

Re: Adding External Library

Posted: 19 Feb 2009 21:20
by Jean-Baptiste Kempf
why link to hotkeys.c ?

Re: Adding External Library

Posted: 20 Feb 2009 06:10
by wssoh85
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.

Re: Adding External Library

Posted: 20 Feb 2009 12:39
by xtophe
You're adding -lpjlib to the ldflags for the pjlib module

That's not the ldflags for the hotkey module

Re: Adding External Library

Posted: 20 Feb 2009 13:54
by wssoh85
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.

Re: Adding External Library

Posted: 07 Mar 2009 04:37
by wssoh85
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

Re: Adding External Library

Posted: 10 Mar 2009 08:05
by Jean-Baptiste Kempf
This is usually a -l flag missing.

Re: Adding External Library

Posted: 11 Mar 2009 02:34
by wssoh85
Thanks for your all help, i found out which -l flag missing already. thanks a lot.

Re: Adding External Library

Posted: 11 Mar 2009 10:55
by Jean-Baptiste Kempf
-ljp or similar?

Re: Adding External Library

Posted: 11 Mar 2009 18:27
by wssoh85

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.

Re: Adding External Library

Posted: 11 Mar 2009 23:10
by Jean-Baptiste Kempf
Use nm and objdump to find the missing symbols in the libraries.

Re: Adding External Library

Posted: 19 Mar 2009 17:48
by wssoh85
ALright, thanks a lot for your help :)