连接问题CUDA编译使用升压code [英] Problems linking CUDA-compiled with Boost-using code

查看:325
本文介绍了连接问题CUDA编译使用升压code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关CUDA暨升压互动问题偶尔弹出她这样,但他们总是对的编译的(?)CUDA与Boost的巫毒把戏麻烦。共同的看法是到$ C $隔离c。使用加速从CUDA编译code。

Questions about CUDA-cum-Boost interaction occasionally pop up her on SO, but they are always (?) about compilation: CUDA has trouble with Boost's voodoo tricks. The common wisdom is to isolate your code using Boost from your CUDA-compiled code.

所以,我这样做:我在写一个小程序CUDA与的boost :: program_options 很好地限制在一个类的实施使用。我的问题是在链接

So, I've done this: I'm writing a small CUDA utility, with boost::program_options nicely limited to use in the implementation of a single class. My problems are in linking.

我的工作Debian的弹力(64位),这是建立与GCC 5.x的(这包括其升压1.58包)。我CUDA 7.5的本地安装,但是,只能忍受GCC 4.9.x或更早的版本,这是我使用。编译一切之后,未定义的引用依然存在。也就是说,我做后:

I'm working on Debian Stretch (64-bit), which is built with GCC 5.x (and this includes its Boost 1.58 packages). My local installation of CUDA 7.5, however, can only stomach gcc 4.9.x or earlier, which is what I use. After compiling everything, Undefined references remain. That is, after I do:

/usr/bin/g++-4.9   -Wall -std=c++11  originally_cu.o originaly_cpp.o weird_cmake_generated_intermediate_link.o -o foo_app -rdynamic /usr/local/cuda/lib64/libcudart_static.a -lpthread -lrt -ldl -lboost_log -lboost_system -lboost_program_options /usr/local/cuda/lib64/libcudart_static.a -lpthread -lrt -ldl -lboost_log -lboost_system -lboost_program_options 

(CMake的生成,我不知道为什么我看到的双重 -l <​​/ code> S)

(CMake generates that, I'm not sure why I'm seeing the double -ls)

我得到:

originally_cpp.o: In function `FooConfiguration::getFromProgramArguments(int, char**)':
FooConfiguration.cpp:(.text+0x5d4): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
FooConfiguration.cpp:(.text+0x6ca): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
FooConfiguration.cpp.o: In function `boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::string const&, std::string const&, int)':
FooConfiguration.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKSsS4_i[_ZN5boost15program_options16validation_errorC5ENS1_6kind_tERKSsS4_i]+0x2e): undefined reference to `boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)'

等等。

我想,也许这有事可做的事实,升压与海湾合作委员会建立5.x中;所以,我下载了升压1.60,用gcc 4.9建造它,并在的/ opt /升压修改安装了它:并添加的/ opt /升压/ lib目录来`LD_LIBRARY_PATH)。但是,当我试图使用它,以及 - 它建立,但我得到加速内分段违规(我知道我不应该,因为同样的code另一台机器上运行,至少要解析命令 - 点行参数)。下面是从GDB回溯:

