This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++, pthreads, -D__STL_PTHREADS, and link errors
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: g++, pthreads, -D__STL_PTHREADS, and link errors
- From: rgarabedian at tripod dot com
- Date: Wed, 17 Mar 1999 17:29:16 -0500
Thank you so much for responding ... I *think* your suggestions worked. In the
least, I'm now able to get my test program to compile.
I'm going to try the complete app in a bit. One thing I thought you'd be
interested in. The new compiler produced an internal error
when trying to build the test program that contained some "last ditch" efforts
by me to get the mess to build. Specifically, I tried to
specify pthread_alloc as the allocator to be used with string. See source and
output below.
Oh, and sorry about the attachement I sent before. Wasn't thinking :-)
Compiler output:
*********************************************************************************************************************************************
bash$ make
g++ -c -DOS_SOLARIS_2_5 -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__ -D_REENTRANT
-D__STL_PTHREADS -DDEBUG -g -v test.cc
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.66/cpp -lang-c++ -v
-undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -Dsparc -Dsun
-Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4
-D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -g
-D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) -DOS_SOLARIS_2_5
-D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__ -D_REENTRANT -D__STL_PTHREADS -DDEBUG
test.cc /var/tmp/ccBpk8Uy.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++
/usr/local/include
/usr/local/sparc-sun-solaris2.5.1/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.66/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.66/cc1plus
/var/tmp/ccBpk8Uy.ii -quiet -dumpbase test.cc -g -version -o /var/tmp/cc8Lipt6.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release)
(sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.91.66 19990314
(egcs-1.1.2 release).
test.cc: In function `int main()':
test.cc: At top level:
test.cc:39: Internal compiler error 980521.
test.cc:39: Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.
test.cc:39: See <URL:http://egcs.cygnus.com/faq.html#bugreport> for details.
make: *** [test.o] Error 1
bash$
Simple test program
*********************************************************************************************************************************************
#include <pthread.h>
#include <iostream.h>
#include <string>
#include <pthread_alloc>
void setAttributes();
// Driver Globals
pthread_attr_t attr;
void * threadEntry(void *arg)
{
int count = 10;
while(count)
{
cout << "Looping ..." << endl;
count--;
};
pthread_exit(NULL);
return NULL;
};
////////////////////////////////////////////////////////////////////////////////
////// Main //////
////////////////////////////////////////////////////////////////////////////////
main()
{
unsigned int tid;
// Just trying somethine here ... anything
string msg<char, string_char_traits<char>, pthread_alloc>;
cout << "Main: Waking up and creating thread..." << endl;
setAttributes();
pthread_create(&tid, NULL, threadEntry, NULL);
pthread_attr_destroy( &attr );
pthread_join(tid, NULL);
cout << "Main: Exiting" << endl;
};
void setAttributes()
{
if( pthread_attr_init(&attr) != 0)
{
cout << "Unable to initialize attribute struct" << endl;
exit(1);
};
if( pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM) != 0)
{
cout << "Unable to set attribute scope" << endl;
exit(1);
};
};
Simple Makefile
*********************************************************************************************************************************************
###############################################################################
# Name: Makefile
# Author: R. Garabedian
# Date: 11/27/98
###############################################################################
#
#
# Define objects to build
#
#
#
CC = g++
C_FLAGS = -c -DOS_SOLARIS_2_5 -D_POSIX_C_SOURCE=199506L \
-D__EXTENSIONS__ -D_REENTRANT \
-D__STL_PTHREADS -DDEBUG -g -v
TEST_OBJS = test.o
shitTest : $(TEST_OBJS)
$(CC) -o $@ -lgcc $(TEST_OBJS) -lnsl -lposix4 -lpthread \
-R /usr/local/lib -v
test.o : test.cc
$(CC) $(C_FLAGS) $<
Thanks again !
Rich
Alexandre Oliva <oliva@dcc.unicamp.br> on 03/17/99 12:17:17 PM
To: Rich Garabedian <rgarabed@tripod.com>
cc: egcs@egcs.cygnus.com (bcc: Rich Garabedian/Lycos)
Subject: Re: g++, pthreads, -D__STL_PTHREADS, and link errors
On Mar 17, 1999, Rich Garabedian <rgarabed@tripod.com> wrote:
> I'm having a great deal of difficulty building a multi-threaded app,
> and I'm running out of options.
Thanks for your bug report. Please don't post compiler output as
zipped bitmaps, plain text is much easier to read and takes much less
space. It took me about 2 minutes to figure out you're not even using
egcs, but gcc 2.8.1. Time to upgrade. After you download egcs 1.1.2,
don't forget to configure --enable-threads!
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org,computer.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Instituto de Computa
ção, Universidade Estadual de Campinas, SP, Brasil
*** E-mail about software projects will be forwarded to mailing lists