Problem when including "vlc.h" file to c++ win32

This forum is about all development around libVLC.
tirolock
Blank Cone
Blank Cone
Posts: 29
Joined: 04 Jun 2018 17:34

Problem when including "vlc.h" file to c++ win32

Postby tirolock » 06 Jun 2018 14:19

I downloaded vlc-3.0.3's sdk with the .7z link given on this page -> https://get.videolan.org/vlc/3.0.3/win3 ... 3-win32.7z
I added the whole vlc folder to my c++ project, I added the include directory, the library directory and the libs to my project's properties.
I added a path to vlc's dlls to my PATH environment variable.

When I add the include to "vlc\vlc.h" file to my project's .cpp file and try to build it, I get a bunch of errors from the "libvlc_media.h" file...

-Error (active) E0090 function returning function is not allowed vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error (active) E0338 more than one instance of overloaded function "libvlc_media_new_callbacks" has 'C' linkage vlc-3.0.3\sdk\include\vlc\libvlc_media.h 475
-Error C2065 'libvlc_media_read_cb': undeclared identifier vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error C2513 'int': no variable declared before '=' vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error C2143 syntax error: missing ';' before '(' vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error C2062 type 'void' unexpected vlc-3.0.3\sdk\include\vlc\libvlc_media.h 368
-Error C2061 syntax error: identifier 'libvlc_media_read_cb' vlc-3.0.3\sdk\include\vlc\libvlc_media.h 478

Is there a known cause for those errors??

tirolock
Blank Cone
Blank Cone
Posts: 29
Joined: 04 Jun 2018 17:34

Re: Problem when including "vlc.h" file to c++ win32

Postby tirolock » 06 Jun 2018 16:21

I did the same steps with the 2.2.8 sdk .7z link given on this page ->https://download.videolan.org/pub/video ... 8-win32.7z
Everything seems to be ok... I could include my header files to my .cpp and build afterward..

avilleret
New Cone
New Cone
Posts: 3
Joined: 18 May 2014 10:13

Re: Problem when including "vlc.h" file to c++ win32

Postby avilleret » 20 Jun 2018 09:57

I do have the same issue with 3.0.2 and 3.0.3.
By commenting out the related line in libvlc_media.h the code compiles but then it crash as soon as I call a libvlc_media* function.

avilleret
New Cone
New Cone
Posts: 3
Joined: 18 May 2014 10:13

Re: Problem when including "vlc.h" file to c++ win32

Postby avilleret » 20 Jun 2018 11:29

It seems that `ssize_t` is not defined in MSVC maybe because it's not POSIX but a C extension.
you can replace it with `int`

Jackylan
New Cone
New Cone
Posts: 1
Joined: 20 Jun 2018 11:40

Re: Problem when including "vlc.h" file to c++ win32

Postby Jackylan » 20 Jun 2018 11:47

Just add following type definition before line 368 of libvlc_media.h
typedef unsigned int ssize_t;

You may get another error in libvlc_dialog.h. To solve it, just DELETE following statement at line 24
#include <stdbool.h>

tirolock
Blank Cone
Blank Cone
Posts: 29
Joined: 04 Jun 2018 17:34

Re: Problem when including "vlc.h" file to c++ win32

Postby tirolock » 21 Jun 2018 15:54

Is there any way to propose these changes to vlc's developer community?

User avatar
InTheWings
Developer
Developer
Posts: 1275
Joined: 07 Aug 2013 13:15
VLC version: crashing
Operating System: Linux
Contact:

Re: Problem when including "vlc.h" file to c++ win32

Postby InTheWings » 21 Jun 2018 17:37

Just add following type definition before line 368 of libvlc_media.h
typedef unsigned int ssize_t;
DONT do that unless you want crashes & undefined behavior
:!: If you want your problem to be solved :
* First read troubleshooting guide VSG:Main
* Always provide verbose LOGS ! (command line or from gui)
* Always check your issue against a developer build from Nightly Build of VLC
* Tell us when your problem is solved !

User avatar
InTheWings
Developer
Developer
Posts: 1275
Joined: 07 Aug 2013 13:15
VLC version: crashing
Operating System: Linux
Contact:

Re: Problem when including "vlc.h" file to c++ win32

Postby InTheWings » 21 Jun 2018 17:38

:!: If you want your problem to be solved :
* First read troubleshooting guide VSG:Main
* Always provide verbose LOGS ! (command line or from gui)
* Always check your issue against a developer build from Nightly Build of VLC
* Tell us when your problem is solved !

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: Problem when including "vlc.h" file to c++ win32

Postby mangokm40 » 22 Jun 2018 19:34

Just add following type definition before line 368 of libvlc_media.h
typedef unsigned int ssize_t;
I believe that is wrong. "ssize_t" is supposed to be a "size type" that allows for an error value (-1).
The comment in libvlc_media.h (#361) says the function returns "-1 on non-recoverable error".
I don't think you want to use "unsigned int".

When I started using libvlc 3.0, I didn't know about the C++ bindings mentioned above. I've been using an int return value for that callback prototype.
That is the only reference to "ssize_t", so I don't "typedef" it. I just changed the "ssize_t" for "int".

While reading libvlc_media.h, I just noticed the "libvlc_media_open_cb" prototype uses "uint64_t" for the byte length of the stream.
In my system, that's defined as "long long". I'm going to try "uint64_t" as the return type in "libvlc_media_read_cb".
Of course, I'm having no problems and shouldn't change it...but. :)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 21 guests