Menu

Using MediaInfo in QtCreator

Help
Jech
2016-09-01
2016-09-15
  • Jech

    Jech - 2016-09-01

    Hi,

    I would like to use MediaInfo in my application. I have used it in my older Python program (I contributed the first Python wrapper version which was written by a friend of mine). Now I have learned some C++ basics and I would like to use the library.

    I work on a player written using QtCreator in QML/C++ which currently uses TagLib. But I would like to use MediaInfo too. So this is what I did:
    1) I downloaded the MediaInfo source, opened the Qt project a compiled the library. I got a static .a library.
    2) I downloaded the win32 release and put the .h file to ../mediainfo/include, the .dll to ../mediainfo/bin and finally put the .a and .dll to ../mediainfo/lib
    3) I added the library to my project using the wizard in QtCreator
    4) I added the line #include <MediaInfoDLL.h> to my header file

    Up to here everything went fine. But as soon as I trid to initialize the library using MediaInfo MI; I got this error:

    C:\QtProjects\Muzika\3rdparty\mediainfo\include\MediaInfoDLL.h:342: Error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
             MediaInfo_Module = LoadLibrary(MEDIAINFODLL_NAME);
                                                             ^
    

    I understand it has something to do with Unicode support. But from the error I understood it is complaining about the MEDIAINFODLL_NAME type which is defined within the header. Since I don't have much C++ experience I'm not able to figure what is worng and how should I fix it.

    I also don't know if the steps I did were correct or not. Could you help me, please?

    I should also mention that my primary development platform is Windows but I also use Linux. The target platforms are Windows, desktop Linux and Android. I read it should be possible to compile the library for Android too.

     
  • Jerome Martinez

    Jerome Martinez - 2016-09-02

    1) I downloaded the MediaInfo source, opened the Qt project a compiled the library. I got a static .a library.

    the static version is not usable with MediaInfoDLL/MediaInfoDLL.h, prefer MediaInfoDLL/MediaInfo.h or compile an .so (I don't know with tht Qt project, I use automake for it).

    But as soon as I trid to initialize the library using MediaInfo MI; I got this error:

    Very weird, as it looks like _UNICODE definition is not set but Windows API is in Unicode. I need to find a way for detecting Unicode API better.

    In the meanwhile, I think that adding :
    #define _UNICODE
    before your #include should fix the issue.

    I read it should be possible to compile the library for Android too.

    I heard that some people already did that, but this is currently not officially supported (there are plans for that in the future but is not a priority right now).

     
  • Jech

    Jech - 2016-09-02

    Thanks a lot regarding the solution with adding #define _UNICODE. That solved the issue.

    I had some further issues with converting from/to QString but I was able to sort these problems and now everything works.

    The next challenge will be the Android version. I already did it successfully with the TagLib library but it was a lot of work. Furthermore I have no experience with automake.

    I was able to compile the statical library for Android using QtCreator. But I don't know how to switch it to compile a shared (.so) library. Furthermore as Android doesn't support library versions it can't have any. Do you have any idea how to do that? Or should I better ask at Qt forum?

     
    • Jerome Martinez

      Jerome Martinez - 2016-09-05

      We have very little experience in Qt and no experience in Android, so you are on you own.
      But if you do the work, we are interested in an "how to" and/or code! (could be also sponsored)

       
  • Jech

    Jech - 2016-09-13

    I found two projects with MediaInfo Android port. The first one is here and the second here. The second project even has already compiled Android library so I just used it.

    Now during execution and library loading I get this error:
    E/linker ( 3296): "libmediainfo.so": ignoring 2-entry DT_PREINIT_ARRAY in shared library!

    But I think the problem why it doesn't work is even somewhere else. I was always getting the answer "Unable to load libmediainfo.so" whenever I called the library. I ended with my debugging in these lines:

    #define MEDIAINFO_ASSIGN(_Name,_Name2) \
        MediaInfo_##_Name=(MEDIAINFO_##_Name)dlsym(MediaInfo_Module, "MediaInfo" MEDIAINFO_Ansi "_" _Name2); \
        if (MediaInfo_##_Name==NULL) Errors++;
    

    Unfortunately because of my limitted C/C++ knowledge I don't understand what these lines do. Anyway the result is that the Errors couter is incremented (it ends on 28). Do you have any idea what could be the problem?

     
    • Jerome Martinez

      Jerome Martinez - 2016-09-13

      the dlsym() just says that it does not find the mediainfo library (=the .so is not in the library paths).
      You are on your own here.

       
  • Jech

    Jech - 2016-09-15

    The library is found. So far it is working. But the association of functions fails. And it is apparently because the fucntions like (New, Open, Inform etc.) are simply not there. This is what I got using objdump:

    DYNAMIC SYMBOL TABLE:
    00000000      DF *UND*  00000000 __libc_init
    00000000      DF *UND*  00000000 __cxa_atexit
    00000000      DF *UND*  00000000 strcmp
    00000000      DF *UND*  00000000 __errno
    00000000      DF *UND*  00000000 lstat
    00000000      DF *UND*  00000000 __stack_chk_fail
    00000000      DO *UND*  00000000 __stack_chk_guard
    00000000      DF *UND*  00000000 stat
    00000000      DF *UND*  00000000 realloc
    00000000      DF *UND*  00000000 malloc
    00000000      DF *UND*  00000000 free
    00000000      DF *UND*  00000000 strcpy
    00000000      DF *UND*  00000000 opendir
    00000000      DF *UND*  00000000 mbrtowc
    00000000      DF *UND*  00000000 closedir
    00000000      DF *UND*  00000000 readdir
    00000000      DF *UND*  00000000 issetugid
    00000000      DF *UND*  00000000 getlogin
    00000000      DF *UND*  00000000 getenv
    00000000      DF *UND*  00000000 getpwnam
    00000000      DF *UND*  00000000 getuid
    00000000      DF *UND*  00000000 getpwuid
    00000000      DF *UND*  00000000 qsort
    001deba9 g    DF .text  00000068 operator new(unsigned int)
    00000000      DF *UND*  00000000 pthread_mutex_init
    00000000      DF *UND*  00000000 pthread_mutex_destroy
    001deffd g    DF .text  00000008 operator delete(void*)
    00000000      DF *UND*  00000000 pthread_mutex_lock
    00000000      DF *UND*  00000000 pthread_mutex_unlock
    00000000      DF *UND*  00000000 mkdir
    00000000      DF *UND*  00000000 truncate
    00000000      DF *UND*  00000000 unlink
    00000000      DF *UND*  00000000 rename
    00000000      DF *UND*  00000000 wmemcmp
    00000000      DF *UND*  00000000 memset
    00000000      DF *UND*  00000000 fmodf
    00000000      DF *UND*  00000000 fmod
    00000000      DF *UND*  00000000 strlen
    00000000      DF *UND*  00000000 pthread_attr_init
    00000000      DF *UND*  00000000 pthread_attr_setdetachstate
    00000000      DF *UND*  00000000 pthread_create
    00000000      DF *UND*  00000000 sched_yield
    000162a5  w   DF .text  00000018 tolower
    00000000      DO *UND*  00000000 _tolower_tab_
    000162bd  w   DF .text  00000018 toupper
    00000000      DO *UND*  00000000 _toupper_tab_
    001df1f5 g    DF .text  00000014 operator new[](unsigned int)
    001dee45 g    DF .text  00000004 operator delete[](void*)
    00000000      DF *UND*  00000000 wcslen
    00000000      DF *UND*  00000000 wcsncpy
    00000000      DF *UND*  00000000 strncpy
    00000000      DF *UND*  00000000 memcpy
    00000000      DF *UND*  00000000 gmtime
    00000000      DF *UND*  00000000 localtime
    001de4a9 g    DF .text  00000004 operator delete(void*, std::nothrow_t const&)
    002f3fc0 g    DO .rodata        00000001 std::nothrow
    001df449 g    DF .text  00000050 operator new(unsigned int, std::nothrow_t const
    &)
    00000000      DF *UND*  00000000 strftime
    00000000      DF *UND*  00000000 time
    00000000      DF *UND*  00000000 memmove
    00000000      DF *UND*  00000000 pow
    00000000      DF *UND*  00000000 powf
    00000000      DF *UND*  00000000 ceil
    001df3f5 g    DF .text  00000018 __cxa_pure_virtual
    001de38d g    DF .text  0000009a __cxa_guard_acquire
    001de469 g    DF .text  0000003e __cxa_guard_release
    001de429 g    DF .text  00000040 __cxa_guard_abort
    00000000      DF *UND*  00000000 logf
    00000000      DF *UND*  00000000 log
    00000000      DF *UND*  00000000 log10
    00000000      DF *UND*  00000000 log10f
    00000000      DF *UND*  00000000 floorf
    00000000      DF *UND*  00000000 memcmp
    00000000      DF *UND*  00000000 strtod
    00000000      DF *UND*  00000000 strchr
    00000000      DF *UND*  00000000 atoi
    00000000      DF *UND*  00000000 uncompress
    00000000      DF *UND*  00000000 compress2
    00000000      DF *UND*  00000000 atan2f
    00000000      DF *UND*  00000000 ceilf
    00000000      DF *UND*  00000000 setlocale
    001d5d0d  w   DF .text  00000024 isspace
    00000000      DO *UND*  00000000 _ctype_
    00000000      DF *UND*  00000000 strncmp
    00000000      DF *UND*  00000000 snprintf
    00000000      DF *UND*  00000000 sscanf
    00000000      DF *UND*  00000000 fseek
    00000000      DF *UND*  00000000 fgetc
    00000000      DF *UND*  00000000 ferror
    00000000      DF *UND*  00000000 ftell
    00000000      DF *UND*  00000000 fread
    00000000      DF *UND*  00000000 fopen
    00000000      DF *UND*  00000000 fclose
    00000000      DF *UND*  00000000 printf
    00000000      DO *UND*  00000000 __sF
    00000000      DF *UND*  00000000 vfprintf
    00000000      DF *UND*  00000000 vsnprintf
    00000000      DF *UND*  00000000 __android_log_print
    00000000      DF *UND*  00000000 syscall
    00000000      DF *UND*  00000000 abort
    00000000      DF *UND*  00000000 pthread_key_delete
    00000000      DF *UND*  00000000 pthread_getspecific
    00000000      DF *UND*  00000000 pthread_setspecific
    00000000      DF *UND*  00000000 pthread_key_create
    00000000      DF *UND*  00000000 write
    00000000      DF *UND*  00000000 acos
    00000000      DF *UND*  00000000 asin
    00000000      DF *UND*  00000000 atan
    00000000      DF *UND*  00000000 atan2
    00000000      DF *UND*  00000000 cos
    00000000      DF *UND*  00000000 cosh
    00000000      DF *UND*  00000000 exp
    00000000      DF *UND*  00000000 frexp
    00000000      DF *UND*  00000000 sqrt
    00000000      DF *UND*  00000000 modf
    00000000      DF *UND*  00000000 sin
    00000000      DF *UND*  00000000 sinh
    00000000      DF *UND*  00000000 tan
    00000000      DF *UND*  00000000 tanh
    00000000      DF *UND*  00000000 wmemcpy
    00000000      DF *UND*  00000000 vsprintf
    00000000      DF *UND*  00000000 memchr
    00000000      DF *UND*  00000000 wcsftime
    00000000      DF *UND*  00000000 pthread_once
    00000000      DF *UND*  00000000 fflush
    00000000      DF *UND*  00000000 fdopen
    00000000      DF *UND*  00000000 setvbuf
    00000000      DF *UND*  00000000 read
    00000000      DF *UND*  00000000 writev
    00000000      DF *UND*  00000000 lseek
    00000000      DF *UND*  00000000 ioctl
    00000000      DF *UND*  00000000 poll
    00000000      DF *UND*  00000000 fstat
    00000000      DF *UND*  00000000 wmemchr
    00000000      DF *UND*  00000000 strcoll
    00000000      DF *UND*  00000000 strxfrm
    00000000      DF *UND*  00000000 wcscoll
    00000000      DF *UND*  00000000 wcsxfrm
    00000000      DF *UND*  00000000 fwrite
    00000000      DF *UND*  00000000 getwc
    00000000      DF *UND*  00000000 putwc
    00000000      DF *UND*  00000000 getc
    00000000      DF *UND*  00000000 ungetc
    00000000      DF *UND*  00000000 ungetwc
    00000000      DF *UND*  00000000 putc
    00000000      DF *UND*  00000000 wmemset
    00000000      DF *UND*  00000000 wmemmove
    00000000      DF *UND*  00000000 wctype
    00000000      DF *UND*  00000000 towupper
    00000000      DF *UND*  00000000 towlower
    00000000      DF *UND*  00000000 iswctype
    00000000      DF *UND*  00000000 wctob
    00000000      DF *UND*  00000000 btowc
    00000000      DF *UND*  00000000 pthread_cond_destroy
    00000000      DF *UND*  00000000 pthread_cond_wait
    00000000      DF *UND*  00000000 pthread_cond_signal
    00000000      DF *UND*  00000000 pthread_cond_broadcast
    00000000      DF *UND*  00000000 strerror
    00000000      DF *UND*  00000000 fputs
    00000000      DF *UND*  00000000 fputc
    00000000      DF *UND*  00000000 sprintf
    00304458 g    D  *ABS*  00000000 _edata
    00304458 g    D  *ABS*  00000000 __bss_start
    0030a329 g    D  *ABS*  00000000 _end
    00000000  w   DF *UND*  00000000 __gnu_Unwind_Find_exidx
    00000000      DF *UND*  00000000 raise
    

    Is this familiar to you?

     

Log in to post a comment.