Linker errors with i686-w64-mingw32 on Ubuntu 12.04

This forum is about all development around libVLC.
lscn
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Aug 2012 18:09

Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby lscn » 05 Aug 2012 18:27

Hi all and thanks in advance for your help! :-)

After one weekend of browsing through all the docs I could, I surrender... I have tried to cross compile an example plugin with VLC source code from current HEAD, revision 1.1.7 and 2.0.3. Either didn't succeed or the generated plugin didn't load.

The current HEAD generates plugins with an entry point which I think isn't yet valid for VLC 2.0.3 (current version for Windows), so I've discard this.

I then checked out from GIT version 1.1.7, but never was able to configure the stuff for compilation. With 2.0.3 I was able to generate libvlccore, but can't link the sample plugin, with the error below:

Code: Select all

lscn@lscn-VirtualBox:~/Desktop/vlc-2.0/win32/win32_$ i686-w64-mingw32-gcc -std=gnu99 `pkg-config --cflags --libs hello` -o libhello_plugin.dll hello.c In file included from hello.c:15:0: /home/lscn/Desktop/vlc-2.0/include/vlc_common.h:405:0: warning: "stat" redefined [enabled by default] /usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include/sys/stat.h:255:0: note: this is the location of the previous definition /home/lscn/Desktop/vlc-2.0/include/vlc_common.h:406:0: warning: "fstat" redefined [enabled by default] /usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include/sys/stat.h:256:0: note: this is the location of the previous definition /tmp/cc77N1wO.o:hello.c:(.text+0x75): undefined reference to `_var_Inherit' /tmp/cc77N1wO.o:hello.c:(.text+0x386): undefined reference to `_vlc_Log' /tmp/cc77N1wO.o:hello.c:(.text+0x3cb): undefined reference to `_vlc_Log' /tmp/cc77N1wO.o:hello.c:(.text+0x40a): undefined reference to `_vlc_Log' collect2: ld returned 1 exit status
Below is the sample code from hello.c (copied from one of the wiki pages and with slight changes):

Code: Select all

/** * @file hello.c * @brief Hello world interface VLC module example */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #define DOMAIN "vlc-myplugin" #define _(str) dgettext(DOMAIN, str) #define N_(str) (str) #include <stdlib.h> /* VLC core API headers */ #include <vlc_common.h> #include <vlc_plugin.h> #include <vlc_interface.h> #define MODULE_STRING "hello" /* Forward declarations */ static int Open(vlc_object_t *); static void Close(vlc_object_t *); /* Module descriptor */ vlc_module_begin() set_shortname(N_("Hello")) set_description(N_("Hello interface")) set_capability("interface", 0) set_callbacks(Open, Close) set_category(CAT_INTERFACE) add_string("hello-who", "world", "Target", "Whom to say hello to.", false) vlc_module_end () /* Internal state for an instance of the module */ struct intf_sys_t { char *who; }; /** * Starts our example interface. */ static int Open(vlc_object_t *obj) { intf_thread_t *intf = (intf_thread_t *)obj; /* Allocate internal state */ intf_sys_t *sys = (intf_sys_t *) malloc(sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; intf->p_sys = sys; /* Read settings */ char *who = var_InheritString(intf, "hello-who"); if (who == NULL) { msg_Err(intf, "Nobody to say hello to!"); goto error; } sys->who = who; msg_Info(intf, "Hello %s!", who); return VLC_SUCCESS; error: free(sys); return VLC_EGENERIC; } /** * Stops the interface. */ static void Close(vlc_object_t *obj) { intf_thread_t *intf = (intf_thread_t *)obj; intf_sys_t *sys = intf->p_sys; msg_Info(intf, "Good bye %s!"); /* Free internal state */ free(sys->who); free(sys); } int main() { }
And here is the config used (a bit of mess in terms of dir structure, I'm sorry):

Code: Select all

prefix=/home/lscn/Desktop/vlc-2.0/contrib/win32/win32_ exec_prefix=/home/lscn/Desktop/vlc-2.0 includedir=${exec_prefix}/include datarootdir=${exec_prefix}/share libdir=${exec_prefix}/win32/src/.libs datadir=${datarootdir} pkgincludedir=${exec_prefix}/include/vlc pkgdatadir=${datadir}/vlc pkglibdir=${libdir}/vlc pluginsdir=${pkglibdir}/plugins Name: Hello Description: VLC media player plugin hello world Version: 2.0.3 Cflags: -I${includedir} \ -D__PLUGIN__ \ -D_FILE_OFFSET_BITS=64 \ \ -D_REENTRANT \ -D_THREAD_SAFE Libs: -L${libdir} -lvlccore
Can somebody point me in the right direction here?

Btw, I'm using the compiler as suggested in another thread:
wget http://ftp.jp.debian.org/debian/pool/ma ... -1_all.deb
sudo dpkg -i mingw-w64-dev_3.0~svn4933-1_all.deb
sudo apt-get install gcc-mingw-w64 g++-mingw-w64
Thanks a lot!
lscn

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby Rémi Denis-Courmont » 05 Aug 2012 19:24

You're not following the instructions http://wiki.videolan.org/OutOfTreeCompile . Why do you expect it to work?
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

lscn
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Aug 2012 18:09

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby lscn » 06 Aug 2012 20:37

Dear Rémi,

Thank you so much for your fast reply and help (I noticed from other posts, you really put you really put a lot of effort into this).

I read the link you posted several times, but it isn't clear to me how to work in a cross-compile situation (I'm sorry, but I'm not really comfortable with Linux development). My questions:

1 - To cross compile in Ubuntu 12.04 for Windows, should I use the files within the vlc-*-win*.zip file, inside the sdk/ directory or install the mentioned package in Ubuntu? Maybe a stupid question, but...

2 - In terms of building, there's a mention of "If cross-compiling, you will probably need to adjust the pkg-config environment variables", but I couldn't really find a direct example of how to do this and this is why I ended up probably complicating stuff... I'm targeting the use of i686-w64-mingw32. Can you please explain how to adapt for this?

Again, thanks a lot!
lscn

lscn
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Aug 2012 18:09

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby lscn » 14 Aug 2012 12:40

Hi Rémi!

How are you doing?

Well, I decided to have another go at this and just follow the instructions as above, using the Windows binaries.

I still have the following error:

/tmp/cc77N1wO.o:hello.c:(.text+0x386): undefined reference to `_vlc_Log'

Can you please help me out?

Thanks,
lscn

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby Rémi Denis-Courmont » 14 Aug 2012 17:15

You're not linking the plugin against the libvlc core run-time.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

lscn
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Aug 2012 18:09

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby lscn » 14 Aug 2012 22:03

Hi Rémi! :-)

Thanks for coming back to me so fast...
You're not linking the plugin against the libvlc core run-time.
I would say I'm doing so, although indeed the symbols can't be found... on the safe side I tried to compile & link like below:

Code: Select all

$ gcc -Wall -std=gnu99 -I/home/lscn/include/vlc/plugins -D__PLUGIN__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -L/home/lscn/lib -lvlccore -o mymodule demuxdump.c
As you can see I'm linking to libvlccore... What is missing?

Again, thank you for the help... and the patience! ;-)

Cheers!
lscn

lscn
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Aug 2012 18:09

Re: Linker errors with i686-w64-mingw32 on Ubuntu 12.04

Postby lscn » 14 Aug 2012 22:07

Hey! :-)

Never mind!! Just noticed the order was wrong... :-$

Thanks for your help!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 2 guests