Operating System - HP-UX
1833696 Members
3431 Online
110062 Solutions
New Discussion

Re: stl pthread and Bus error

 
Xiao Ling Zhou
New Member

stl pthread and Bus error

My application always crash (Bus error), I simplified it as the following cpp, it use some stl class,

//--------test.cpp---------
#include
#include
#include
#include

typedef std::basic_string _CHAR_STRING;
typedef std::list<_CHAR_STRING> tmp;
typedef std::map abcmap;

abcmap map1;

int main(void)
{
printf("begin\n");
tmp a1;
_CHAR_STRING h = "sdfasdffsdfsdflksdhfjlkasdhfjlk;asdhfl;kasdhf;kjasdlfasdfasd";
a1.push_back(h);
a1.push_back("aaaa");
a1.push_back("aaaa");
a1.push_back("aaaa");

printf("ok\n");
return 0;
}
//-----------------------


I compiled it the the command,

aCC -AA +DA1.1 +DS2.0 -D_INCLUDE__STDC_A1_SOURCE -DRWSTD_MULTI_THREAD -D_REENTRANT -D_THREAD_SAFE -g -D_UNIX -D_UNICODE -o test test.cpp -lrt -lCsup_v2 -lstd_v2 -lpthread


when I run it, a Bus error occurred.

When I remove the link option -lpthread, it work fine. Unfortunatly, my real application should use POSIX thread!

Cound anyone enlight me on this problem?

Thanks a million!
2 REPLIES 2
harry d brown jr
Honored Contributor

Re: stl pthread and Bus error

Why not just drop the "-lpthread" option and replace it with "-mt"??

live free or die
harry
Live Free or Die
Xiao Ling Zhou
New Member

Re: stl pthread and Bus error

I use aCC for HP-UX 11, the aCC compiler only accept
-DRWSTD_MULTI_THREAD
-D_REENTRANT
-D_THREAD_SAFE
-D_HPUX_SOURCE
-D_POSIX_C_SOURCE=199506L

and -lpthread.

mt is the compiler flags for Sun Solaris