5. Compilation ( Makefiles )
Prev | Chapter 6. Plug-ins development | Next

## 5. Compilation ( Makefiles )

You can download plugins skeletons here .

Following is a Makefile that compiles a plug-in :

     # Update the line below according to the tulip installation directory you choosed
    TULIP_DIR=/usr/local/bin
    TULIP_CONFIG=$(TULIP_DIR)/tulip-config
    TULIP_VERSION=$(shell ${TULIP_CONFIG} --version)
    LIB_EXTENSION=$(shell ${TULIP_CONFIG} --pluginextension)

    # To limit, crash problems when loading a plugin library
    # Tulip only load those whose names end with a compatible version number
    TARGET= libmyalgorithm-$(TULIP_VERSION).$(LIB_EXTENSION)

    # a plugin library may contain more than one algorithm
    # so you can have several source files on the line below
    SRCS = MyGeneralAlgorithm.cpp

    CXX=g++
    CXXFLAGS = -O3 -Wall -DNDEBUG `${TULIP_CONFIG} --cxxflags --plugincxxflags`
    LDFLAGS=  `${TULIP_CONFIG} --pluginldflags` `${TULIP_CONFIG} --libs`

    OBJS=$(SRCS:.cpp=.o)

    DEPS=$(SRCS:.cpp=.d)

    all: $(TARGET)

    $(TARGET): $(OBJS)
    	$(CXX) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)

    clean :
    	-rm -f $(TARGET) *.o *.d

    install: all
    	install $(TARGET) `${TULIP_CONFIG} --pluginpath`

    %.d: %.cpp
    	$(CXX) -M $(CXXFLAGS) $< \
    	| sed 's!\($*\)\.o[ :]*!\1.o $@ : !g' > $@; \
    	 [ -s $@ ] 2>/dev/null || rm $@

    -include $(DEPS)

Procedure 6.1. Compile and install your plugin

1.     [user@localhost ]$ make

   Type make in a terminal.

2.      [user@localhost ]$ make install

   Type make install in a terminal. Be careful that you may need root privileges to do this.

3.     [user@localhost ]$ make clean

   'make clean', will remove all generated files (libraries, *.o , ...)

Prev | Up | Next
4. Export plug-ins | Home | Chapter 7. Tulip graph format