2016-05-09 73 views
1

我想建立cmake-gui與自定義路徑,但是失敗的運行:如何使用qt的自定義路徑構建cmake-gui?

#/opt/dev-tools-4.9/cmake-gui 
/opt/dev-tools-4.9/cmake-gui: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory 

所以我想這cmake的桂開始在/opt/dev-tools-4.9搜索QTX,但它從一個用系統

# strace -f ./cmake-gui 
execve("./cmake-gui", ["./cmake-gui"], [/* 24 vars */]) = 0 
brk(0)         = 0x13ca000 
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or directory) 
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fcfdff0b000 
access("/etc/ld.so.preload", R_OK)  = -1 ENOENT (No such file or directory) 
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 
fstat(3, {st_mode=S_IFREG|0644, st_size=53974, ...}) = 0 
mmap(NULL, 53974, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcfdfefd000 
close(3)        = 0 
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/tls/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/tls/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/x86_64-linux-gnu/tls", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0 
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/x86_64-linux-gnu/tls/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/x86_64-linux-gnu/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/x86_64-linux-gnu/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=32768, ...}) = 0 
open("/lib/tls/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/tls/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/lib/tls/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/tls", 0x7fffebe47810)  = -1 ENOENT (No such file or directory) 
open("/lib/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib/x86_64", 0x7fffebe47810)  = -1 ENOENT (No such file or directory) 
open("/lib/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 
open("/usr/lib/tls/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/tls/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/tls/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/tls", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/x86_64/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib/x86_64", 0x7fffebe47810) = -1 ENOENT (No such file or directory) 
open("/usr/lib/libQtGui.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 
writev(2, [{"./cmake-gui", 11}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"libQtGui.so.4", 13}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2}, {"No such file or directory", 25}, {"\n", 1}], 10./cmake-gui: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory 
) = 124 
exit_group(127)       = ? 
+++ exited with 127 +++ 

我在LFS找到一個例子,其中我可以使用自定義路徑QTX:

如果Qt4​​的和QT5被安裝在/ opt,使用源setqt4或源碼 setqt5選擇哪一個將用於構建基於Qt的GUI。

但沒有這些文件:

~# cd cmake-3.5.2 
root:~/cmake-3.5.2# ls |grep set 
root:~/cmake-3.5.2# 

libarchive

wget http://www.libarchive.org/downloads/libarchive-3.2.0.tar.gz 
tar xzvf libarchive-3.2.0.tar.gz 
./configure --prefix=/opt/dev-tools-4.9 --disable-static && \ 
make -j $(nproc || grep -c ^processor /proc/cpuinfo|| echo "1") && \ 
make install 

cmake的構建2.8.11

wget --no-check-certificate https://cmake.org/files/v2.8/cmake-2.8.11.tar.gz 
tar xzvf cmake-2.8.11.tar.gz 
./bootstrap --prefix=/opt/dev-tools-4.9 \ 
    --no-system-libs --qt-gui   && \ 
    make -j $(nproc || grep -c ^processor /proc/cpuinfo|| echo "1") && \ 
    make install 
+0

那麼,在構建過程中應該使用'-rpath'鏈接器選項,或者在執行之前將路徑添加到LD_LIBRARY_PATH環境變量。 – user3159253

+1

如果輸入'ls/opt |,你會得到什麼? grep qt'?我不知道LFS,但似乎你必須在開始構建cmake之前運行'setqt4'。 – Antonio

+0

所以它不是cmake的一部分? –

回答

1

要調整的是rpath的構建只適用於cmake-gui,您應該在之後添加這樣的內容,後add_executable(cmake-gui....)

set_target_properties(cmake-gui PROPERTIES     
    INSTALL_RPATH "/opt/path/to/qt/shared/libs" 
) 

不要忘記再生CMake的完全建立的文件。一個正確配置的版本應該在鏈接器調用命令中包含-Wl,-rpath,<specified-path>Source/QtDialog/CMakeFiles/cmake-gui.dir/link.txt

注意:一切都按照cmake-3.2.2進行檢查,但我不認爲其他版本的cmake在這方面有很大不同。

相關問題