cuda: undefined reference to `cufftExecR2C' - cmake

Im using Cudas cuFFT library and therefore I have added the library path to $LD_LIBRARY_PATH. When compiling, Im using the -lcufft flag, after including the header with #include<cufft.h>. But I still receive the following errors:
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x51b): undefined reference to `cufftExecR2C'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x528): undefined reference to `cufftDestroy'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16d8): undefined reference to `cufftPlan2d'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16f3): undefined reference to `cufftExecC2R'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16fd): undefined reference to `cufftDestroy'
collect2: error: ld returned 1 exit status
This is a CMake project and I link via: set(CMAKE_CUDA_FLAGS_RELEASE " -I/opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/include -L/opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/lib64 -lcufft")
Am I missing something crucial?

Related

Difficulty in linking FFTW library with gfortran

I have a c++ program, which uses the FFTW3 library, which I would like to translate to Fortran. I am using Ubuntu 22.04.1.
I installed the FFTW3 library as detailed in Installation on UNIX
The c++ main program is named ksbenchmark.cpp and, using g++, I compile it and link it (to the math and fftw3 libraries) with
g++ -o my_executable.out ksbenchmark.cpp -lm -lfftw3
which works great.
I have translate the c++ code in Fortran, the source file being named ksbenchmrk.f90.
If I issue
gfortran ksbenchmark.f90 -lfftw3 -lm
I get error messages
/usr/bin/ld: /tmp/cca2xMGa.o: in function `ksintegrate_':
ksbenchmark.f90:(.text+0x59): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x94): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0xcf): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x4de): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x5db): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x626): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x780): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0xa1c): undefined reference to `dfftw_execute_'
collect2: error: ld returned 1 exit status
I have spent the afternoon reading about it, and it seems I may have to use -I and -L flags such as
gfortran test.f90 -L/new/path/to/lib -I/new/path/to/include -lfftw3 -lm
as illustrated in the post Problems linking FFTW with gfortran (symbol(s) not found for architecture x86_64).
The first question is, what paths to use?
I can find files referring to fftw3 in /usr/local/lib as well as in /usr/local/include, but the attempt
gfortran ksbenchmark.f90 -L/usr/local/lib -I/usr/local/include -lfftw3 -lm
returns the same error as before
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/ccW2DYGP.o: in function `ksintegrate_':
ksintegrate.f90:(.text+0x62): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0x9d): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0xd8): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0x4df): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x5f7): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x643): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x79d): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0xa5b): undefined reference to `dfftw_execute_'
collect2: error: ld returned 1 exit status
I am unable to understand which paths to the library are to be used.
How to find where the library is saved?
Why does not g++ need any paths to the library?
I apologise for how trivial the question might seem, I am a total newbie can ensure I put a significant effort in trying to sort this out. Any hint would be most appreciated, thanks
EDIT
Following Vladimir F Героям слава's advice, I tried using the nm command to verify the library contains what is expected to.
In /usr/local/lib
I found libfftw3.a and libfftw3.la files.
Issuing nm libfftw3.a I get quite a long list.
I tried looking for one of the commands I get an error about, dfftw_plan_dft_1d
nm -S libfftw3.a | grep dfftw_plan_dft_1d
and indeed it returns hits
00000000000003a0 0000000000000026 T _Z18dfftw_plan_dft_1d_PP11fftw_plan_sPiPA2_dS4_S2_S2_
0000000000002df0 0000000000000026 T _Z19dfftw_plan_dft_1d__PP11fftw_plan_sPiPA2_dS4_S2_S2_

How do I solve GATE building file make error

