Search code examples
c++makefilegnu-makelibxml2opendds

How to include libxml2 library on GNUMakefile


I recently try to include libxml2 on my OpenDDS c++ project.

But, I don't know the way how to include this library on GNUMakefile.

How can I include libxml2 on this GNUmake file?

Also, I have tried to add command on GNUMakefile like this.

LIB = /usr/local/xml/lib

But, still doesn't work.

My GNUMakefile is Here:

    MAKEFILE         = GNUmakefile.DDS_Messenger_Publisher
    DEPENDENCY_FILE  = .depend.DDS_Messenger_Publisher
    BIN_UNCHECKED    = publisher

    LIB_PREFIX      ?= lib

    TAO_ROOT  ?= $(ACE_ROOT)/TAO

    FILES = \
      publisher.cpp \
      Writer.cpp


    LIBPATHS := . "$(ACE_ROOT)/lib" "../../../lib"

    #----------------------------------------------------------------------------
    #       Include macros and targets
    #----------------------------------------------------------------------------
    LDLIBS = -lDDS_Messenger_Idl -lOpenDDS_Shmem -lOpenDDS_Rtps_Udp -lOpenDDS_Rtps -lOpenDDS_Multicast -lOpenDDS_Udp -lOpenDDS_Tcp -lOpenDDS_InfoRepoDiscovery -lOpenDDS_Dcps -lTAO_BiDirGIOP -lTAO_PI -lTAO_CodecFactory -lTAO_PortableServer -lTAO_AnyTypeCode -lTAO -lACE
    TAO_IDL = $(ACE_ROOT)/bin/tao_idl
    TAO_IDL_DEP = $(ACE_ROOT)/bin/tao_idl$(EXEEXT)
    TAO_IDLFLAGS = -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT)$(if $(ARCH), -g $(call ADD_QUOTE,$(call ADD_ARCH,$(ACE_ROOT)/bin/ace_gperf)))

    PRJ_TYPE = rtp

    ifeq ($(INSBIN),.)
      ifeq ($(CURDIR),)
        ifeq ($(PWD),)
          PWD=$(shell pwd)
        endif
      else
        PWD=$(CURDIR)
      endif
      INSBIN = $(PWD)
    endif
    OUTPUT_DIRECTORY = $(if $(ARCH),./$(ARCH))

    include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU

    include $(DDS_ROOT)/rules.dds.GNU

    include $(TAO_ROOT)/rules.tao.GNU
...
...

Solution

  • I finally solved this problem.

    just added

    LIBXML_ROOT ?= /usr/local/xml

    LDLIBS = -lDDS_Messenger_Idl -lOpenDDS_Shmem ... -L$(LIBXML_ROOT)/lib -lxml2
    ...
    CPPFLAGS     += -I$(ACE_ROOT) -I$(TAO_ROOT) -I../../.. -I$(LIBXML_ROOT)/include/libxml2