Browse Source

Linux: remove hard-coded plugin path and find it via dladdr() instead

pull/1639/head
bsp2 6 years ago
parent
commit
0e32465769
2 changed files with 13 additions and 5 deletions
  1. +12
    -4
      src/vst2_main.cpp
  2. +1
    -1
      vst2_common_linux_pre.mk

+ 12
- 4
src/vst2_main.cpp View File

@@ -148,6 +148,9 @@ struct PluginMutex {
#include <fcntl.h>
#include <sys/mman.h>

// #define _GNU_SOURCE
#include <dlfcn.h>

//static pthread_mutex_t loc_pthread_mutex_t_init = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static pthread_mutex_t loc_pthread_mutex_t_init = PTHREAD_MUTEX_INITIALIZER;

@@ -526,6 +529,7 @@ public:

char oldCWD[1024];
char dllnameraw[1024];
char *dllnamerawp = dllnameraw;

#ifdef HAVE_WINDOWS
::GetCurrentDirectory(1024, (LPSTR) oldCWD);
@@ -538,12 +542,16 @@ public:
// (+the string is not NULL-terminated from the looks of it)
readlink("/proc/self/exe", dllnameraw, 1024);
#else
// (TODO) just a test
sprintf(dllnameraw, "/mnt/git/VeeSeeVSTRack/vst2_bin/");
// (note) 'dli_fname' can be a relative path
Dl_info dlInfo;
::dladdr((void*)VSTPluginMain, &dlInfo);
// // dllnamerawp = (char*)dlInfo.dli_fname;
sprintf(dllnameraw, "%s/%s", oldCWD, dlInfo.dli_fname);
#endif
#endif

dllname.visit(dllnameraw);
Dprintf("xxx vstrack_plugin::openEffect: dllnamerawp=\"%s\"\n", dllnamerawp);
dllname.visit(dllnamerawp);
dllname.getDirName(&cwd);
rack::global->vst2.program_dir = (const char*)cwd.chars;

@@ -559,7 +567,7 @@ public:
int argc = 1;
char *argv[1];
//argv[0] = (char*)cwd.chars;
argv[0] = (char*)dllnameraw;
argv[0] = (char*)dllnamerawp;
Dprintf("xxx argv[0]=%p\n", argv[0]);
Dprintf("xxx vstrack_plugin::openEffect: dllname=\"%s\"\n", argv[0]);
(void)vst2_init(argc, argv,


+ 1
- 1
vst2_common_linux_pre.mk View File

@@ -7,6 +7,6 @@ else
EXTRALIBS_DEP= dep/lib/linux_gcc/x86
endif

EXTRALIBS+= $(EXTRALIBS_DEP)/libspeexdsp.a $(EXTRALIBS_DEP)/glew.a $(EXTRALIBS_DEP)/jansson.a `pkg-config gtk+-2.0 --libs` -lGL
EXTRALIBS+= $(EXTRALIBS_DEP)/libspeexdsp.a $(EXTRALIBS_DEP)/glew.a $(EXTRALIBS_DEP)/jansson.a `pkg-config gtk+-2.0 --libs` -lGL -ldl

plugin_lib = $(PLUGIN_DIR)/$(1)/$(1).a

Loading…
Cancel
Save