Browse Source

launcher_main: automatically set LD_LIBRARY_PATH on launch

pull/122/merge
nillerusr 2 years ago
parent
commit
2dca8fd6c7
  1. 19
      launcher_main/main.cpp

19
launcher_main/main.cpp

@ -216,6 +216,25 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
char ld_path[4196];
char *path = "bin/";
char *ld_env;
if( (ld_env = getenv("LD_LIBRARY_PATH")) != NULL )
{
snprintf(ld_path, sizeof(ld_path), "%s:bin/", ld_env);
path = ld_path;
}
setenv("LD_LIBRARY_PATH", path, 1);
extern char** environ;
if( getenv("NO_EXECVE_AGAIN") == NULL )
{
setenv("NO_EXECVE_AGAIN", "1", 1);
execve(argv[0], argv, environ);
}
void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW ); void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
if ( !launcher ) if ( !launcher )
fprintf( stderr, "%s\nFailed to load the launcher\n", dlerror() ); fprintf( stderr, "%s\nFailed to load the launcher\n", dlerror() );

Loading…
Cancel
Save