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

Boost C++ Discussion :

Boost::Asio et code::blocks


Sujet :

Boost C++

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    185
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 185
    Points : 118
    Points
    118
    Par défaut Boost::Asio et code::blocks
    Bonjour, voilà mon problème:
    j'ai téléchargé Boost1.34 et BoostAsio, j'ai tout mis directement dans la racine:


    j'ai configuré Code::Blocks :


    j'ai ensuite tenté de compiler le code du tutorial sur le site de Boost::Asio :
    tutorial : http://asio.sourceforge.net/boost_as...tuttimer1.html
    Code complet :
    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
    #include <iostream>
    #include <boost/asio.hpp>
    #include <boost/date_time/posix_time/posix_time.hpp>
     
    int main()
    {
      boost::asio::io_service io;
     
      boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
      t.wait();
     
      std::cout << "Hello, world!\n";
     
      return 0;
    }
    voilà les insultes que le compiler m'envoie :
    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
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    C:/boost_asio_0_3_7/boost/asio/detail/socket_types.hpp:31:5: warning: #warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
    C:/boost_asio_0_3_7/boost/asio/detail/socket_types.hpp:32:5: warning: #warning Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target)
    Linking console executable: bin\Release\test-01.exe
    obj\Release\main.o:main.cpp:(.text+0xcde): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x6d): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x99): undefined reference to `WSASocketA@24'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xa7): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xf7): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x12d): undefined reference to `setsockopt@20'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x135): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x165): undefined reference to `inet_addr@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x19d): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x1bf): undefined reference to `bind@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x1cd): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x214): undefined reference to `getsockname@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x249): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x263): undefined reference to `listen@8'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x271): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x2b3): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x2e9): undefined reference to `WSASocketA@24'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x2f7): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x348): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x36a): undefined reference to `connect@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x378): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x3c3): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x3e0): undefined reference to `accept@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x3ee): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x447): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x46b): undefined reference to `ioctlsocket@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x479): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x49f): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x693): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x6a4): undefined reference to `closesocket@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x6ac): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x6fa): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x70b): undefined reference to `closesocket@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x713): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x766): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x777): undefined reference to `closesocket@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x77f): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0x7bc): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xbaa): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xc0f): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xc69): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xcf4): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xd2a): undefined reference to `setsockopt@20'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xd32): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xd70): undefined reference to `WSASetLastError@4'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xd94): undefined reference to `ioctlsocket@12'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xda2): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xdc8): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xe22): undefined reference to `WSAGetLastError@0'
    obj\Release\main.o:main.cpp:(.text$_ZN5boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_select_interrupter::socket_select_interrupter()]+0xead): undefined reference to `WSASetLastError@4'
    Process terminated with status 1 (0 minutes, 29 seconds)
    50 errors, 2 warnings
    si je ne dis pas de bétise (...) ce genre de msg indiquent que j'ai mal ou pas, linké quelque chose, mais je ne sais pas quoi.

  2. #2
    Rédacteur/Modérateur
    Avatar de JolyLoic
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2004
    Messages
    5 463
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2004
    Messages : 5 463
    Points : 16 213
    Points
    16 213
    Par défaut
    Dans les options, tu as indiqué les répertoires des libs, pas avec quelles libs linker. Sous MsDev, il y a du code qui fait que les libs à linker sont automatiquement sélectionnées. Par pour code::blocks. Il te faut donc indiquer manuellement la bonne version de la lib à utiliser.
    Ma session aux Microsoft TechDays 2013 : Développer en natif avec C++11.
    Celle des Microsoft TechDays 2014 : Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
    Et celle des Microsoft TechDays 2015 : Visual C++ 2015 : voyage à la découverte d'un nouveau monde
    Je donne des formations au C++ en entreprise, n'hésitez pas à me contacter.

  3. #3
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 26
    Points : 28
    Points
    28
    Par défaut
    Il faut que tu link ton programme avec libws2_32.a si tu compiles avec mingw, si tu as mingw installé avec codeblocks c'est dans le repertoire ....../CodeBlocks/lib/

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    185
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 185
    Points : 118
    Points
    118
    Par défaut
    Citation Envoyé par JolyLoic
    Dans les options, tu as indiqué les répertoires des libs, pas avec quelles libs linker. Sous MsDev, il y a du code qui fait que les libs à linker sont automatiquement sélectionnées. Par pour code::blocks. Il te faut donc indiquer manuellement la bonne version de la lib à utiliser.
    c'est une version SVN que j'ai, je ne peux pas selectionner une lib, je peux que sélectionner un répertoire.

    Citation Envoyé par albat0r
    Il faut que tu link ton programme avec libws2_32.a si tu compiles avec mingw, si tu as mingw installé avec codeblocks c'est dans le repertoire ....../CodeBlocks/lib/
    j'ai mingw installé à part, j'ai linké le répertoire lib contenant libws2_32.a, j'ai plus les msg
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    C:/boost_asio_0_3_7/boost/asio/detail/socket_types.hpp:31:5: warning: #warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
    C:/boost_asio_0_3_7/boost/asio/detail/socket_types.hpp:32:5: warning: #warning Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target)
    Linking console executable: bin\Release\test-01.exe
    mais j'ai tjrs les 50 autres

  5. #5
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 26
    Points : 28
    Points
    28
    Par défaut
    Pour enlever les warning rien de plus simple, tu vas dans le build option de ton projet c::b tu vas sur l'onglet Compiler Settings puis dans le sous onglet #defines ensuite tu ajoutes la définition _WIN32_WINNT si tu es sur un windows dont la version est supérieur ou égal à win2000

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    185
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 185
    Points : 118
    Points
    118
    Par défaut
    comme je l'ai dit juste au dessus je n'ai plus c'est msg c'est réglé, mais j'ai tjrs les 50 erreurs d'affichés. En fait il y a plus de 50 erreurs, mais code::blocks ne m'en affiche pas plus de 50. Par contre je sais tjrs pas comment régler ce problème.

  7. #7
    Expert confirmé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2003
    Messages
    3 549
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 3 549
    Points : 4 625
    Points
    4 625
    Par défaut
    Il manque winsock.
    Boost ftw

  8. #8
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 26
    Points : 28
    Points
    28
    Par défaut
    Lier le répertoire ne suffit pas, pas de pragma avec mingw, il faut lier la librairie explicitement et ça réglera les soucis. Il se peut qu'il te faille aussi lier la librairie system de boost pour les exeptions.

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    185
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 185
    Points : 118
    Points
    118
    Par défaut
    alors j'ai ajouté winsock (écrit tel quel sans l'extension dll) dans Link Librairies dans l'écran Project Build options

    voilà le msg d'erreur que je récupère :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lwinsock
    collect2: ld returned 1 exit status
    alors j'ai copié le fichier winsock.dll présent dans le dossier windows/win32 dans le dossier mingw/lib, j'obtient le msg d'erreur suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    C:\mingw\lib/winsock.dll: file not recognized: File format not recognized
    collect2: ld returned 1 exit status
    bon, j'ai vraiment du mal à configurer mon environnement...

  10. #10
    Nouveau membre du Club
    Inscrit en
    Mai 2007
    Messages
    26
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 26
    Points : 28
    Points
    28
    Par défaut
    Le plus simple avec C::B c'est de sélectionner la lib manuellement, tu vas dans l'onglet Linker Settings puis tu ajoutes libws2_32.a . Fais moi confiance j'utilise asio aussi avec tous les compilo courant

  11. #11
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    185
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2004
    Messages : 185
    Points : 118
    Points
    118
    Par défaut


    effectivement, ça marche! j'y penserai à la prochaine histoire de ce type...

    merci à toi et aussi aux autres.

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

Discussions similaires

  1. linker boost fileSystem avec code blocks
    Par mathieu41 dans le forum Boost
    Réponses: 2
    Dernier message: 11/05/2014, 12h46
  2. Code::Blocks et Boost
    Par Trunks dans le forum Code::Blocks
    Réponses: 2
    Dernier message: 26/10/2009, 14h07
  3. [Boost]Linker avec Code::Blocks automatiquement
    Par Bueno dans le forum Boost
    Réponses: 3
    Dernier message: 23/06/2009, 21h34
  4. Réponses: 5
    Dernier message: 02/07/2008, 12h14
  5. Installation de Boost avec Code::Blocks et MinGW
    Par kalash_jako dans le forum Code::Blocks
    Réponses: 0
    Dernier message: 27/08/2007, 12h16

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