草庐IT

pause_test_threads

全部标签

c++ - 链接 boost::thread

我正在尝试使用boost库学习一些东西,但是当我尝试编译包含boost::threads的东西时遇到了问题。我在链接过程中遇到错误,消息如下:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld:cannotfind-lboost-thread但这很奇怪,因为只有当我用普通用户编译时才会发生这种情况,使用root我可以毫无问题地编译。提前致谢。 最佳答案 包含#include其他链接器标志-lboost_system-lboost_

c++ - debian 和 std::thread c++ 的即时段错误

遇到这个问题-在标题中..我有这个代码:#include#includevoidmy_thread_func(){std::cout摘自网络某处。编译器选项-pthread-std=gnu++0x(也试过-std=c++0x)而且我有段错误。一切都在vmBox上的Debian上。我之前已经启动了其他代码,并且它们有效。突然间,我在所有工作应用程序中使用std::thread的线程上出现段错误。编辑:这是来自gdb:(gdb)where#00x00000000in??()#10x08048dc9inthread(this=0xbffff3fc,__f=0x8048b9f)at/usr/i

c++ - OpenMP Mac OSX Lion c++ 链接器错误 Undefined symbols for architecture x86_64 : "_omp_get_thread_num"

我在互联网上的任何地方都找不到这个问题。所以我的链接器错误是:Undefinedsymbolsforarchitecturex86_64:"_omp_get_thread_num()"这是我的代码:intnthreads;inttid;#pragmaompparallelprivate(tid){tid=omp_get_thread_num();if(tid==0){nthreads=omp_get_num_threads();printf("numberofthreads:%d\n",nthreads);}} 最佳答案 看起来你忘

c++ - 为什么 istream_iterator<string>(ifstream ("test.txt")) 会导致错误?

我尝试编写代码从名为“test.txt”的文件中读取字符串并将字符串写入标准输出。下面的代码运行良好:intmain(){usingnamespacestd;ifstreamfile("test.txt");copy(istream_iterator(file),istream_iterator(),ostream_iterator(cout,""));}但是,通过此修改,代码不再编译:intmain(){usingnamespacestd;copy(istream_iterator(ifstream("test.txt")),//(),ostream_iterator(cout,""

c++ - 为什么 virtual void test()=00 有效但 virtual void test()=+0 和 virtual void test()=-0 无效?

我搜索了一些关于虚函数声明的帖子,相信=0在virtualvoidtest()=0;是固定句法所以virtualvoidtest()=NULL;virtualvoidtest()=false;virtualvoidtest()=1-1;virtualvoidtest()=0.0;和其他声明应该是无效的。但是我发现了virtualvoidtest()=00;virtualvoidtest()=000;virtualvoidtest()=0000;还能编译,为什么?还有,我觉得整数+0和-0其实和0一样(不知道对不对),就像00其实就是0一样,为什么virtualvoidtest()=+0

c++ - gtest,对 'testing::Test::~Test()' 的 undefined reference ,testing::Test::Test()

我使用apt-getinstalllibgtest-dev安装了gtest我正在尝试检查它是否有效。所以我在eclipse中编写了简单的测试代码。但是有错误,undefinedreferenceto'testing::Test::~Test()'undefinedreferenceto'testing::Test::Test()'相反,如果我将ATest类的继承更改为protected,错误就会消失,但是出现其他错误testing::Testisinaccessiblebaseof'ATest_AAA_Test'怎么了?#include#includeclassA{public:int

c++ - 错误:使用已删除的函数'test::test (const test&) C++ 结合 vector

我有一个我不明白的问题。我有一个生成线程的类。一切都好。我制作了一个新对象-一切正常。如果我将这些存储在一个vector中以迭代我的代码将无法编译。我使用g++4.9i686。我制作了以下简短程序,它完全模拟了问题,因为真实代码相当广泛。如果有人可以澄清或给我一个对我的宠物项目非常有用的解决方案,因为我坚持这个。代码如下:#include#include#include#includeclasstest{public:test();voidsetstring(std::strings);~test(){}voidrunThread(){m_thread=std::thread(&tes

C++:具有 `std::lock_guard` 的互斥量是否足以同步两个 `std::thread`?

我的问题是基于下面的C++代码示例#include#include#include#includeclassClassUtility{public:ClassUtility(){}~ClassUtility(){}voiddo_something(){std::coutlock(g_mutex);std::coutlock(g_mutex);std::cout如果需要,这更像是一个问题,目的是让我的理解更清楚,并获取std::condition_variable的示例用法。我有2个C++std::thread,它们在main方法中启动。它是osx上的控制台应用程序。所以使用clang编

c++ - Thread Sanitizer 是否可用?

我想尝试线程清洁剂(http://code.google.com/p/data-race-test/wiki/ThreadSanitizer#Using_ThreadSanitizer)所以我做了一个简单的程序:#include#include#include#include#include#includeusingnamespacestd;intviolated=0;mutexmtx;voidviolator(){lock_guardlg(mtx);violated++;}intmain(){threadt1(violator);t1.join();threadt2(violator

c++ - 不知道使用 google-test 在哪里抛出异常

我们使用GoogleTest作为我们的C++单元测试框架。但是我遇到了一个痛苦的情况,不知道如何处理。基本上,当代码中存在未捕获的异常时,我会在控制台中打印以下错误消息并得到一个FAILED。很明显,这个异常是被googletest捕获的。但是,我根本不知道异常在哪里抛出。unknownfile:error:SEHexceptionwithcode0xc000005throwninthetestbody.我能做的就是调试和单步调试代码,我最终会找出问题所在。但这不是很有效,因为项目很大。我希望调试器在未捕获的异常行处停止,并给我一个漂亮的调用堆栈。谷歌测试中有什么我不知道的设置吗?任何