2016-05-09 47 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在这方面有很大不同。

相关问题