Operating System - HP-UX
1752761 Members
5411 Online
108789 Solutions
New Discussion

troubles building librdkafka

 
dongfang
Visitor

troubles building librdkafka

hi, All:

 

 

I'm try to compile the 3rd opensource library: librdkafka, and  then solve some compile problems. but can't handle the last problem.

 

the first step, compile librdkafka library, and no errror happen.

echo "uname is HP-UX;"
uname is HP-UX;
Creating shared library librdkafka.so.1
aCC rdqueue.o rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_defaultconf.o rdkafka_timer.o rdkafka_offset.o rdcrc32.o rdgz.o rdaddr.o rdrand.o rdthread.o rdlog.o -mt -lpthread -lrt -bdynamic -o librdkafka.so.1


Creating static library librdkafka.a
ar rcs librdkafka.a rdqueue.o rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_defaultconf.o rdkafka_timer.o rdkafka_offset.o rdcrc32.o rdgz.o rdaddr.o rdrand.o rdthread.o rdlog.o

 

Checking librdkafka integrity
librdkafka.so.1 OK
librdkafka.a OK

 

when compile the example, and occur the link error. 

aCC -I../src rdkafka_example.c -mt -lpthread -lrt -o rdkafka_example \   ../src/librdkafka.a

 

ld: Unsatisfied symbol "spinlock(lock*)" in file ../src/librdkafka.a[rdkafka.o]
ld: Unsatisfied symbol "atomic_lock_in_use" in file ../src/librdkafka.a[rdkafka.o]
ld: Unsatisfied symbol "spinunlock(lock*)" in file ../src/librdkafka.a[rdkafka.o]
ld: Unsatisfied symbol "atomic_op_lock" in file ../src/librdkafka.a[rdkafka.o]

 

I was brathered this problem some day.hope some help!

 

thinks

 

 

8 REPLIES 8
Dennis Handly
Acclaimed Contributor

Re: troubles building librdkafka

>aCC ... -mt -lpthread -lrt -bdynamic -o librdkafka.so.1

 

Change -bdynamic to just -b.

dongfang
Visitor

Re: troubles building librdkafka

change to -b, but no effect. 

 

for test, I create a simple test code, like:

 

//-------------------------------------Test code begin ------------------------------------------
#ifndef _KERNEL
#define _KERNEL
#endif
#include <sys/spinlock.h>

 

int main (int argc, char **argv)

{
       printf("spinlock test\n");

      int kk = 0;
       lock_t t;
      spinlock(&t);

     

      return 0;

}

 

//-------------------------------------Test code end ------------------------------------------

 

and compile, the same thing is occur:

 

----------------------------------------- compile begin -----------------------------------------------------

aCC -I../src -mt -D_INCLUDE__STDC__ -D_INCLUDE_POSIX4_SOURCE -D__HP_NO_STRING_OVERLOADS -D_INCLUDE_POSIX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_INCLUDE_HPUX_SOURCE -D_HPUX_SOURCE -D__STDC__ -D_PROTOTYPES rdkafka_example.c -o rdkafka_example \
-mt -lpthread -lrt
ld: Unsatisfied symbol "spinlock(lock*)" in file rdkafka_example.o

----------------------------------------- compile end -----------------------------------------------------

 

here whether we need linke some library about spinlock? 

 

 

 

 

Dennis Handly
Acclaimed Contributor

Re: troubles building librdkafka, no spinlocks

>ld: Unsatisfied symbol "spinlock(lock*)"

 

Ah, these are C++ mangled names.  Why are you developing with aC++?

The header file <sys/spinlock.h> hasn't been C++ified.

 

You could try doing:

#ifdef __cplusplus

extern "C" {

#endif

#include <sys/spinlock.h>

#ifdef __cplusplus
}   // extern "C"
#endif

dongfang
Visitor

Re: troubles building librdkafka

here likely exist some  conflict define, when I use the extern "C" define, some happen!

 

code:
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/spinlock.h>

#ifdef __cplusplus
} // extern "C"
#endif

 

compile error:

 

"/usr/include/sys/kern_svcs.h", line 58: error #2338: more than one instance
of overloaded function "strtol" has "C" linkage
extern long strtol __((const char *));
^

"/usr/include/sys/kern_svcs.h", line 80: error #2338: more than one instance
of overloaded function "sleep" has "C" linkage
extern int sleep __((void *, int));
^

"/usr/include/sys/kern_svcs.h", line 93: error #2338: more than one instance
of overloaded function "sprintf" has "C" linkage
extern int sprintf __((char *str,int len,const char *fmt, ...));
^

 

oh, for schedule pressure, I replace spinlock with pthread_mutex, and it's work.

 

Dennis Handly
Acclaimed Contributor

Re: troubles building librdkafka, no spinlocks

>here likely exist some  conflict define, when I use the extern "C" define, some happen!

>#define _KERNEL

 

Most likely it is illegal for you to define _KERNEL when you are developing for user space.

 

 

dongfang
Visitor

Re: troubles building librdkafka

if don't define _KERNEL, then can't refer spinlock struct.

Dennis Handly
Acclaimed Contributor

Re: troubles building librdkafka, no spinlocks

>if don't define _KERNEL, then can't refer spinlock struct.

 

Then it isn't available for user space.

I just took a look and there are no man pages nor are there any library routines to support this.

Just some internal ones for libpthread.

damienwei
Occasional Visitor

Re: troubles building librdkafka

I know this topic would be a bit old for you. However, if you can help would be very appreciated.

I am currently building the librdkafka for my HPUX as well, however, I am not even able to rebuild the library. My system does not have bash, mklove, cmake, so I can not generated the required config.h & Makefile.config. 

Just wondering how did you generate the config.h & Makefile.config? are you able to share your config.h & Makefile.config?

 

Regards,