- FS::Path libdir = FS::get_sys_lib_dir(argv[0], "gldbg");
- process.setenv("LD_PRELOAD", (libdir/"glwrap.so").str().c_str());
+ instance = this;
+
+ char buf[PATH_MAX];
+ unsigned len = readlink("/proc/self/exe", buf, sizeof(buf));
+ string exe(buf, len);
+ string::size_type slash = exe.rfind('/');
+ process.setenv("LD_PRELOAD", (exe.substr(0, slash+1)+"glwrap.so"));