VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

This forum is about all development around libVLC.
eli13
Blank Cone
Blank Cone
Posts: 25
Joined: 21 May 2012 15:28

VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby eli13 » 29 May 2012 12:42

Hello.

(Another) question about VLC_PLUGIN_PATH:

It seems to me that it is not possible to set this variable on a Win32 System programmatically in a way that it can be used by libVlc: If I set up VLC_PLUGIN_PATH as an environment variable using control-panel -> Advanced -> Environment variables -> etc.. things work fine with libVLC (Defining it to something like C:\myplugins)

If I set them from within my program before calling new_libvlc for the first time, the variable is set within my program, but not within the process/thread where VLC runs. For example the following will not work:

Code: Select all

wstring vlcPluginDirectory = L"C:\\myplugins"; ::SetEnvironmentVariable(L"VLC_PLUGIN_PATH", vlcPluginDirectory.c_str()); m_pVlcInstance = libvlc_new(0, NULL);
All this makes sense as libVLc probably does not use the CreateProcess function of the win32 api and therefore the thread does not inherit the environment, but gets a new one.

Is there any known work-around simpler than the one mentioned here: http://permalink.gmane.org/gmane.comp.v ... evel/86757? I'm not so happy with having a folder named 'plugin' (VlcPlugins would be nice ;) ) or having to modify the environment. Or do I get things totally wrong?

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

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby Rémi Denis-Courmont » 29 May 2012 13:57

All this makes sense as libVLc probably does not use the CreateProcess function of the win32 api and therefore the thread does not inherit the environment, but gets a new one.
The environment is process-wide state, not thread state. If the environment variable is set before libvlc starts, it just works. In fact, development builds of vlc.exe use VLC_PLUGIN_PATH:

http://git.videolan.org/?p=vlc.git;a=bl ... 0-git#l122
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

eli13
Blank Cone
Blank Cone
Posts: 25
Joined: 21 May 2012 15:28

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby eli13 » 29 May 2012 14:23

What do you exactly mean with "before libvlc starts"? I assumed that libvlc will "start" on the first call to libvlc_new(..) but setting the environment var before the first call to libvlc_new(..) does not work here (Win7, VC++ 2008, libVlc 2.0.1). Thanks for the help.

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

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby Rémi Denis-Courmont » 29 May 2012 14:26

As you can see in the code linked above, before the first call to libvlc_new() (within the address space).
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

eli13
Blank Cone
Blank Cone
Posts: 25
Joined: 21 May 2012 15:28

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby eli13 » 29 May 2012 15:17

Thanks again Rémi for the quick answer. I still can't get it to work. What is confusing me: From the source-linked above, I would assume this very simple program would work (If the directory C:\vlcPlugins is existing):

Code: Select all

#include "stdafx.h" #include "vlc/libvlc.h" #include <Windows.h> #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { // ::SetEnvironmentVariable(L"VLC_PLUGIN_PATH", L"C:\\vlcPlugins"); // _putenv("VLC_PLUGIN_PATH=C:\\vlcPlugins"); _wputenv(L"VLC_PLUGIN_PATH=C:\\vlcPlugins"); libvlc_instance_t* pVlc = NULL; pVlc = libvlc_new(0, NULL); if(!pVlc) { std::cout << "Failed"; return 1; } std::cout << "OK"; return 0; }
But when I try to run it, I get:

Code: Select all

D:\Dev\PluginTestApp\Debug>PluginTestApp.exe [00802818] main libvlc error: No plugins found! Check your VLC installation. Failed
(It doesnt matter if I use SetEnvironmentVariable, _putenv, _wputenv)

But, when I manually set the environment variable before launching the exe, things work fine:

Code: Select all

D:\Dev\PluginTestApp\Debug>set VLC_PLUGIN_PATH=C:\vlcPlugins D:\Dev\PluginTestApp\Debug>PluginTestApp.exe OK
Glad for any hints pointing me to the place where I make a mistake.

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

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby Rémi Denis-Courmont » 29 May 2012 15:41

I don't know. Be sure to use the same CRT as libvlc.dll; that's known to cause various problems on Windows.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

eli13
Blank Cone
Blank Cone
Posts: 25
Joined: 21 May 2012 15:28

Re: VC++, Win32: Setting VLC_PLUGIN_PATH programmatically

Postby eli13 » 29 May 2012 16:03

I think I have the correct ones: Dependency Walker tells me libvlc.dll uses MSVCRT.DLL what would be the Multithreaded, dynamic link /MD Version, the same that I use from within Visual Studio - strange.

For linking, I use the lib from http://code.google.com/p/vc-libvlc/ - should be correct according to some other post.

Well, its not such a big deal as there are lots of way to deal with this problem - I was just wondering if I'm missing something obvious.. And the rest is running perfect (until now).

Thanks for your help anyway.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 20 guests