FYI: Solved a dynamic linking loader issues with iptables,libiptc and perl

Jesper Dangaard Brouer hawk at
Mon Jul 10 13:52:03 CEST 2006

Hi Google

(This is a weird message, as I already have solved my problem... When I
searhed google I only found questions about this issue and no answers.
Thus, this post will provide an answer)

The error message I experinced was:
  Couldn't load target `standard':/usr/local/lib/iptables/ undefined symbol: register_target

This issue is caused when loading a dynamic library via ldopen(3). The
problem here is that the loaded library cannot resolve/find external
symbol "register_target" which is defined in iptables.o.

The reason this error occured, in my case, was that I also loaded the
library containing iptables.o dynamically (through perl).  The problem
with this is that the default behavior of ldopen(3) is NOT to export
symbols defined in the library (default flag RTLD_LOCAL).  Thus, the
solution was to set the flag RTLD_GLOBAL when loading the library.

>From man dlopen(3):
  "... RTLD_GLOBAL may be or'ed into flag, in which case the external
  symbols defined in the library will be made available for symbol
  resolution of subsequently loaded libraries."

With perl and DynaLoader, this RTLD_LOCAL flag is set by defining:
  sub dl_load_flags { 0x01 }

(What am I doing: I'm interfacing with libiptc and iptables do_command
from Perl (p.s. I hate perl XS code... but now it finally works...))

Med venlig hilsen / Best regards
   Jesper Brouer
   ComX Networks A/S
   Linux Network developer
   Cand. Scient Datalog / MSc.
   Author of

Questions found via Google...

"About the iptc library":
  This post, has experinced the problem I describe...

"Compilation problem??":
  This post, he simply need to compile with option "-rdynamic" or "--export-dynamic".

More information about the netfilter-devel mailing list