La librairie est séparer en plusieurs dossier avec d'un côté les .hh, d'un autre les .cc, d'un autre les .o et pour finir librts.a les 4 dans des dossier séparer.
Voici mon message d'erreur
avr-g++ -o TopMain Controller.o OnOff.o Top.o TopControllers.o interact.o TopMain.o
/usr/bin/avr-ld : TopControllers.o : dans la fonction « __static_initialization_and_destruction_0(int, int) » :
TopControllers.cc:(.text+0x32) : référence indéfinie vers « UMLRTController::UMLRTController(char const*) »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTQueue::~UMLRTQueue() » :
TopControllers.cc:(.text._ZN10UMLRTQueueD2Ev[_ZN10UMLRTQueueD5Ev]+0x14) : référence indéfinie vers « UMLRTMutex::~UMLRTMutex() »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTController::~UMLRTController() » :
TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTController »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTController »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x30) : référence indéfinie vers « UMLRTPriorityMessageQueue::~UMLRTPriorityMessageQueue() »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x3a) : référence indéfinie vers « UMLRTPriorityMessageQueue::~UMLRTPriorityMessageQueue() »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTController::~UMLRTController() » :
TopControllers.cc:(.text._ZN15UMLRTControllerD0Ev[_ZN15UMLRTControllerD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « Capsule_interact::~Capsule_interact() » :
TopControllers.cc:(.text._ZN16Capsule_interactD2Ev[_ZN16Capsule_interactD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « Capsule_interact::~Capsule_interact() » :
TopControllers.cc:(.text._ZN16Capsule_interactD0Ev[_ZN16Capsule_interactD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « main » :
TopMain.cc:(.text+0x20) : référence indéfinie vers « UMLRTMain::setArgs(int, char* const*) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x2a) : référence indéfinie vers « UMLRTCapsuleToControllerMap::setDefaultSlotList(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x2c) : référence indéfinie vers « UMLRTMain::targetStartup() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x46) : référence indéfinie vers « UMLRTController::spawn() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x48) : référence indéfinie vers « UMLRTMain::mainLoop() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x56) : référence indéfinie vers « UMLRTMain::targetShutdown(bool) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x62) : référence indéfinie vers « UMLRTController::join() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x66) : référence indéfinie vers « UMLRTMain::targetShutdown(bool) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « __static_initialization_and_destruction_0(int, int) » :
TopMain.cc:(.text+0xb8) : référence indéfinie vers « UMLRTSignalElement::UMLRTSignalElement() »
/usr/bin/avr-ld : TopMain.cc:(.text+0xd6) : référence indéfinie vers « UMLRTSignalElementPool::UMLRTSignalElementPool(UMLRTSignalElement*, unsigned int, unsigned int) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x10a) : référence indéfinie vers « UMLRTMessagePool::UMLRTMessagePool(UMLRTMessage*, unsigned int, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessage::UMLRTMessage() » :
TopMain.cc:(.text._ZN12UMLRTMessageC2Ev[_ZN12UMLRTMessageC5Ev]+0x52) : référence indéfinie vers « UMLRTSignal::UMLRTSignal() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessagePool::~UMLRTMessagePool() » :
TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTMessagePool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTMessagePool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0x22) : référence indéfinie vers « UMLRTPool::~UMLRTPool() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessagePool::~UMLRTMessagePool() » :
TopMain.cc:(.text._ZN16UMLRTMessagePoolD0Ev[_ZN16UMLRTMessagePoolD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessage::~UMLRTMessage() » :
TopMain.cc:(.text._ZN12UMLRTMessageD2Ev[_ZN12UMLRTMessageD5Ev]+0x14) : référence indéfinie vers « UMLRTSignal::~UMLRTSignal() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElementPool::~UMLRTSignalElementPool() » :
TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTSignalElementPool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTSignalElementPool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x22) : référence indéfinie vers « UMLRTPool::~UMLRTPool() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElementPool::~UMLRTSignalElementPool() » :
TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD0Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElement::~UMLRTSignalElement() » :
TopMain.cc:(.text._ZN18UMLRTSignalElementD2Ev[_ZN18UMLRTSignalElementD5Ev]+0x14) : référence indéfinie vers « UMLRTMutex::~UMLRTMutex() »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::Capsule_Controller(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
Controller.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::bindPort(bool, int, int) » :
Controller.cc:(.text+0x132) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::unbindPort(bool, int, int) » :
Controller.cc:(.text+0x18c) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : Controller.cc:(.text+0x1aa) : référence indéfinie vers « UMLRTFrameService::disconnectPort(UMLRTCommsPort const*, int) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::transitionaction_____CheakButton(UMLRTMessage const*) » :
Controller.cc:(.text+0x31a) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x326) : référence indéfinie vers « digitalRead »
/usr/bin/avr-ld : Controller.cc:(.text+0x354) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x35c) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : Controller.cc:(.text+0x37a) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x382) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::state_____VoidLoop(UMLRTMessage const*) » :
Controller.cc:(.text+0x42c) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : Controller.o : dans la fonction « instantiate_Controller(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
Controller.cc:(.text+0x4fe) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : Controller.cc:(.text+0x508) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : Controller.o : dans la fonction « UMLRTMessage::getSignalId() const » :
Controller.cc:(.text._ZNK12UMLRTMessage11getSignalIdEv[_ZNK12UMLRTMessage11getSignalIdEv]+0x14) : référence indéfinie vers « UMLRTSignal::getId() const »
/usr/bin/avr-ld : Controller.o:(.rodata._ZTV18Capsule_Controller[_ZTV18Capsule_Controller]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : Controller.o:(.rodata._ZTV18Capsule_Controller[_ZTV18Capsule_Controller]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::~Capsule_Controller() » :
Controller.cc:(.text._ZN18Capsule_ControllerD2Ev[_ZN18Capsule_ControllerD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::~Capsule_Controller() » :
Controller.cc:(.text._ZN18Capsule_ControllerD0Ev[_ZN18Capsule_ControllerD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::CheakButton() const » :
OnOff.cc:(.text+0x4a) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x9c) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::TurnOff() const » :
OnOff.cc:(.text+0xda) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x12c) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::TurnOn() const » :
OnOff.cc:(.text+0x16a) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x1bc) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::CheakButton() const » :
OnOff.cc:(.text+0x22c) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x27e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::TurnOff() const » :
OnOff.cc:(.text+0x2bc) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x30e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::TurnOn() const » :
OnOff.cc:(.text+0x34c) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x39e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::Capsule_Top(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
Top.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::entryaction_____Running(UMLRTMessage const*) » :
Top.cc:(.text+0x266) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::transitionaction_____Initial(UMLRTMessage const*) » :
Top.cc:(.text+0x298) : référence indéfinie vers « pinMode »
/usr/bin/avr-ld : Top.cc:(.text+0x29e) : référence indéfinie vers « pinMode »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::state_____Running(UMLRTMessage const*) » :
Top.cc:(.text+0x31a) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : Top.o : dans la fonction « instantiate_Top(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
Top.cc:(.text+0x3f2) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : Top.cc:(.text+0x44a) : référence indéfinie vers « UMLRTFrameService::connectPorts(UMLRTCommsPort const*, unsigned int, UMLRTCommsPort const*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x47c) : référence indéfinie vers « UMLRTFrameService::createBorderPorts(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x4e2) : référence indéfinie vers « UMLRTFrameService::createBorderPorts(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x51c) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : Top.o:(.rodata._ZTV11Capsule_Top[_ZTV11Capsule_Top]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : Top.o:(.rodata._ZTV11Capsule_Top[_ZTV11Capsule_Top]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::~Capsule_Top() » :
Top.cc:(.text._ZN11Capsule_TopD2Ev[_ZN11Capsule_TopD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::~Capsule_Top() » :
Top.cc:(.text._ZN11Capsule_TopD0Ev[_ZN11Capsule_TopD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::Capsule_interact(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
interact.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::bindPort(bool, int, int) » :
interact.cc:(.text+0x132) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::unbindPort(bool, int, int) » :
interact.cc:(.text+0x18c) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : interact.cc:(.text+0x1aa) : référence indéfinie vers « UMLRTFrameService::disconnectPort(UMLRTCommsPort const*, int) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::entryaction_____Running(UMLRTMessage const*) » :
interact.cc:(.text+0x31a) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : interact.cc:(.text+0x322) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::transitionaction_____TurnOff(UMLRTMessage const*) » :
interact.cc:(.text+0x366) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : interact.cc:(.text+0x374) : référence indéfinie vers « digitalWrite »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::transitionaction_____TurnOn(UMLRTMessage const*) » :
interact.cc:(.text+0x3b4) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : interact.cc:(.text+0x3c2) : référence indéfinie vers « digitalWrite »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::state_____Running(UMLRTMessage const*) » :
interact.cc:(.text+0x4d8) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : interact.o : dans la fonction « instantiate_interact(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
interact.cc:(.text+0x5c4) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : interact.cc:(.text+0x5ce) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : interact.o:(.rodata._ZTV16Capsule_interact[_ZTV16Capsule_interact]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : interact.o:(.rodata._ZTV16Capsule_interact[_ZTV16Capsule_interact]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
collect2: error: ld returned 1 exit status
make: *** [Makefile:22 : TopMain] Erreur 1
Tu dois spécifier le répertoire dans lequel se trouve le fichier librts.a avec l'option "-L" et include cette bibliothèque avec l'option "-lrts" (qui va rechercher un fichier librts.a ou librts.so).
En supposant que librts.a est dans le répertoire lib à côté du répertoire include indiqué à la ligne avec SOURCE_UMLRTS:
Si par exemple, tu mets -ltoto, le compilateur va rechercher un fichier libtoto.a dans les répertoires que tu auras spécifiés juste avant sur la ligne de commande avec "-L".
Le morceau de makefile que j'ai donné ne remplace pas la ligne avec SOURCE_UMLRTS, il commence juste en dessous et définit une nouvelle variable pour la cible TopMain (l'exécutable, pas le fichier .o), donc ce qui compilait avant devrait toujours compiler.
Note que tu peux aussi passer directements les bibliothèques sans -L et -l (CMake fait souvent ça). C'est pratique si tu sais qu'une bibliothèque est toujours au même endroit par exemple quand elle est directement dans ton dépôt
cc -o monexecutable ./deps/mylib.a
git is great because Linus did it, mercurial is better because he didn't.
Si par exemple, tu mets -ltoto, le compilateur va rechercher un fichier libtoto.a dans les répertoires que tu auras spécifiés juste avant sur la ligne de commande avec "-L".
Si on tenait l'animal qui a eu cette idée stupide, il y a quelques décennies....
Conseil : ne pas se laisser impressionner par la quantité de messages.
En voyant le premier, j'ai l'impression qu'il y a une embrouille dans ton Makefile
Normalement, un fichier .o, c'est un "module objet", produit à partir du source. Compilé séparément. Et ensuite les modules objets sont collés entre eux par le linker.
tu lances le compilateur SANS L'OPTION "-c" qui demande de ne faire que la compilation.
Donc il essaie de faire l'édition des liens tout de suite (et de mettre l'exécutable dans un .o).
A l'exécution,
avr-g++ -o TopMain.o TopMain.cc -Imachintruc
/usr/bin/avr-ld : /tmp/ccabfaWb.o : dans la fonction « main » :
TopMain.cc:(.text+0x20) : référence indéfinie vers « UMLRTMain::setArgs(int, char* const*) »
on voit que ça a lancé le linker (avr-ld), alors que c'est pas le moment.
Que les références soient indéfinies à ce moment-là, c'est pas faux, mais c'est juste un épiphénomène. Le problème, c'est d'avoir lancé l'édition des liens quand il faut pas en oubliant "-c".
-----------
Au passage, tu simplifierais sans doute ton Makefile en utilisant les bonnes variables
CXX pour le compilateur C++ (et pas CC)
CPPFLAGS pour le préprocesseur (les includes)
CXXFLAGS pour ses options (et pas FLAGS)
LDFLAGS pour les options du link
LDLIBS pour les bibliothèques
etc.
sachant qu'il y a dejà des macros, des règles par défaut etc intégrées à Make
Autant les utiliser dans le sens de la marche, plutôt que se compliquer la vie en tordant les options destinées à C (je sais, les Makefile distribués avec les arduinosont été écrits par des pignoufs qui ne savent pas utiliser Make correctement....)
EDIT: Grillé par Michel. J'ai plus confiance en son Makefile qu'en le mien (surtout pour le linker), mais l'idée est la même, et dans tous les cas: se souvenir que LDFLAGS et LDLIBS ne vont pas au même endroit. C'est pour ça qu'en "standard" (de gnumake) c'est fait en 2 variables distinctes.
Bon, j'ai relu quelques trucs sur ldlibs/ldflags pour gnu make
Apparemment, -I et -L vont dans LDLIBS. Ce qui concerne les bibliothèques à "linker". Comme son nom l'indique.
LDFLAGS, C'est pour les options genre --go-to-hell et -Wmind-the-step
Le truc c'est que LDFLAGS est expansé bien plus à gauche dans la commande. Avant les modules objets, alors que LDLIBS c'est après. Et avec le linker, l'ordre est important.
Mon erreur (j'ai déja été emmerdé avec ca sans bien comprendre - je contournais par une commande explicite) c'était de faire un parallèle entre -I (localisation des includes) et -L (localisation et désignation des bibliothèques). Ça fait bien 20 ans que j'aurais du clarifier, mais il n'est jamais trop tard.
Comme quoi y a pas que les contributeurs d'arduino qui bossent comme des gougnaffiers.
Pourquoi ? Parce que les packagers et utilisateur peuvent avoir envie de passer leur propre macros pour rajouter/changer des choses :
make CFLAGS=-g
Or, dans ce cas j'efface VARDIR qui peut-être nécessaire pour la compilation de mon projet.
Pour ce faire, il faudrait toujours laisser CFLAGS, LDFLAGS (et LDLIBS pour GNU make) en tant qu'option à l'utilisateur. À la place, on peut passer par des variables intermédiaires et des variables par défaut qui peuvent être changées sans problèmes :
# Ok, n'influe pas les prérequis pour compiler
CFLAGS= -O3
# Ok, variables censées être privées
PROJ_CFLAGS= -I ./deps/
PROJ_LDFLAGS= -L ./deps -l mysuperdependency
foo: ${OBJECTS}
${CC} ${PROJ_CFLAGS} ${CFLAGS} -o $@ ${OBJECTS} ${PROJ_LDFLAGS} ${LDFLAGS}
Notez aussi que CFLAGS/LDFLAGS apparaissent après leur homonymes PROJ_ pour pouvoir les « annuler ».
git is great because Linus did it, mercurial is better because he didn't.
Ok ! Il y a pas mal de choses que je comprend mieux, mais j'ai quand même quelques questions. Make -p me dit que LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH). Es ce que cela veut dire que LDLIBS n'est utilisé nul part ? Aussi, comment le makefile arrive à "trouver" une commande pour compiler les .o ? Cela se fait avec les options par défaut ? Dernière interrogation, à quoi sert .PHONY ?
Dans tout les cas j'ai toujours des références indéfinie vers la lib (les 3 premières ligne ci dessous). Es ce que cela viens de la possible non utilisation de LDLIBS ?
avr-g++ -Wall -Wextra -std=c++17 -I/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino -I/usr/share/arduino/hardware/archlinux-arduino/avr/variants/standard -I/home/breizh/Documents/Cours/stage/Sujet/uml-rt-port-for-arduino/umlrt-arduino_lib/include -o TopMain OnOff.o interact.o Controller.o Top.o TopControllers.o TopMain.o
/usr/bin/avr-ld : TopControllers.o : dans la fonction « __static_initialization_and_destruction_0(int, int) » :
TopControllers.cc:(.text+0x32) : référence indéfinie vers « UMLRTController::UMLRTController(char const*) »
Dans tout les cas, merci beaucoup, j'ai l'impression d'avancer !
avec LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH . Même avec LINK.cc, LDLIBS est utilisé dans la règle "%: %.cc"
Donc tu devrais mettre:
TopMain: $(OBJ)
Sans aucune commande en dessous, pour utiliser la règle interne.
Par défaut les cibles, la partie avant les : sont des fichiers que make recherche pour savoir s'il doit les reconstruire s'ils sont plus anciens que les prérequis (la partie après les : ). Si tu places un nom de cible dans .PHONY, cette cible ne sera plus rattachée à un fichier et sera reconstruite même si un fichier du même nom plus récent que tous les prérequis existent.
Si on le compile par "make" avec les options par défaut
$ make a
g++ a.cc -o a
$ ./a
Hello, folks
Jusque là, tout va bien.
Maintenant si on demande d'abord d'obtenir le .o
$ make a.o
g++ -c -o a.o a.cc
ça va encore bien.
et si on demande ensuite d'avoir l'exécutable
$ make a
cc a.o -o a
/usr/bin/ld: a.o: in function `main':
a.cc:(.text+0xe): undefined reference to `std::cout'
(etc)
bim boum badaboum, parce que la commande make "croit" qu'il faut faire l'éditions des liens de fichiers .o avec la bibliothèque standard C. Et non C++.
We're deep in the sh*t. On ne peut pas compter sur la règle interne
est que il tente de compiler avec cc, or, pour compiler sous arduino j'ai besoin de avr-g++ ou avr-gcc. En plus du problème lié au c++ du coup
michelbillaud a écrit:
Une idée qui vient de me tomber dessus (aïeeeuuu), c'est de mettre la ligne
LINK.o = $(LINK.cc)
dans le Makefile d'un projet en C++
Ou juste changer la valeur de la variable $(CC):
CC=avr-g++
Ta règle avec OnOff a des lignes vides en dessous, vérifie qu'aucune de ces lignes ne commence par une tabulation, parce que ça remplacerait la règle interne.
OK. Pour la règle avec OnOff c'etais effectivement un tab caché
Pour le reste en faisant CC=avr-g++ ou LINK.o = $(LINK.cc) j'ai
avr-g++ TopMain.o OnOff.o interact.o Controller.o Top.o TopControllers.o -L/home/breizh/Documents/Cours/stage/Sujet/uml-rt-port-for-arduino/umlrt-arduino_lib//lib/arduino.avr-gcc -lrts -o TopMain
/usr/bin/avr-ld : TopMain la section «.text» ne va pas s'adapter à la région «text»
/usr/bin/avr-ld : l'adresse 0x8145f3 de TopMain de la section «.bss» n'est pas dans la région «data»
/usr/bin/avr-ld : l'adresse 0x8145f3 de TopMain de la section «.bss» n'est pas dans la région «data»
/usr/bin/avr-ld : la VMA de la section .bss englobe l'espace d'adressage
/usr/bin/avr-ld : la région « text » est débordée de 168504 octets
puis des millions de référence indéfinie.
Et en faisant
TopMain: $(OBJ)
$(LINK.cc) -o $@ $^
j'ai beaucoup moins de référence indéfinie
avr-g++ -Wall -Wextra -std=c++17 -I/usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino -I/usr/share/arduino/hardware/archlinux-arduino/avr/variants/standard -I/home/breizh/Documents/Cours/stage/Sujet/uml-rt-port-for-arduino/umlrt-arduino_lib//include -o TopMain OnOff.o interact.o Controller.o Top.o TopControllers.o TopMain.o
/usr/bin/avr-ld : TopControllers.o : dans la fonction « __static_initialization_and_destruction_0(int, int) » :
TopControllers.cc:(.text+0x32) : référence indéfinie vers « UMLRTController::UMLRTController(char const*) »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTQueue::~UMLRTQueue() » :
TopControllers.cc:(.text._ZN10UMLRTQueueD2Ev[_ZN10UMLRTQueueD5Ev]+0x14) : référence indéfinie vers « UMLRTMutex::~UMLRTMutex() »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTController::~UMLRTController() » :
TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTController »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTController »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x2e) : référence indéfinie vers « UMLRTTimerQueue::~UMLRTTimerQueue() »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x38) : référence indéfinie vers « UMLRTPriorityMessageQueue::~UMLRTPriorityMessageQueue() »
/usr/bin/avr-ld : TopControllers.cc:(.text._ZN15UMLRTControllerD2Ev[_ZN15UMLRTControllerD5Ev]+0x42) : référence indéfinie vers « UMLRTPriorityMessageQueue::~UMLRTPriorityMessageQueue() »
/usr/bin/avr-ld : TopControllers.o : dans la fonction « UMLRTController::~UMLRTController() » :
TopControllers.cc:(.text._ZN15UMLRTControllerD0Ev[_ZN15UMLRTControllerD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « main » :
TopMain.cc:(.text+0x20) : référence indéfinie vers « UMLRTMain::setArgs(int, char* const*) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x2a) : référence indéfinie vers « UMLRTCapsuleToControllerMap::setDefaultSlotList(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x2c) : référence indéfinie vers « UMLRTMain::targetStartup() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x46) : référence indéfinie vers « UMLRTController::spawn() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x48) : référence indéfinie vers « UMLRTMain::mainLoop() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x56) : référence indéfinie vers « UMLRTMain::targetShutdown(bool) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x62) : référence indéfinie vers « UMLRTController::join() »
/usr/bin/avr-ld : TopMain.cc:(.text+0x66) : référence indéfinie vers « UMLRTMain::targetShutdown(bool) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « __static_initialization_and_destruction_0(int, int) » :
TopMain.cc:(.text+0xb8) : référence indéfinie vers « UMLRTSignalElement::UMLRTSignalElement() »
/usr/bin/avr-ld : TopMain.cc:(.text+0xd6) : référence indéfinie vers « UMLRTSignalElementPool::UMLRTSignalElementPool(UMLRTSignalElement*, unsigned int, unsigned int) »
/usr/bin/avr-ld : TopMain.cc:(.text+0x10a) : référence indéfinie vers « UMLRTMessagePool::UMLRTMessagePool(UMLRTMessage*, unsigned int, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessage::UMLRTMessage() » :
TopMain.cc:(.text._ZN12UMLRTMessageC2Ev[_ZN12UMLRTMessageC5Ev]+0x52) : référence indéfinie vers « UMLRTSignal::UMLRTSignal() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessagePool::~UMLRTMessagePool() » :
TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTMessagePool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTMessagePool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN16UMLRTMessagePoolD2Ev[_ZN16UMLRTMessagePoolD5Ev]+0x22) : référence indéfinie vers « UMLRTPool::~UMLRTPool() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessagePool::~UMLRTMessagePool() » :
TopMain.cc:(.text._ZN16UMLRTMessagePoolD0Ev[_ZN16UMLRTMessagePoolD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTMessage::~UMLRTMessage() » :
TopMain.cc:(.text._ZN12UMLRTMessageD2Ev[_ZN12UMLRTMessageD5Ev]+0x14) : référence indéfinie vers « UMLRTSignal::~UMLRTSignal() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElementPool::~UMLRTSignalElementPool() » :
TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0xe) : référence indéfinie vers « vtable for UMLRTSignalElementPool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x10) : référence indéfinie vers « vtable for UMLRTSignalElementPool »
/usr/bin/avr-ld : TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD2Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x22) : référence indéfinie vers « UMLRTPool::~UMLRTPool() »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElementPool::~UMLRTSignalElementPool() » :
TopMain.cc:(.text._ZN22UMLRTSignalElementPoolD0Ev[_ZN22UMLRTSignalElementPoolD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : TopMain.o : dans la fonction « UMLRTSignalElement::~UMLRTSignalElement() » :
TopMain.cc:(.text._ZN18UMLRTSignalElementD2Ev[_ZN18UMLRTSignalElementD5Ev]+0x14) : référence indéfinie vers « UMLRTMutex::~UMLRTMutex() »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::CheakButton() const » :
OnOff.cc:(.text+0x4a) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x9c) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::TurnOff() const » :
OnOff.cc:(.text+0xda) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x12c) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Base::TurnOn() const » :
OnOff.cc:(.text+0x16a) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x1bc) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::CheakButton() const » :
OnOff.cc:(.text+0x22c) : référence indéfinie vers « UMLRTOutSignal::UMLRTOutSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x27e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::TurnOff() const » :
OnOff.cc:(.text+0x2bc) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x30e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : OnOff.o : dans la fonction « OnOff::Conj::TurnOn() const » :
OnOff.cc:(.text+0x34c) : référence indéfinie vers « UMLRTInSignal::UMLRTInSignal() »
/usr/bin/avr-ld : OnOff.cc:(.text+0x39e) : référence indéfinie vers « UMLRTSignal::initialize(char const*, int, UMLRTCommsPort const*, UMLRTObject const*, ...) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::Capsule_interact(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
interact.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::bindPort(bool, int, int) » :
interact.cc:(.text+0x132) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::unbindPort(bool, int, int) » :
interact.cc:(.text+0x18c) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : interact.cc:(.text+0x1aa) : référence indéfinie vers « UMLRTFrameService::disconnectPort(UMLRTCommsPort const*, int) »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::entryaction_____Running(UMLRTMessage const*) » :
interact.cc:(.text+0x31a) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : interact.cc:(.text+0x322) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::transitionaction_____TurnOff(UMLRTMessage const*) » :
interact.cc:(.text+0x366) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : interact.cc:(.text+0x374) : référence indéfinie vers « digitalWrite »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::transitionaction_____TurnOn(UMLRTMessage const*) » :
interact.cc:(.text+0x3b4) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : interact.cc:(.text+0x3c2) : référence indéfinie vers « digitalWrite »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::state_____Running(UMLRTMessage const*) » :
interact.cc:(.text+0x4d8) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : interact.o : dans la fonction « instantiate_interact(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
interact.cc:(.text+0x5bc) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : interact.cc:(.text+0x5c6) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : interact.o : dans la fonction « UMLRTMessage::getSignalId() const » :
interact.cc:(.text._ZNK12UMLRTMessage11getSignalIdEv[_ZNK12UMLRTMessage11getSignalIdEv]+0x14) : référence indéfinie vers « UMLRTSignal::getId() const »
/usr/bin/avr-ld : interact.o:(.rodata._ZTV16Capsule_interact[_ZTV16Capsule_interact]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : interact.o:(.rodata._ZTV16Capsule_interact[_ZTV16Capsule_interact]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::~Capsule_interact() » :
interact.cc:(.text._ZN16Capsule_interactD2Ev[_ZN16Capsule_interactD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : interact.o : dans la fonction « Capsule_interact::~Capsule_interact() » :
interact.cc:(.text._ZN16Capsule_interactD0Ev[_ZN16Capsule_interactD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::Capsule_Controller(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
Controller.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::bindPort(bool, int, int) » :
Controller.cc:(.text+0x132) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::unbindPort(bool, int, int) » :
Controller.cc:(.text+0x18c) : référence indéfinie vers « UMLRTFrameService::sendBoundUnbound(UMLRTCommsPort const**, int, int, bool) »
/usr/bin/avr-ld : Controller.cc:(.text+0x1aa) : référence indéfinie vers « UMLRTFrameService::disconnectPort(UMLRTCommsPort const*, int) »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::transitionaction_____CheakButton(UMLRTMessage const*) » :
Controller.cc:(.text+0x31a) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x326) : référence indéfinie vers « digitalRead »
/usr/bin/avr-ld : Controller.cc:(.text+0x354) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x35c) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : Controller.cc:(.text+0x37a) : référence indéfinie vers « UMLRTOutSignal::send(unsigned char) const »
/usr/bin/avr-ld : Controller.cc:(.text+0x382) : référence indéfinie vers « UMLRTOutSignal::~UMLRTOutSignal() »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::state_____VoidLoop(UMLRTMessage const*) » :
Controller.cc:(.text+0x42c) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : Controller.o : dans la fonction « instantiate_Controller(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
Controller.cc:(.text+0x4f6) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : Controller.cc:(.text+0x500) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : Controller.o:(.rodata._ZTV18Capsule_Controller[_ZTV18Capsule_Controller]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : Controller.o:(.rodata._ZTV18Capsule_Controller[_ZTV18Capsule_Controller]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::~Capsule_Controller() » :
Controller.cc:(.text._ZN18Capsule_ControllerD2Ev[_ZN18Capsule_ControllerD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : Controller.o : dans la fonction « Capsule_Controller::~Capsule_Controller() » :
Controller.cc:(.text._ZN18Capsule_ControllerD0Ev[_ZN18Capsule_ControllerD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::Capsule_Top(UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) » :
Top.cc:(.text+0x56) : référence indéfinie vers « UMLRTCapsule::UMLRTCapsule(UMLRTRtsInterface const*, UMLRTCapsuleClass const*, UMLRTSlot*, UMLRTCommsPort const**, UMLRTCommsPort const**, bool) »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::entryaction_____Running(UMLRTMessage const*) » :
Top.cc:(.text+0x266) : référence indéfinie vers « UMLRTLogProtocol_baserole::log(char const*, ...) const »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::transitionaction_____Initial(UMLRTMessage const*) » :
Top.cc:(.text+0x298) : référence indéfinie vers « pinMode »
/usr/bin/avr-ld : Top.cc:(.text+0x29e) : référence indéfinie vers « pinMode »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::state_____Running(UMLRTMessage const*) » :
Top.cc:(.text+0x31a) : référence indéfinie vers « UMLRTCommsPort::role() const »
/usr/bin/avr-ld : Top.o : dans la fonction « instantiate_Top(UMLRTRtsInterface const*, UMLRTSlot*, UMLRTCommsPort const**) » :
Top.cc:(.text+0x3ee) : référence indéfinie vers « UMLRTFrameService::createInternalPorts(UMLRTSlot*, UMLRTCapsuleClass const*) »
/usr/bin/avr-ld : Top.cc:(.text+0x446) : référence indéfinie vers « UMLRTFrameService::connectPorts(UMLRTCommsPort const*, unsigned int, UMLRTCommsPort const*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x478) : référence indéfinie vers « UMLRTFrameService::createBorderPorts(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x4de) : référence indéfinie vers « UMLRTFrameService::createBorderPorts(UMLRTSlot*, unsigned int) »
/usr/bin/avr-ld : Top.cc:(.text+0x518) : référence indéfinie vers « operator new(unsigned int) »
/usr/bin/avr-ld : Top.o:(.rodata._ZTV11Capsule_Top[_ZTV11Capsule_Top]+0x10) : référence indéfinie vers « UMLRTCapsule::logMsg() »
/usr/bin/avr-ld : Top.o:(.rodata._ZTV11Capsule_Top[_ZTV11Capsule_Top]+0x12) : référence indéfinie vers « UMLRTCapsule::unexpectedMessage() const »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::~Capsule_Top() » :
Top.cc:(.text._ZN11Capsule_TopD2Ev[_ZN11Capsule_TopD5Ev]+0x22) : référence indéfinie vers « UMLRTCapsule::~UMLRTCapsule() »
/usr/bin/avr-ld : Top.o : dans la fonction « Capsule_Top::~Capsule_Top() » :
Top.cc:(.text._ZN11Capsule_TopD0Ev[_ZN11Capsule_TopD5Ev]+0x1c) : référence indéfinie vers « operator delete(void*, unsigned int) »
collect2: error: ld returned 1 exit status
make: *** [Makefile:33 : TopMain] Erreur 1
C'est surtout -ffunction-sections -fdata-sections dans CXXFLAGS et -Wl,--gc-sections dans LDFLAGS qui sont censés corriger les erreurs (les 2 premières options séparent toutes les fonctions et les variables dans leur propre section, la 3e sert à ne pas intégrer les sections inutilisées dans l'exécutable final).
Il manque également une option pour indiquer le microcontrôleur cible, par exemple: "-mmcu=atmega328p" dans CXXFLAGS et LDFLAGS.
Je ne sais pas si ça va corriger certaines références indéfinies.
ça ne cause pas de l'utilisation de bibliothèques (-l).
Du coup faut pas trop s'étonner qu'il ne trouve pas les fonctions UMLRT (il faut lire la troisième ligne) :
TopControllers.cc:(.text+0x32) : référence indéfinie vers
« UMLRTController::UMLRTController(char const*) »
Une excellente raison d'avoir des références indéfinies, parce qu'on fait appel a des trucs qui sont dans une bibliothèque qui n'est pas cités.
Les petits cochons ont mangé -lrts ?
PS: je trouve ça abominable de faire
CC=g++
parce que ça dit exactement : hé les gars, le compilateur C, c'est g++. Ce qui est faux.
Pour moi, c'est un contournement très maladroit. Imaginez le bond qu'on ferait en lisant : CC=cobol
Ce qu'on veut exprimer, c'est que pour linker des .o (LINK.o) il faut le faire avec la recette de cuisine de C++ (LINK.cc). Pas qu'on veut utiliser g++.
Donc si c'est ce qu'on veut dire, on le fait.
PS 2. Mon contournement habituel c'était
$(exec): $(objects)
$(LINK.cc) -o $@ $^
ce qui n'est pas faux, mais devait être répété pour les différents exécutables qui peuplent mes projets (tests unitaires etc).
parce que ça dit exactement : hé les gars, le compilateur C, c'est g++. Ce qui est faux.
Juste partiellement faux, il y a très peu d'éléments du C qui vont poser problème, et si tu mélanges du C et du C++, tu as déjà des sections "extern "C"" qui limite les incompatibilités. Si tu veux vraiment être puriste, pour g++ on peut juste mettre ça:
CC=gcc
LDFLAGS+=-lstdc++
pour avr-g++/avr-gcc l'option -lstdc++ n'est pas nécessaire, vu que lIbstdc++ n'existe pas, donc juste:
CC=avr-gcc
Ca évite d'avoir CPPFLAGS et CXXFLAGS inclus dans LINK.cc qui "polluent" la ligne de commande d'édition des liens de LINK.o.
PS: Je ne sais pas si "-xc++" est une option que quelqu'un mettrait dans une des 2 variables CPPFLAGS ou CXXFLAGS, mais si on essaye de lier avec cette option, gcc tente de lire les fichiers .o comme des fichiers sources C++, et forcément, ça marche pas très bien .
Si la règle est mal foutue, pourquoi ne pas la redéfinir proprement ?
Parce que comme je l'ai écrit juste au dessus de façon pas forcément très claire apparemment, ce n'est pas nécessaire, lors de l'édition des liens, "g++" = "gcc -lstdc++", et "avr-g++"="avr-gcc".
Et puis d'après l'aide de gcc/g++:
-x <langage> Spécifier le langage des fichiers d'entrée suivants.
Les langages permis sont: c c++ assembler none
« none » signifiant d'utiliser le comportement par défaut
en tentant d'identifier le langage par l'extension du fichier.
le langage de compilation est choisi en fonction de l'extension du fichier, pas de l'exécutable appelé, donc finalement "CC=g++" / "CC=avr-g++" ne va pas compiler en C++ les fichiers C et ce n'est pas la peine de s'embêter à trouver des solutions de contournement compliquées.
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
Pas d'aide concernant le code par MP, le forum est là pour ça :)
Liens utiles pour le C++
git is great because Linus did it, mercurial is better because he didn't.
git is great because Linus did it, mercurial is better because he didn't.