Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'pthread_getname_np' was not declared in this scope #3832

Closed
OneTop4458 opened this issue Oct 12, 2022 · 5 comments · Fixed by #4210
Closed

'pthread_getname_np' was not declared in this scope #3832

OneTop4458 opened this issue Oct 12, 2022 · 5 comments · Fixed by #4210

Comments

@OneTop4458
Copy link
Contributor

OneTop4458 commented Oct 12, 2022

problem

src/Thread_POSIX.cpp:69:39: error: 'pthread_setname_np' was not declared in this scope
  pthread_setname_np(threadName.c_str()); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)

poco info

poco : 1.12.2-all

system info

# uname -a
AIX ZEUS 1 6 00F6B0674C00

# gcc --version
gcc (GCC) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# g++ --version
g++ (GCC) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# cmake --version
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).

#make --version
GNU Make 4.1
Built for powerpc-ibm-aix6.1.0.0
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

error log

g++ -Iinclude -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/CppUnit/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Encodings/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/XML/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/JSON/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Util/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Net/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Crypto/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/NetSSL_OpenSSL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/JWT/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/SQLite/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/ODBC/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/MySQL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/PostgreSQL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Zip/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/PageCompiler/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/PageCompiler/File2Page/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/MongoDB/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Redis/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/ActiveRecord/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/ActiveRecord/Compiler/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Prometheus/include -I/home/user/workspace/Prebuild/openssl/include   -std=c++14 -Wall -Wno-sign-compare -DPOCO_BUILD_HOST='"'p510'"' -DPOCO_TARGET_OSNAME='"'AIX'"' -DPOCO_TARGET_OSARCH='"'00C4C7DF4C00'"' -DPOCO_NO_WSTRING -DPOCO_NO_FPENVIRONMENT -D_XOPEN_SOURCE=600 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_IPv6 -D__STDC_FORMAT_MACROS -pthread -latomic  -g -D_DEBUG -fPIC -c src/Timespan.cpp -o /home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/obj/AIX/00C4C7DF4C00/debug_shared/Timespan.o
In file included from src/Thread.cpp:32:0:
src/Thread_POSIX.cpp: In function 'void {anonymous}::setThreadName(pthread_t, const string&)':
src/Thread_POSIX.cpp:69:39: error: 'pthread_setname_np' was not declared in this scope
  pthread_setname_np(threadName.c_str()); // __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
                                       ^
** Compiling src/Timestamp.cpp (debug, shared)
g++ -Iinclude -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/CppUnit/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Encodings/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/XML/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/JSON/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Util/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Net/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Crypto/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/NetSSL_OpenSSL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/JWT/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/SQLite/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/ODBC/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/MySQL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Data/PostgreSQL/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Zip/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/PageCompiler/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/PageCompiler/File2Page/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/MongoDB/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Redis/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/ActiveRecord/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/ActiveRecord/Compiler/include -I/home/user/workspace/Prebuild/src/poco-1.12.2-all/Prometheus/include -I/home/user/workspace/Prebuild/openssl/include   -std=c++14 -Wall -Wno-sign-compare -DPOCO_BUILD_HOST='"'p510'"' -DPOCO_TARGET_OSNAME='"'AIX'"' -DPOCO_TARGET_OSARCH='"'00C4C7DF4C00'"' -DPOCO_NO_WSTRING -DPOCO_NO_FPENVIRONMENT -D_XOPEN_SOURCE=600 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_IPv6 -D__STDC_FORMAT_MACROS -pthread -latomic  -g -D_DEBUG -fPIC -c src/Timestamp.cpp -o /home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/obj/AIX/00C4C7DF4C00/debug_shared/Timestamp.o
/home/user/workspace/Prebuild/src/poco-1.12.2-all/build/rules/compile:59: recipe for target '/home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/obj/AIX/00C4C7DF4C00/debug_shared/Thread.o' failed
make[1]: *** [/home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation/obj/AIX/00C4C7DF4C00/debug_shared/Thread.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/user/workspace/Prebuild/src/poco-1.12.2-all/Foundation'
Makefile:131: recipe for target 'Foundation-libexec' failed
make: *** [Foundation-libexec] Error 2

I can't find pthread_setname_np for Unix equipment as explained in the link below

12.39.19 pthread_setname_np
Documentation:
[man pthread_setname_np](https://www.kernel.org/doc/man-pages/online/pages/man3/pthread_setname_np.3.html)

Gnulib module: —

Portability problems fixed by Gnulib:

Portability problems not fixed by Gnulib:

This function is missing on many non-glibc platforms: glibc 2.11, Mac OS X 10.5, FreeBSD 12.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14.
This function has a different signature on some platforms: NetBSD 9.0. On NetBSD the second argument is interpreted as a printf format string, with the third argument as parameter.

https://www.gnu.org/software/gnulib/manual/html_node/pthread_005fsetname_005fnp.html

I tested all of the equipment below, but I couldn't find the same pthread_setname_np

aix 6.1
aix 7.1
aix 7.2
solaris 11.1
solaris 11.2

@HR1025
Copy link
Contributor

HR1025 commented Oct 13, 2022

try link with -lpthread

@OneTop4458
Copy link
Contributor Author

try link with -lpthread

I've already tried it.

In conclusion, the same error occurs because the pthread_getname_np function itself is not defined in the system itself /usr/include/pthread.h.

After searching through various codes, I came to the conclusion that the UNIX system should make an exception like the code below.

https://github.com/Haivision/srt/blob/master/srtcore/threadname.h

@github-actions
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Oct 14, 2023
@aleks-f aleks-f added this to the Release 1.12.5 milestone Oct 14, 2023
@pavledragisic pavledragisic linked a pull request Oct 22, 2023 that will close this issue
@aleks-f aleks-f added fixed and removed stale labels Oct 22, 2023
@aleks-f aleks-f reopened this Oct 23, 2023
@aleks-f
Copy link
Member

aleks-f commented Oct 23, 2023

9ad2bc7

@aleks-f
Copy link
Member

aleks-f commented Oct 23, 2023

c163237

@aleks-f aleks-f closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants