Skip to content

Commit fd8bd30

Browse files
authored
Create shared.cpp
1 parent b661b39 commit fd8bd30

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

shared/shared.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ QString copyDylib(const LibraryInfo &library, const QString path)
670670
return dylibDestinationBinaryPath;
671671
}
672672

673-
void runPatchelf(QStringList options)
673+
QString runPatchelf(QStringList options)
674674
{
675675
QProcess patchelftool;
676676
patchelftool.start("patchelf", options);
@@ -690,6 +690,7 @@ void runPatchelf(QStringList options)
690690
LogError() << "runPatchelf:" << patchelftool.readAllStandardOutput();
691691
// exit(1); // Do not exit because this could be a script that patchelf can't work on
692692
}
693+
return(patchelftool.readAllStandardOutput().trimmed());
693694
}
694695

695696
bool patchQtCore(const QString &path, const QString &variable, const QString &value)
@@ -742,6 +743,17 @@ bool patchQtCore(const QString &path, const QString &variable, const QString &va
742743

743744
void changeIdentification(const QString &id, const QString &binaryPath)
744745
{
746+
LogNormal() << "Checking rpath in" << binaryPath;
747+
QString oldRpath = runPatchelf(QStringList() << "--get-rpath" << id << binaryPath);
748+
if (oldRpath.startsWith("/")){
749+
LogDebug() << "Old rpath in" << binaryPath << "starts with /, hence adding it to LD_LIBRARY_PATH";
750+
// FIXME: Split along ":" characters, check each one, only append to LD_LIBRARY_PATH if not already there
751+
QString oldPath = env.value("LD_LIBRARY_PATH");
752+
QString newPath = oldRpath + ":" + oldPath; // FIXME: If we use a ldd replacement, we still need to observe this path
753+
// FIXME: Directory layout might be different for system Qt; cannot assume lib/ to always be inside the Qt directory
754+
LogDebug() << "Changed LD_LIBRARY_PATH:" << newPath;
755+
setenv("LD_LIBRARY_PATH",newPath.toUtf8().constData(),1);
756+
}
745757
LogNormal() << "Changing rpath in" << binaryPath << "to" << id;
746758
runPatchelf(QStringList() << "--set-rpath" << id << binaryPath);
747759

0 commit comments

Comments
 (0)