[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

problem compiling with pthread_setaffinity_np()



Hello,

I am trying to compile a program using the non-portable (np)
pthread_setaffinity_np() call and I am running into problems
with glibc. 

With LinuxThreads, the call is not defined (as expected):

gcc -Wall  -O2 -g  -pthread -D_GNU_SOURCE -c test.c
test.c: In function 'pfms_thread_mainloop':
test.c:147: warning: implicit declaration of function 'pthread_setaffinity_np'
gcc -Wall  -O2 -g  -pthread  -D_GNU_SOURCE -o test test.o -lm -lpthread
test.o: In function `main':test.c:147: undefined reference to `pthread_setaffinity_np'

forcing the use of NPTL, I run into another problem with the cancel calls which I do 
not quite understand. Apparently some of the calls are declared as hidden but I don't
know why. Note that I do not explicitely refer to those __pthread*cancel() calls,
instead I use the documented testcancel(), setcancelstate(), cancel(). is what I get:

gcc -Wall  -O2 -g  -pthread -D_GNU_SOURCE -I/usr/include/nptl -c test.c
gcc -Wall  -O2 -g  -pthread -D_GNU_SOURCE -I/usr/include/nptl -D_GNU_SOURCE -o test test.o -lm -lpthread
test.o: In function `barrier_wait':test.c:93: undefined reference to `__pthread_register_cancel'
:test.c:127: undefined reference to `__pthread_unregister_cancel'
:test.c:127: undefined reference to `__pthread_unregister_cancel'
test.o: In function `pfms_thread_mainloop':test.c:147: undefined reference to `pthread_setaffinity_np'

I am runing Sarge/testing on i686:

$ dpkg -i | fgrep libc6
ii  libc6                        2.3.5-13                          GNU C Library: Shared libraries and Timezone
ii  libc6-dev                    2.3.5-13                          GNU C Library: Development Libraries and Hea
ii  libc6-i686                   2.3.5-13                          GNU C Library: Shared libraries [i686 optimi

ii  gcc                          4.0.2-2                           The GNU C compiler
ii  gcc-4.0                      4.0.2-9                           The GNU C compiler
ii  gcc-4.0-base                 4.0.2-9                           The GNU Compiler Collection (base package)
ii  libgcc1                      4.0.2-9                           GCC support library

The same problem exists on Debian/testing on IA-64.

Does anybody know what I am missing?

Thanks.

-- 
-Stephane



Reply to: