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

MFC Discussion :

conflit lib


Sujet :

MFC

  1. #1
    Membre à l'essai
    Inscrit en
    Septembre 2005
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 5
    Par défaut conflit lib
    je programme en utilisant des API fournis par un autre logiciel et quand j'appelle une bibliotheque et que je complie le message d'erreur suivant apparait :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    --------------------Configuration: motion capture - Win32 Debug--------------------
    Compiling...
    dt3152.cpp
    Linking...
    MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _memmove already defined in LIBCD.lib(memmove.obj)
    MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _sprintf already defined in LIBCD.lib(sprintf.obj)
    MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _memmove already defined in LIBCD.lib(memmove.obj); second definition ignored
    MSVCRTD.lib(MSVCRTD.dll) : warning LNK4006: _sprintf already defined in LIBCD.lib(sprintf.obj); second definition ignored
    j'ai vu dans d'autres post du forum que l'on pouvait regler ce probleme par du multithread mais etant debutant en programmation j'ai pas bien pige de quoi il s'agissait

    si quelqu'un pouvait mexpliquer comment regler se probleme merci

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    87
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2006
    Messages : 87
    Par défaut
    Salut

    Ca peut en effet etre un probleme de MultiThread /SingleThread mais ca peux aussi etre un conflit MFC CRT.
    C'est du Chinois ??
    Bon je vais essayer d'etre clair: les new et delete sont defini dans plusieurs libraries, le probleme ici c'est qu'une library essaye de redefinir les new et delete defini pas un autre: soit parce que certains de tes programmes (dll,lib,exe....) utilise une librairie pour le multiThread et d'autre une pour le singleThread.
    Soit parce que CRT essaye de redefinir ce qui a deja ete definie par MFC, parce que si je me plante pas, CRT emmene pas trop que les new et delete on ete definie par MFC alors que MFC s'en fiche.

    Maintenant passons a la solution:
    Essaye deja d'aller dans les propietes de ton projet: C/C++/CodeGeneration/RunTime library (mon visual .Net est en anglais dsl) et essaye les differentes options...
    Si ca compile bingo !!!

    Sinon le prob c MFC:
    Je te file un lien sur un forum en anglais qui reprend la solus de la msdn
    http://www.codeguru.com/forum/archive/index.php/t-102337.html

    RESOLUTION
    There are two ways to resolve this problem. The first solution involves forcing the linker to link the libraries in the correct order. The second solution allows you to find the module that's causing the problem and correct it.
    Solution One - Force Linker to Link Libraries in Correct Order
    Open the Project Settings dialog box by clicking Settings on the Build menu.
    in the Settings For view, select (highlight) the project configuration that's getting the link errors.
    Click the Link tab.
    Select INPUT in the Category combo box.
    In the Libraries to Ignore edit box, insert the library names (for example, Nafxcwd.lib Libcmtd.lib)

    NOTE: The linker command line equivalent in /NOD:<library name>

    In the Object/library Modules edit box, insert the library names. You must ensure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).
    Solution Two - Find the Problem Module and Correct It
    Perform the following steps to see the current library link order:
    Open the Project Settings dialog box by clicking Settings on the Build menu.
    In the Settings For view, Select (highlight) the project configuration that's getting the link errors .
    Click the Link tab.
    Type the following in the Project Options dialog box:
    /verbose:lib
    Rebuild your project. The libraries will now be listed in the output window during the linking process.


    STATUS
    This behavior is by design.


    MORE INFORMATION
    When using MFC libraries, you must make sure they are linked before the CRT library. This can be done by ensuring every file in your project includes ..\Msdev\Mfc\Include\Afx.h first, either directly (#include <Afx.h&gt or indirectly (#include <Stdafx.h&gt. The Afx.h include file forces the correct order of the libraries, by using the #pragma comment (lib,"<libname>") directive.
    If the source file has a .c extension, or the file has a .cpp extension but does not use MFC, you can create and include a small header file (Forcelib.h) at the top of the module. This new header will ensure the correct library search order.
    Visual C++ does not contain this header file, but you can easily create this file by performing the following steps:
    Open ..\Msdev\Mfc\Include\Afx.h.
    Select line 29 (#ifndef _AFX_NOFORCE_LIBS) through line 204 (#endif //!_AFX_NOFORCE_LIBS).
    Copy the selection to the Windows Clipboard.
    Create a new text file.
    Paste the contents of the Clipboard into this new file.
    Save the file as ..\Msdev\Mfc\Include\Forcelib.h.

  3. #3
    Membre expérimenté Avatar de Rupella
    Inscrit en
    Février 2005
    Messages
    286
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 286
    Par défaut
    J'ai eu un souci du meme ordre...

    J'ai d'un coté deux libraries qui n'utilisent pas les MFC, mais qui utilisent massivement la STL... Compilation en Multi-threaded Debug DLL (/MDd).
    Les fichiers générés sont des .LIB

    J'ai d'un aute coté des applicatifs qui utilisent les MFC et la STL.
    si le projet est paramétré pour "Use MFC in a Shared DLL" (dsl j'suis en anglais), et Multi-threaded Debug DLL (/MDd), je n'ai pas de souci.
    Par contre, si je veux mettre Use MFC in a Static Library" j'suis carrotte !
    J'ai un paquet d'erreurs sur les objets de la STL que j'utilise, les type_info ...

    A la fin, j'ai le warning suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
    J'ai essayé un peu toutes les solutions, je suis passé par la page donnée plus haut, mais j'y arrive pas !

  4. #4
    Membre éprouvé
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    87
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mars 2006
    Messages : 87
    Par défaut
    Salut

    Je dsl pour toi Rupella mais je crois pas qu'il y est de solus pour ton prob...
    Si tu utilise d'une certaine facon (j'ai pas encore tres bien compris laquelle ) les MFC tu est oblige des les liers en static....
    C pas tres grave le seul probleme c que si tu veux distribuer ton appli il faut inclure les dll MFC dont tu as besoin (tu as le droit de distribuer les versions release de ces DLL mais pas debug si tu as une licence Visual Studio). Le seul oups c que il existe differentes version de ces fameuse dll mfc et quelles portent toutes le meme non .... (Bonjour les conflits entre appli utilisant les MFC)

  5. #5
    Membre expérimenté Avatar de Rupella
    Inscrit en
    Février 2005
    Messages
    286
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 286
    Par défaut
    Le truc qu'il faut que je fasse, c'est de générer les librairies qui n'utilisent
    pas les MFC avec un autre compilateur (genre avec Code::Blocks).

    J'essaye dès que j'ai un peu de temps, mais je ne sais pas s'il c'est possible
    de faire comme ca...

  6. #6
    Membre éclairé
    Avatar de barthelv
    Inscrit en
    Mars 2003
    Messages
    267
    Détails du profil
    Informations forums :
    Inscription : Mars 2003
    Messages : 267
    Par défaut
    Voici peut etre la solution:

    http://support.microsoft.com/default...;EN-US;q148652

    En gros:

    Solution One: Force Linker to Link Libraries in Correct Order
    1. On the Project menu, click Settings.
    2. In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
    3. On the Link tab, click to select Input in the Category combo box.
    4. In the Ignore libraries box, insert the library names (for example, Nafxcwd.lib;Libcmtd.lib).

    Note The linker command-line equivalent in /NOD:<library name>.
    5. In the Object/library modules box, insert the library names. You must make sure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).
    To set this option in Visual C++ .NET, read the "Setting Visual C++ Project Properties" online help topic.
    Back to the top Back to the top

    Solution Two: Locate and Correct the Problem Module
    To view the current library link order, follow these steps:
    1. On the Project menu, click Settings.
    2. In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
    3. On the Link tab, type /verbose:lib in the Project Options box.
    4. Rebuild your project. The libraries will be listed in the output window during the linking process.

  7. #7
    Membre à l'essai
    Inscrit en
    Septembre 2005
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 5
    Par défaut
    merci pour ta solution vincedom
    j'ai trouver ou il fallait modifier les settings pour les run timelibrary et l'option qui fonctionne est multithread DLL et la toutes mes erreurs LNK2005 ont disparue

    par contre maintenant apparait une erreur lnk 2001 mais ca je dois reussir a la corriger en trouver la bonne library pour la fonction demandee

Discussions similaires

  1. Générer règles de conflits pour réplication
    Par dupin40 dans le forum Administration
    Réponses: 3
    Dernier message: 01/09/2003, 15h31
  2. [horloge] conflit caractère / timer
    Par JeanJean dans le forum C
    Réponses: 10
    Dernier message: 09/05/2003, 23h47
  3. [Technique] Conflits entre plusieurs requêtes
    Par Neowile dans le forum Décisions SGBD
    Réponses: 3
    Dernier message: 24/03/2003, 09h37
  4. inclure une librairie *.lib
    Par darkbm dans le forum C
    Réponses: 2
    Dernier message: 16/12/2002, 22h48

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