IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

deux makefile: en faire un seul


Sujet :

C++

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    60
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 60
    Points : 34
    Points
    34
    Par défaut deux makefile: en faire un seul
    Bonsoir,

    Voici mon souci j'ai un premier makefile comme celui-ci (pour compiler MyGeneralAlgorithm.cpp):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
     
    # Update the line below according to the tulip installation directory you choosed
    TULIP_DIR=/home/docky/Bureau/tulip-3.2.1
    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= libTest-$(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)

    puis un deuxième comme celui-ci (pour compiler BayesianNetwork.cpp):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    # Sample Makefile to compile ProBT examples.
    # Probayes, 2007
    # 
    # Targets:
     
    PROBT_INCLUDE=include
    PROBT_LIB=lib
     
    CXX=g++ -Wall
     
    # Environment variable containing the path to the dynamically loaded libraries
    ifeq ($(shell uname -s),Darwin)
    	# libraries for Mac OS X
    	DLL_PATH_VAR := DYLD_LIBRARY_PATH
    else
    	# libraries for Linux
    	DLL_PATH_VAR := LD_LIBRARY_PATH
    endif
     
    all: show
     
    # Compiling a C++ source file: add the path to the ProBT includes, the path to the ProBT libraries,
    # and link with the ProBT libraries.
    bayesian_network: BayesianNetwork.cpp
    	$(DLL_PATH_VAR)=$(PROBT_LIB):${$(DLL_PATH_VAR)} $(CXX) -I$(PROBT_INCLUDE) BayesianNetwork.cpp -L$(PROBT_LIB) -lspl -o bayesian_network
     
    # Running an example: adjust the LD_LIBRARY_PATH environment variable to point to the directory
    # containing the ProBT libraries.
    run: bayesian_network
    	@echo ">>> Running the example. It will output bayesian_network.fig (figure in in xfig format)."
    	$(DLL_PATH_VAR)=$(PROBT_LIB):${$(DLL_PATH_VAR)} ./bayesian_network
     
    show: run
    	xfig bayesian_network.fig
     
    .PHONY: run show
    Mon souhait c'est d'intégrer le code contenu dans BayesianNetwork.cpp dans MyGeneralAlgorithm.cpp. Ainsi les dépendances pour BayesianNetwork doivent être maintenant paramétrées dans MyGeneralAlgorithm et ainsi dans son makefile. Malheureusement, je n'arrive pas à faire un mix des deux et notamment au niveau de la ligne $(TARGET):
    j'ai pour l'instant mis cela mais cela ne marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $(TARGET): $(OBJS)
    	$(DLL_PATH_VAR)=$(PROBT_LIB):${$(DLL_PATH_VAR)} $(CXX) -I$(PROBT_INCLUDE) $(OBJS) -L$(PROBT_LIB) -lspl -o $@ $(LDFLAGS) $(LIBS)
    Je suis loin d'être un expert en makefile c'est pour cela que je vous sollicite.

    Merci d'avance

  2. #2
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Bonjour,
    As-tu jeté un coup d'oeil à ce tutoriel assez complet : Introduction à Makefile ?

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    60
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 60
    Points : 34
    Points
    34
    Par défaut
    Oui mais dans ce tuto il n'est pas question de -I ou de -L, du coup je ne vois pas comment les positionner.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 20/01/2015, 16h24
  2. Réponses: 1
    Dernier message: 01/03/2009, 16h53
  3. peut on faire deux actions à partir d'une seule form
    Par sniper_marra dans le forum Langage
    Réponses: 3
    Dernier message: 15/08/2008, 19h20
  4. Faire une seule ligne avec deux echo
    Par d10g3n dans le forum Shell et commandes GNU
    Réponses: 8
    Dernier message: 23/06/2008, 20h11
  5. enregistrer deux variable différente dans un seul champs
    Par developpeur_mehdi dans le forum Bases de données
    Réponses: 7
    Dernier message: 07/03/2004, 23h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo