nvcc 错误编译 ld 错误未定义对符号的引用 'XConvertSelection'
nvcc error compiling ld error undefined reference to symbol 'XConvertSelection'
我正在尝试编译可在其他机器和集群上运行的 nvcc,现在我在 运行 x86-64 机器上收到 relocation R_X86_64_32 against ...
不同库文件的错误和错误。将 --compiler-options
放在标记错误的相关库之后。在之后添加 -fPIC
会导致错误 return。所以我很困惑。
命令(易读):
nvcc -o exe/prog src/main.cu -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode arch=compute_37,code=sm_37 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_52,code=compute_52 -L/home/mohamed/PhD/VENV/lib -L/home/mohamed/PhD/VENV/glew-1.10.0/lib -llua -lGLEW -lglfw3 -lcuda -lGLU -ljpeg -lGL -lGLU -lglfw3 --compiler-options -lX11 -lXxf86vm -lXrandr -lpthread -lXi -I ./code_generator_lua/utils/ -I/home/mohamed/PhD/VENV/include/GLFW -I/home/mohamed/PhD/VENV/glew-1.10.0/include -I ./utils2/visualisation -D WITH_OPENGL -I ./geo -I/home/mohamed/PhD/VENV/lua-5.1.5/src -I/home/mohamed/PhD/VENV/boost_1_61_0 -I/usr/local/cuda-7.5/samples/common/inc
这是我的编译命令行输出(终端)(请忽略警告-它们是正常的):
nvcc -o exe/prog src/main.cu -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode arch=compute_37,code=sm_37 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_52,code=compute_52 -L/home/mohamed/PhD/VENV/lib -L/home/mohamed/PhD/VENV/glew-1.10.0/lib -llua -lGLEW -lglfw3 -lcuda -lGLU -ljpeg -lGL -lGLU -lglfw3 --compiler-options -lX11 -lXxf86vm -lXrandr -lpthread -lXi -I ./code_generator_lua/utils/ -I/home/mohamed/PhD/VENV/include/GLFW -I/home/mohamed/PhD/VENV/glew-1.10.0/include -I ./utils2/visualisation -D WITH_OPENGL -I ./geo -I/home/mohamed/PhD/VENV/lua-5.1.5/src -I/home/mohamed/PhD/VENV/boost_1_61_0 -I/usr/local/cuda-7.5/samples/common/inc
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/usr/bin/ld: /home/mohamed/PhD/VENV/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to symbol 'XConvertSelection'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我已经为所有使用新系统和 运行 旧代码的用户解决了这个问题。由于静态和动态库,这实际上是 relocation R_X86_64_32 ...
错误的问题。现在,如果您使用的是 gcc 和 g++ 版本 <4.8,则可以通过 运行 gcc 在我的案例 nvcc 中找到带有 no-pie
标志的解决方案。还要确保默认情况下即使是 gcc 4.8 也没有启用 pie。您可以通过检查版本 gcc -v
.
来检查启用的默认值
我正在尝试编译可在其他机器和集群上运行的 nvcc,现在我在 运行 x86-64 机器上收到 relocation R_X86_64_32 against ...
不同库文件的错误和错误。将 --compiler-options
放在标记错误的相关库之后。在之后添加 -fPIC
会导致错误 return。所以我很困惑。
命令(易读):
nvcc -o exe/prog src/main.cu -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode arch=compute_37,code=sm_37 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_52,code=compute_52 -L/home/mohamed/PhD/VENV/lib -L/home/mohamed/PhD/VENV/glew-1.10.0/lib -llua -lGLEW -lglfw3 -lcuda -lGLU -ljpeg -lGL -lGLU -lglfw3 --compiler-options -lX11 -lXxf86vm -lXrandr -lpthread -lXi -I ./code_generator_lua/utils/ -I/home/mohamed/PhD/VENV/include/GLFW -I/home/mohamed/PhD/VENV/glew-1.10.0/include -I ./utils2/visualisation -D WITH_OPENGL -I ./geo -I/home/mohamed/PhD/VENV/lua-5.1.5/src -I/home/mohamed/PhD/VENV/boost_1_61_0 -I/usr/local/cuda-7.5/samples/common/inc
这是我的编译命令行输出(终端)(请忽略警告-它们是正常的):
nvcc -o exe/prog src/main.cu -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode arch=compute_37,code=sm_37 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_52,code=compute_52 -L/home/mohamed/PhD/VENV/lib -L/home/mohamed/PhD/VENV/glew-1.10.0/lib -llua -lGLEW -lglfw3 -lcuda -lGLU -ljpeg -lGL -lGLU -lglfw3 --compiler-options -lX11 -lXxf86vm -lXrandr -lpthread -lXi -I ./code_generator_lua/utils/ -I/home/mohamed/PhD/VENV/include/GLFW -I/home/mohamed/PhD/VENV/glew-1.10.0/include -I ./utils2/visualisation -D WITH_OPENGL -I ./geo -I/home/mohamed/PhD/VENV/lua-5.1.5/src -I/home/mohamed/PhD/VENV/boost_1_61_0 -I/usr/local/cuda-7.5/samples/common/inc
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/home/mohamed/PhD/VENV/boost_1_61_0/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp(75): warning: variable "tmp" was set but never used
src/main.cu(364): warning: variable "fname2" was declared but never referenced
src/main.cu(392): warning: conversion from a string literal to "char *" is deprecated
/usr/bin/ld: /home/mohamed/PhD/VENV/lib/libglfw3.a(x11_clipboard.c.o): undefined reference to symbol 'XConvertSelection'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我已经为所有使用新系统和 运行 旧代码的用户解决了这个问题。由于静态和动态库,这实际上是 relocation R_X86_64_32 ...
错误的问题。现在,如果您使用的是 gcc 和 g++ 版本 <4.8,则可以通过 运行 gcc 在我的案例 nvcc 中找到带有 no-pie
标志的解决方案。还要确保默认情况下即使是 gcc 4.8 也没有启用 pie。您可以通过检查版本 gcc -v
.