I thought maybe this had something to do with the fact that Boost was built with gcc 5.x ; so, I downloaded Boost 1.60, built it with gcc 4.9, and installed it under /opt/boost ( and add /opt/boost/lib to `LD_LIBRARY_PATH). But when I tried to use it, well - it builds, but I get segmentation violations within Boost (And I know I shouldn't, because the same code runs on another machine, at least to the point of parsing command-line arguments). Here's a backtrace from gdb:

(gdb) bt
#0  0x00007fe9b8362880 in boost::program_options::validators::check_first_occurrence(boost::any const&) () from /opt/boost/lib/libboost_program_options.so.1.60.0
#1  0x000000000046c9d8 in void boost::program_options::validate<int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int*, long) ()
#2  0x000000000046be44 in boost::program_options::typed_value<int, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const ()
#3  0x00007fe9b8347cda in boost::program_options::option_description::~option_description() () from /opt/boost/lib/libboost_program_options.so.1.60.0
#4  0x00007fe9b834d2b5 in boost::detail::sp_counted_impl_p<boost::program_options::option_description>::dispose() () from /opt/boost/lib/libboost_program_options.so.1.60.0
#5  0x00000000004616d4 in boost::detail::sp_counted_base::release() ()
#6  0x0000000000461763 in boost::detail::shared_count::~shared_count() ()
#7  0x0000000000468c4c in boost::shared_ptr<boost::program_options::option_description>::~shared_ptr() ()
#8  0x0000000000468c66 in void std::_Destroy<boost::shared_ptr<boost::program_options::option_description> >(boost::shared_ptr<boost::program_options::option_description>*) ()
#9  0x0000000000467c05 in void std::_Destroy_aux<false>::__destroy<boost::shared_ptr<boost::program_options::option_description>*>(boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description>*) ()
#10 0x0000000000465eeb in void std::_Destroy<boost::shared_ptr<boost::program_options::option_description>*>(boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description>*) ()
#11 0x0000000000464337 in void std::_Destroy<boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description> >(boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description>*, std::allocator<boost::shared_ptr<boost::program_options::option_description> >&) ()
#12 0x0000000000462ee3 in std::vector<boost::shared_ptr<boost::program_options::option_description>, std::allocator<boost::shared_ptr<boost::program_options::option_description> > >::~vector() ()
#13 0x0000000000461ccc in boost::program_options::options_description::~options_description() ()
#14 0x000000000045fb88 in FooConfiguration::getFromProgramArguments(int, char**) ()
#15 0x00000000004710e1 in get_configuration (argc=1, argv=0x7fff61fcb398) at /home/joeuser/foo_app/src/main.cu:257
#16 0x00000000004711f7 in main (argc=1, argv=0x7fff61fcb398) at /home/joeuser/foo_app/src/main.cu:269

下面是在此情况下,LDD输出:

Here is the ldd output in this case:

linux-vdso.so.1 (0x00007ffd4912f000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f06496e6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f06494de000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f06492d9000)
libboost_log.so.1.60.0 => /opt/boost/lib/libboost_log.so.1.60.0 (0x00007f064901e000)
libboost_system.so.1.60.0 => /opt/boost/lib/libboost_system.so.1.60.0 (0x00007f0648e1b000)
libboost_program_options.so.1.60.0 => /opt/boost/lib/libboost_program_options.so.1.60.0 (0x00007f0648ba3000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0648828000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0648523000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f064830c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0647f68000)
/lib64/ld-linux-x86-64.so.2 (0x000055a192443000)
libboost_atomic.so.1.60.0 => /opt/boost/lib/libboost_atomic.so.1.60.0 (0x00007f0647d66000)
libboost_date_time.so.1.60.0 => /opt/boost/lib/libboost_date_time.so.1.60.0 (0x00007f0647b54000)
libboost_filesystem.so.1.60.0 => /opt/boost/lib/libboost_filesystem.so.1.60.0 (0x00007f064793b000)
libboost_regex.so.1.60.0 => /opt/boost/lib/libboost_regex.so.1.60.0 (0x00007f064761e000)
libboost_thread.so.1.60.0 => /opt/boost/lib/libboost_thread.so.1.60.0 (0x00007f06473f9000)
libboost_chrono.so.1.60.0 => /opt/boost/lib/libboost_chrono.so.1.60.0 (0x00007f06471f3000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f064573c000)
libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007f06452d9000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f0644f45000)

所以:


  • 是什么造成了这些问题?

  • 我能做些什么来解决任何他们或比不使用升压绕过他们,其他的?

推荐答案

显然,这有没有关系CUDA,我可以只提升来体现的问题。跟进的<一个href=\"http://stackoverflow.com/questions/34974854/undefined-reference-when-linking-with-boost-using-g-4-9-on-a-g-5-ish-distrib\">pertinent非CUDA相关的问题。感谢@Drop。

Apparently this has nothing to do with CUDA, I can get the problem to manifest with just Boost. Following up with the pertinent non-CUDA-related question. Thanks @Drop.

这篇关于连接问题CUDA编译使用升压code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