As oleg_g hints towards you are mixing preprocessor commands (#define) and c++ typedef
The preprocessor directives (#define etc.) are processed before the parser processes the resulting code. When you typedef ber_tag_t the preprocessor commands will never know of this and instead you need to #define a variable to indicate the type is defined.:
#if HAVE_LBER_H
#include <lber.h>
#if defined(HPUX) && !defined(_LBER_TYPES_H)
#ifndef DEFINED_BER_TAG_T
#define DEFINED_BER_TAG_T
typedef unsigned long ber_tag_t;
typedef int ber_int_t;
#endif
#endif
To clarify; preprocessor directives see only of other preprocessor variables as your code has not yet been interpreted at this point.
EDIT:
I should also mention it may be beneficial to lay out your code in a way to avoid the need of this if possible. For example using a separate common header in which the inclusion and type are protected by include guards for example.