I am installing gate on centOS 7. Almost finish all installation besides a little error when I try to build installation file in build directory before final installation, make install. Here is the command line response:
100%] Building CXX object CMakeFiles/Gate.dir/source/physics/src/GateXrayBoundaryPB.cc.o
[100%] Building CXX object CMakeFiles/Gate.dir/source/physics/src/GateeMultipleScatteringPB.cc.o
[100%] Building CXX object CMakeFiles/Gate.dir/source/physics/src/GatehMultipleScatteringPB.cc.o
[100%] Linking CXX executable Gate
/usr/bin/ld: warning: libtbb.so.2, needed by /home/xincao/GATE/root_v6.18/lib/libImt.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libvdt.so, needed by /home/xincao/GATE/root_v6.18/lib/libROOTVecOps.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libRDAVIX.so.6.18, needed by /home/xincao/GATE/root_v6.18/lib/libROOTDataFrame.so, not found (try using -rpath or -rpath-link)
/home/xincao/GATE/root_v6.18/lib/libROOTDataFrame.so: undefined reference to `Davix::DavPosix::pread(Davix_fd*, void*, unsigned long, long, Davix::DavixError**)'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::task_scheduler_init::initialize(int)'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::task::note_affinity(unsigned short)'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::internal::throw_exception_v4(tbb::internal::exception_id)'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `vtable for tbb::task'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::task_group_context::reset()'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_terminate()'
...
/home/xincao/GATE/root_v6.18/lib/libROOTDataFrame.so: undefined reference to `Davix::DavPosix::stat(Davix::RequestParams const*, std::string const&, stat*, Davix::DavixError**)'
/home/xincao/GATE/root_v6.18/lib/libROOTDataFrame.so: undefined reference to `Davix::DavixError::getErrMsg() const'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const'
/home/xincao/GATE/root_v6.18/lib/libROOTDataFrame.so: undefined reference to `Davix::Context::~Context()'
/home/xincao/GATE/root_v6.18/lib/libImt.so: undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
collect2: error: ld returned 1 exit status
make[2]: *** [Gate] Error 1
make[1]: *** [CMakeFiles/Gate.dir/all] Error 2
make: *** [all] Error 2
Does anyone can help? Any reply will be highly appreciated!!
Thanks!
It is because the geant4.sh script in the Geant4 bin has not been run. This sets up the LD_LIBRARY_PATH variable which then allows these libraries to be found. (Note that you will need the data from CERN in order to successfully run geant4.sh)

colcon could not find thirdparty libraries (Poco)

I am trying to cross-compile ROS2 for Arm. The steps I am following can be found in here: https://github.com/ros2-for-arm/ros2/wiki/ROS2-on-arm-architecture
The build command used is
colcon build --symlink-install --cmake-force-configure --cmake-args -DCMAKE_TOOLCHAIN_FILE=aarch64_toolchainfile.cmake -DTHIRDPARTY=ON -DBUILD_TESTING:BOOL=OFF
The poco library cannot be found, however it is in "/work/ROS2_Bouncy/ros2_ws/install/poco_vendor/lib/libPocoFoundation.so.50" and it is correctly cross-compiled:
/work/ROS2_Bouncy/ros2_ws/install/poco_vendor/lib/libPocoFoundation.so.50: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=6ba44c72e2162ca056b0dbde681dd4a8b5da5e35, not stripped
I wonder where I can modify the CMake script to specify the path to the thirdparty libraries. I tried to specify manually the path to Poco but it did not work:
add_library(Poco_import SHARED IMPORTED)
set_target_properties(Poco_import PROPERTIES
IMPORTED_LOCATION "/work/ROS2_Bouncy/ros2_ws/install/poco_vendor/lib/libPocoFoundation.so.50"
)
I also tried adding the path to the Poco library in CMAKE_EXE_LINKER_FLAGS
(-L) but no success.
Everything look to be compiled correctly, but I got an error at the linking stage:
Failed <<< examples_rclcpp_minimal_publisher [ Exited with code 2 ]
--- stderr: examples_rclcpp_minimal_timer
/work/Documents/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.1.1/../../../../aarch64-linux-gnu/bin/ld: warning: libPocoFoundation.so.50, needed by /work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so, not found (try using -rpath or -rpath-link)
/work/Documents/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.1.1/../../../../aarch64-linux-gnu/bin/ld: warning: libyaml.so, needed by /work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so, not found (try using -rpath or -rpath-link)
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_event_delete'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_parse'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::getSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_delete'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_initialize'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::hasSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::SharedLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_set_input_file'
collect2: error: ld returned 1 exit status
gmake[2]: *** [timer_lambda] Error 1
gmake[1]: *** [CMakeFiles/timer_lambda.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
/work/Documents/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.1.1/../../../../aarch64-linux-gnu/bin/ld: warning: libPocoFoundation.so.50, needed by /work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so, not found (try using -rpath or -rpath-link)
/work/Documents/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.1.1/../../../../aarch64-linux-gnu/bin/ld: warning: libyaml.so, needed by /work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so, not found (try using -rpath or -rpath-link)
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_event_delete'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_parse'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::getSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_delete'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_initialize'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::hasSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::SharedLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/work/ROS2_Bouncy/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_set_input_file'
collect2: error: ld returned 1 exit status
gmake[2]: *** [timer_member_function] Error 1
gmake[1]: *** [CMakeFiles/timer_member_function.dir/all] Error 2
gmake: *** [all] Error 2
Thanks to Tsyvarev who pointed to me the correct flag.
I added the following to the toolchain file and it solved the issue.
set(PATH_POCO_LIB "${CMAKE_CURRENT_LIST_DIR}/build/poco_vendor/poco_external_project_install/lib/")
set(PATH_YAML_LIB "${CMAKE_CURRENT_LIST_DIR}/build/libyaml_vendor/libyaml_install/lib/")
set(CMAKE_BUILD_RPATH "${PATH_POCO_LIB};${PATH_YAML_LIB}")

Issues installing apache httpd 2.4.20 with ldap

I am trying to configure apache using the following command:
./configure --prefix=/opt/nms/app/apache --with-apr=/home/kvanapal/httpd-2.4.20/srclib/apr --with-apr-util=/home/kvanapal/httpd-2.4.20/srclib/apr-util/apu--config --enable-mods-shared=all --with-ldap --with-included-apr --with-included-apr-util --enable-ldap
After this I am running the make command and this gives the following error towards the end:
server/.libs/libmain.a(exports.o):(.data+0x3f0): undefined reference to `apr_ldap_url_parse'
server/.libs/libmain.a(exports.o):(.data+0x3f8): undefined reference to `apr_ldap_url_parse_ext'
server/.libs/libmain.a(exports.o):(.data+0x400): undefined reference to `apr_ldap_is_ldapi_url'
server/.libs/libmain.a(exports.o):(.data+0x408): undefined reference to `apr_ldap_is_ldaps_url'
server/.libs/libmain.a(exports.o):(.data+0x410): undefined reference to `apr_ldap_is_ldap_url'
server/.libs/libmain.a(exports.o):(.data+0x418): undefined reference to `apr_ldap_rebind_remove'
server/.libs/libmain.a(exports.o):(.data+0x420): undefined reference to `apr_ldap_rebind_add'
server/.libs/libmain.a(exports.o):(.data+0x428): undefined reference to `apr_ldap_rebind_init'
server/.libs/libmain.a(exports.o):(.data+0x430): undefined reference to `apr_ldap_set_option'
server/.libs/libmain.a(exports.o):(.data+0x438): undefined reference to `apr_ldap_get_option'
server/.libs/libmain.a(exports.o):(.data+0x440): undefined reference to `apr_ldap_info'
server/.libs/libmain.a(exports.o):(.data+0x448): undefined reference to `apr_ldap_init'
server/.libs/libmain.a(exports.o):(.data+0x450): undefined reference to `apr_ldap_ssl_deinit'
server/.libs/libmain.a(exports.o):(.data+0x458): undefined reference to `apr_ldap_ssl_init'
collect2: error: ld returned 1 exit status
make[1]: *** [httpd] Error 1
What could be causing this issue?

relocation R_X86_64_PC32 against `_ZN7QStringD1Ev' can not be used when making a shared object; recompile with -fPIC

When I build qtwebkit, I got this problem.
/usr/bin/ld: /data/zhengjie/qt-everywhere-opensource-src-5.5.1/qtmultimedia/lib/libQt5Multimedia.a(qmediametadata.o): relocation R_X86_64_PC32 against `_ZN7QStringD1Ev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [../../lib/libWebCore.so.1.0.0] Error 1
Can anyone help?