Consider the following example:
#include <signal.h>
extern "C" {
static void signalHandler(int signal) {}
}
int main(int, char**)
{
sigset (SIGTERM, signalHandler);
return 0;
}
CC test.cpp
succeeds.
But
CC test.cpp -std=c++11
Undefined first referenced
symbol in file
sigset test.o
ld: fatal: symbol referencing errors
I also tried the following:
CC test.cpp -std=c++11 -lstdc++ -lgcc_s -lc
But yields the same error. -m64
doesn't help either.
Nor does -lstdc++ -lgcc_s -lCrunG3
.
OS: Solaris 11 Compiler: CC from Oracle Solaris Studio 12.4
Output requested:
me@myhost:~/projects/cpptest> CC -std=c++11 -c test.cpp -o test.o
me@myhost:~/projects/cpptest> nm -A test.o | grep sigset
test.o: [14] | 0| 0|FUNC |GLOB |0 |UNDEF |_Z6sigset
me@myhost:~/projects/cpptest> nm -A /usr/lib/libc.so | grep sigset
/usr/lib/libc.so: [527] | 883372| 224|FUNC |LOCL |2 |16 |__csigsetjmp
/usr/lib/libc.so: [5694] | 736724| 420|FUNC |WEAK |3 |16 |_sigset
/usr/lib/libc.so: [6599] | 883868| 28|FUNC |GLOB |3 |16 |_sigsetjmp
/usr/lib/libc.so: [4906] | 833680| 532|FUNC |WEAK |3 |16 |_thr_sigsetmask
/usr/lib/libc.so: [6267] | 736724| 420|FUNC |GLOB |3 |16 |sigset
/usr/lib/libc.so: [4590] | 883868| 28|FUNC |GLOB |3 |16 |sigsetjmp
/usr/lib/libc.so: [2244] | 0| 0|FILE |LOCL |0 |ABS |sigsetops.c
/usr/lib/libc.so: [4502] | 833680| 532|FUNC |GLOB |3 |16 |thr_sigsetmask
me@myhost:~/projects/cpptest>
If I use <csignal>
instead of <signal.h>
, I get the following error:
"test.cpp", line 17: Error: The function "sigset" must have a prototype.