[491] in Pthreads mailing list archive
Re: pthreads and syslog
daemon@ATHENA.MIT.EDU (Larry V. Streepy, Jr.)
Mon Nov 11 16:41:16 1996
Date: Mon, 11 Nov 1996 14:04:52 -0700
From: "Larry V. Streepy, Jr." <streepy@healthcare.com>
To: Stewart Gebbie <stewart@lin01.global.co.za>
Cc: pthreads@MIT.EDU
Stewart Gebbie wrote:
>
> Hi,
>
> I'm trying to use syslog with pthreads-1_60_beta5 without success.
> to compile I used pg++ -o test_syslog test_syslog.cc
>
> -----------------test_syslog.cc-------------------
> #include <syslog.h>
>
> int main(void)
> {
> openlog("MyProg",LOG_PID,LOG_USER);
>
> syslog(LOG_USER|LOG_DEBUG,"[%lx,%s:%d] %d: %s",0,__FILE__,__LINE__,123,"
> blaa");
>
> closelog();
>
> return 0;
> };
> --------------------------------------------------
>
> and the output is
>
> /tmp/cca007941.o: In function `main':
> /tmp/cca007941.o(.text+0xd): undefined reference to `openlog(char *, int, i
> nt)'
> /tmp/cca007941.o(.text+0x2c): undefined reference to `syslog(int, char *,..
> .)'
> /tmp/cca007941.o(.text+0x34): undefined reference to `closelog(void)'
>
> I can't seem to get around this.
>
> Does anybody have any ideas.
I don't know what OS your running on, but under Linux, the syslog.h
header file fails to wrap the function decls in extern "C" constructs.
You should check your OS and if this is the case, try this:
extern "C" {
#include <syslog.h>
}
int main(void)
{
...
--
Larry V. Streepy, Jr.
Chief Technical Officer, Healthcare Communications, Inc.
mailto:streepy@healthcare.com
(214) 851-7033 (Dallas Main #)
(970) 626-5028 (My office #) (970) 626-4425 (Fax)