Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to debug #18

Closed
lion6230i opened this issue Nov 21, 2016 · 6 comments
Closed

how to debug #18

lion6230i opened this issue Nov 21, 2016 · 6 comments

Comments

@lion6230i
Copy link

Hi ,

I porting vlc library to mips platform and use vlc.py to test.
But have some error.

python vlc.py

Usage: vlc.py [options] <movie_filename>
Once launched, type ? for help.

Build date: Fri Oct 7 12:04:48 2016 (0x0)
Error: no function 'libvlc_get_version'

Could any one suggest me how to debug?
I have confirm libvlc.so have libvlc_get_version function.

@oaubert
Copy link
Owner

oaubert commented Nov 21, 2016

Hi

You should first try the basic loading of the vlc lib from a python
interpreter:

import ctypes
from ctypes.util import find_library
p = find_library('vlc')
dll = ctypes.CDLL(p)
dll.libvlc_get_version()

and see if it works.

Olivier

On Mon, 2016-11-21 at 01:25 -0800, lion6230i wrote:

Hi ,
I porting vlc library to mips platform and use vlc.py to test.
But have some error.
python vlc.py
Usage: vlc.py [options] <movie_filename>
Once launched, type ? for help.
Build date: Fri Oct 7 12:04:48 2016 (0x0)
Error: no function 'libvlc_get_version'
Could any one suggest me how to debug?
I have confirm libvlc.so have libvlc_get_version function.

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@lion6230i
Copy link
Author

Hi Olivier,
Thanks for your reply.
I try the command step by step ,

python

Python 2.7.6 (default, Nov 16 2016, 11:18:53)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import ctypes
from ctypes.util import find_library
p = find_library('vlc')
dll = ctypes.CDLL(p)
dll.libvlc_get_version()
Traceback (most recent call last):
File "", line 1, in
File "/media/python_nfs/lib/python2.7/ctypes/init.py", line 378, in getattr
func = self.getitem(name)
File "/media/python_nfs/lib/python2.7/ctypes/init.py", line 383, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: Unable to resolve symbol

Is it mean python can't find my libvlc.so ?
I have set LD_LIBRARY_PATH before I run python.

@oaubert
Copy link
Owner

oaubert commented Nov 21, 2016

python seems to find libvlc.so (else it would fail at the ctypes.CDLL
line). Maybe your symbol names are mangled in the lib ? You should
check with 
readelf -Ws /path/to/libvlc.so
or
objdump -TC /path/to/libvlc.so

If the symbol information is correct, then maybe it has to do with the
arch. You should then investigate ctypes on mips, by for instance
building a minimal lib with a unique symbol.

Olivier

On Mon, 2016-11-21 at 02:23 -0800, lion6230i wrote:

Hi Olivier,
Thanks for your reply.
I try the command step by step ,
python
Python 2.7.6 (default, Nov 16 2016, 11:18:53)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
import ctypes
from ctypes.util import find_library
p = find_library('vlc')
dll = ctypes.CDLL(p)
dll.libvlc_get_version()
Traceback (most recent call last):
File "", line 1, in 
File "/media/python_nfs/lib/python2.7/ctypes/init.py", line 378, in
getattr
func = self.getitem(name)
File "/media/python_nfs/lib/python2.7/ctypes/init.py", line 383, in
getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: Unable to resolve symbol
Is it mean python can't find my libvlc.so ?
I have set LD_LIBRARY_PATH before I run python.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@lion6230i
Copy link
Author

Hi Olivier,

I dump symbol information in library , it's correct.

[root@localhost lib]# objdump -TC libvlc.so|grep vlc_get_version
00005954 g DF .text 00000018 Base libvlc_get_version

Then I try the command in below:

python

Python 2.7.6 (default, Nov 16 2016, 11:18:53)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from ctypes import *
cdll.LoadLibrary("libc.so.0")
<CDLL 'libc.so.0', handle 43d838 at 2b396410>
libc = CDLL("libc.so.0")
libc.printf
<_FuncPtr object at 0x2b38b260>
libc.printf("lion debug")
lion debug10

Does it mean ctypes work fine on mips?

@oaubert
Copy link
Owner

oaubert commented Nov 22, 2016

So it seems ctypes is working on mips, and you have the correct symbol
in libvlc. Maybe the ctypes.util.find_library does not find the
appropriate library, could you check the output?

Olivier
On Mon, 2016-11-21 at 17:33 -0800, lion6230i wrote:

Hi Olivier,
I dump symbol information in library , it's correct.
[root@localhost lib]# objdump -TC libvlc.so|grep vlc_get_version
00005954 g DF .text 00000018 Base libvlc_get_version
Then I try the command in below:
python
Python 2.7.6 (default, Nov 16 2016, 11:18:53)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
from ctypes import *
cdll.LoadLibrary("libc.so.0")
<CDLL 'libc.so.0', handle 43d838 at 2b396410>
libc = CDLL("libc.so.0")
libc.printf
<_FuncPtr object at 0x2b38b260>
libc.printf("lion debug")
lion debug10
Does it mean ctypes work fine on mips?

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@lion6230i
Copy link
Author

Hi Olivier,

You are right. The problem case by find_library.
I modify vlc.py skip find_library step , load libvlc.so directly.
Then test it , it's works fine.

python vlc.py

lion debug 1
Usage: vlc.py [options] <movie_filename>
Once launched, type ? for help.

Build date: Fri Oct 7 12:04:48 2016 (0x0)
LibVLC version: 2.2.4 Weatherwax (0x2020400)
LibVLC compiler: gcc version 4.7.3 (Buildroot 2013.08-00907-ga7254e1)

I think , it's may cause by my platform do not have ldconfig.
Somebody said find_library will use ldconfig to look up where library can load.
Anyway thanks for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants