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

Visual C++ Discussion :

[API] Ajouter une dll


Sujet :

Visual C++

  1. #21
    Membre Expert

    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Juin 2003
    Messages
    4 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 506
    Points : 5 723
    Points
    5 723
    Par défaut
    Si tu as ajouté ton .h que tu as ajouté le #pragma pour le .lib et que tout cela compile sans erreur alors tu dois maintenant pouvoir utiliser les fonctions de ta dll dans le source genre : (je ne connais pas les fonctions de cette dll) :


    Et ca devrait compiler et linker et s'executer.

    N'oublies pas que ton .dll doit être dans le PATH (repertoire de l'exeuctable ou alors dans un des repertoire définis dans la variable d'environnement PATH)

  2. #22
    Débutant
    Inscrit en
    Mars 2006
    Messages
    492
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 492
    Points : 94
    Points
    94
    Par défaut
    il y'a la 3ème étape qui fait erreur, quand j'ajoute #import "Netica.dll",
    l'erreur est
    fatal error C1083: Cannot open type library file: 'c:\documents and settings\abbd\mes documents\visual studio 2005\projects\dfdf\dfdf\netica.dll': Erreur lors du chargement de la bibliothèque/DLL du type.

    est ce que cette ligne de code est necessaire?merci

  3. #23
    Membre Expert

    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Juin 2003
    Messages
    4 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 506
    Points : 5 723
    Points
    5 723
    Par défaut
    Citation Envoyé par abbd
    il y'a la 3ème étape qui fait erreur, quand j'ajoute #import "Netica.dll", est ce que cette ligne de code est necessaire?merci
    Non ce n'est plus nécessaire.

    L'étape 3 c'est d'appeler une fonction


  4. #24
    Débutant
    Inscrit en
    Mars 2006
    Messages
    492
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 492
    Points : 94
    Points
    94
    Par défaut
    il y'a ce code qui utilise la dll, il est ecrit dans C, mais normalement sa doit marché dans C++ surtout qu'on a integré la dll

    int main (void){
    net_bn *net;
    node_bn *VisitAsia, *Tuberculosis, *Smoking, *Cancer, *TbOrCa, *XRay;
    double belief;
    char mesg[MESG_LEN_ns];
    int res;

    printf ("\nWelcome to Netica API!\n");
    printf ("This demo project is from the first 2 examples of the Reference Manual.\n");
    printf ("If it compiles, links and runs successfully (i.e. without generating\n");
    printf ("errors), then your installation is probably good.\n");
    printf ("Now you can replace the Demo.c file with your own code.\n");
    printf ("--------------------------------------------------------------------\n\n");

    env = NewNeticaEnviron_ns (NULL, NULL, NULL);
    res = InitNetica_bn (&env, mesg);

    printf ("%s\n", mesg);
    if (res < 0) return -1;

    net = NewNet_bn ("AsiaEx", env);
    CHKERR

    VisitAsia = NewNode_bn ("VisitAsia", 2, net);
    Tuberculosis = NewNode_bn ("Tuberculosis", 2, net);
    Smoking = NewNode_bn ("Smoking", 2, net);
    Cancer = NewNode_bn ("Cancer", 2, net);
    TbOrCa = NewNode_bn ("TbOrCa", 2, net);
    XRay = NewNode_bn ("XRay", 2, net);
    CHKERR

    SetNodeStateNames_bn (VisitAsia, "visit, no_visit");
    SetNodeStateNames_bn (Tuberculosis,"present, absent");
    SetNodeStateNames_bn (Smoking, "smoker, nonsmoker");
    SetNodeStateNames_bn (Cancer, "present, absent");
    SetNodeStateNames_bn (TbOrCa, "true, false");
    SetNodeStateNames_bn (XRay, "abnormal,normal");
    SetNodeTitle_bn (TbOrCa, "Tuberculosis or Cancer");
    SetNodeTitle_bn (Cancer, "Lung Cancer");
    CHKERR

    AddLink_bn (VisitAsia, Tuberculosis);
    AddLink_bn (Smoking, Cancer);
    AddLink_bn (Tuberculosis, TbOrCa);
    AddLink_bn (Cancer, TbOrCa);
    AddLink_bn (TbOrCa, XRay);
    CHKERR

    SetNodeProbs (VisitAsia, 0.01, 0.99);

    SetNodeProbs (Tuberculosis, "visit", 0.05, 0.95);
    SetNodeProbs (Tuberculosis, "no_visit", 0.01, 0.99);

    SetNodeProbs (Smoking, 0.5, 0.5);

    SetNodeProbs (Cancer, "smoker", 0.1, 0.9);
    SetNodeProbs (Cancer, "nonsmoker", 0.01, 0.99);

    // Tuberculosis Cancer
    SetNodeProbs (TbOrCa, "present", "present", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "present", "absent", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "absent", "present", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "absent", "absent", 0.0, 1.0);

    // TbOrCa Abnormal Normal
    SetNodeProbs (XRay, "true", 0.98, 0.02);
    SetNodeProbs (XRay, "false", 0.05, 0.95);
    CHKERR

    CompileNet_bn (net);
    CHKERR

    belief = GetNodeBelief ("Tuberculosis", "present", net);
    CHKERR

    printf ("The probability of tuberculosis is %g\n\n", belief);

    EnterFinding ("XRay", "abnormal", net);
    belief = GetNodeBelief ("Tuberculosis", "present", net);
    CHKERR

    printf ("Given an abnormal X-ray, \n\
    the probability of tuberculosis is %g\n\n", belief);

    EnterFinding ("VisitAsia", "visit", net);
    belief = GetNodeBelief ("Tuberculosis", "present", net);
    CHKERR

    printf ("Given an abnormal X-ray and a visit to Asia, \n\
    the probability of tuberculosis is %g\n\n", belief);

    EnterFinding ("Cancer", "present", net);
    belief = GetNodeBelief ("Tuberculosis", "present", net);
    CHKERR

    printf ("Given abnormal X-ray, Asia visit, and lung cancer, \n\
    the probability of tuberculosis is %g\n\n", belief);

    end:
    DeleteNet_bn (net);
    res = CloseNetica_bn (env, mesg);
    printf ("%s\n", mesg);
    printf ("Press <enter> key to quit ", mesg);
    getchar();
    return (res < 0) ? -1 : 0;

    error:
    fprintf (stderr, "NeticaDemo: Error in %s\n",
    ErrorMessage_ns (GetError_ns (env, ERROR_ERR, NULL)));
    goto end;
    }
    mais dans MFC printf ne marche pas,jai essayé MessageBox("mon message");
    il fait erreur; mais normalement MessageBox affiche normalement un messsage box dans les MFC, parceque jai travailler avec les MFC dans visual C++ 6 sans problem,merci

  5. #25
    Membre Expert

    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Juin 2003
    Messages
    4 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 506
    Points : 5 723
    Points
    5 723
    Par défaut
    Si ca compile et s'execute tu as alors un autre probléme.

    Pour afficher des messages dans la console avec les MFC il me semble qu'il existe une fonction PTRACE je crois ?

  6. #26
    Débutant
    Inscrit en
    Mars 2006
    Messages
    492
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 492
    Points : 94
    Points
    94
    Par défaut
    le code qui est ecrit au dessus la fonction main retourne un entier, pour l'essayer en C++ jai copier le code du mai et je lé copier dans un boutton mais la fonction mais retourne un entier il ya des erreur du genre

    error LNK2019: unresolved external symbol _GetNodeBelief referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)

    merci

  7. #27
    Membre Expert

    Homme Profil pro
    Ingénieur R&D
    Inscrit en
    Juin 2003
    Messages
    4 506
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2003
    Messages : 4 506
    Points : 5 723
    Points
    5 723
    Par défaut
    Je ne vois pas le code d'ou vient l'erreur...

    Tu as bien fais un projet MFC ? Toujours dans la configuration : use MFC library.

    Mais sur ce coup là je ne pourrais t'être d'une grande aide, j'ai renoncé aux MFC depuis longtemps

  8. #28
    Débutant
    Inscrit en
    Mars 2006
    Messages
    492
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 492
    Points : 94
    Points
    94
    Par défaut
    Citation Envoyé par hegros
    Je ne vois pas le code d'ou vient l'erreur...

    Tu as bien fais un projet MFC ? Toujours dans la configuration : use MFC library.

    Mais sur ce coup là je ne pourrais t'être d'une grande aide, j'ai renoncé aux MFC depuis longtemps
    Oui
    j'utilise les MFC Application quand je compile il me fait 3erreur:

    1>rrrrDlg.obj : error LNK2019: unresolved external symbol _GetNodeBelief referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)

    1>rrrrDlg.obj : error LNK2019: unresolved external symbol _SetNodeProbs referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)

    1>rrrrDlg.obj : error LNK2001: unresolved external symbol _env



    sachant que jai réduit du code, jai ecris le code suivant dans ub bouton

    net_bn *net;
    node_bn *VisitAsia, *Tuberculosis, *Smoking, *Cancer, *TbOrCa, *XRay;
    double belief;
    char mesg[MESG_LEN_ns];
    int res;

    env = NewNeticaEnviron_ns (NULL, NULL, NULL);
    res = InitNetica_bn (&env, mesg);



    net = NewNet_bn ("AsiaEx", env);


    VisitAsia = NewNode_bn ("VisitAsia", 2, net);
    Tuberculosis = NewNode_bn ("Tuberculosis", 2, net);
    Smoking = NewNode_bn ("Smoking", 2, net);
    Cancer = NewNode_bn ("Cancer", 2, net);
    TbOrCa = NewNode_bn ("TbOrCa", 2, net);
    XRay = NewNode_bn ("XRay", 2, net);


    SetNodeStateNames_bn (VisitAsia, "visit, no_visit");
    SetNodeStateNames_bn (Tuberculosis,"present, absent");
    SetNodeStateNames_bn (Smoking, "smoker, nonsmoker");
    SetNodeStateNames_bn (Cancer, "present, absent");
    SetNodeStateNames_bn (TbOrCa, "true, false");
    SetNodeStateNames_bn (XRay, "abnormal,normal");
    SetNodeTitle_bn (TbOrCa, "Tuberculosis or Cancer");
    SetNodeTitle_bn (Cancer, "Lung Cancer");


    AddLink_bn (VisitAsia, Tuberculosis);
    AddLink_bn (Smoking, Cancer);
    AddLink_bn (Tuberculosis, TbOrCa);
    AddLink_bn (Cancer, TbOrCa);
    AddLink_bn (TbOrCa, XRay);


    SetNodeProbs (VisitAsia, 0.01, 0.99);

    SetNodeProbs (Tuberculosis, "visit", 0.05, 0.95);
    SetNodeProbs (Tuberculosis, "no_visit", 0.01, 0.99);

    SetNodeProbs (Smoking, 0.5, 0.5);

    SetNodeProbs (Cancer, "smoker", 0.1, 0.9);
    SetNodeProbs (Cancer, "nonsmoker", 0.01, 0.99);


    SetNodeProbs (TbOrCa, "present", "present", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "present", "absent", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "absent", "present", 1.0, 0.0);
    SetNodeProbs (TbOrCa, "absent", "absent", 0.0, 1.0);


    SetNodeProbs (XRay, "true", 0.98, 0.02);
    SetNodeProbs (XRay, "false", 0.05, 0.95);


    CompileNet_bn (net);


    belief = GetNodeBelief ("Tuberculosis", "present", net);


    printf ("The probability of tuberculosis is %g\n\n", belief);
    merci

  9. #29
    Débutant
    Inscrit en
    Mars 2006
    Messages
    492
    Détails du profil
    Informations forums :
    Inscription : Mars 2006
    Messages : 492
    Points : 94
    Points
    94
    Par défaut
    Est ce que #include"Netica.h" je doit le mettre que dans MonprojetDlg.cpp?
    il y'a toujours des erreur du type :

    error LNK2019: unresolved external symbol _EnterFinding referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)
    error LNK2019: unresolved external symbol _GetNodeBelief referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)
    error LNK2019: unresolved external symbol _SetNodeProbs referenced in function "public: void __thiscall CrrrrDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CrrrrDlg@@QAEXXZ)
    error LNK2001: unresolved external symbol _env

    merci d'avance

Discussions similaires

  1. Comment Ajouter une dll a son application web ?
    Par kedare dans le forum ASP.NET
    Réponses: 7
    Dernier message: 08/02/2007, 16h47
  2. Ajouter une dll au linkage
    Par GLDavid dans le forum VC++ .NET
    Réponses: 8
    Dernier message: 04/01/2007, 13h03
  3. Réponses: 2
    Dernier message: 01/09/2006, 14h54
  4. ajouter une dll à un projet devcpp....
    Par youp_db dans le forum Windows
    Réponses: 1
    Dernier message: 28/09/2005, 21h33
  5. ajouter une dll à un projet devcpp....
    Par youp_db dans le forum Dev-C++
    Réponses: 1
    Dernier message: 28/09/2005, 20h47

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