linker error while calling a c function in a VC++ application


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: linker error while calling a c function in a VC++ application

  1. #1
    hai wang Guest

    linker error while calling a c function in a VC++ application


    Hello everybody,
    Now I am working with a xml c libray called libxml, I have compiled
    the library by using VC++ 6, and then I wrote my own application which is
    calling the xml c library functions, I can compile the application without
    any error, but I couldn't create an executable file because a linker error
    "error LNK2001: unresolved external symbol _xmlParseFile", I guess the problem
    may result from VC++ settings which make VC++ co-work with c source code,
    but I don't know how to fix the problem, if any of you has the experience
    or solution, could you please reply me, I really appreciate it.

    Thank you very much!

    Hai Wang


    The source codes are given which caused the problem:

    char* filename = "Wang"; // substitute it with the file name

    FILE* f =fopen(filename, "w");
    f=fopen(filename, "w");
    int res, size = 1024;
    char chars[1024];
    res = fread(chars,1, 1024, f);

    SYSTEMTIME sysTime;
    COleDateTime timeNow = COleDateTime::GetCurrentTime();


    WORD W_starttime, W_endtime = 0;

    if(!timeNow.GetAsSystemTime(sysTime))
    {
    // cout << "time format conversion is failed " << endl;
    exit(1);
    }

    W_starttime = sysTime.wMilliseconds;

    xmlDocPtr xml_xmlDocPtr;


    for(int iterator1 = 0; iterator1 < 1000; iterator1++)
    {
    xml_xmlDocPtr = xmlParseMemory(chars, res); // attention! the function
    call caused this problem
    }
    Share on Google+

  2. #2
    Jonathan Morrison Guest

    Re: linker error while calling a c function in a VC++ application

    Hai,
    The linker error you are getting means that the linker is looking for a
    function written in C named xmlParseFile. The reason that the error message
    says _xmlParseFile is because the compiler mangles the name of C functions
    this way. Where is the libxml library housed (a DLL or LIB).

    -Jonathan
    "hai wang" <hwang@accuris.ie> wrote in message
    news:3a1436ca$1@news.devx.com...
    >
    > Hello everybody,
    > Now I am working with a xml c libray called libxml, I have compiled
    > the library by using VC++ 6, and then I wrote my own application which is
    > calling the xml c library functions, I can compile the application without
    > any error, but I couldn't create an executable file because a linker error
    > "error LNK2001: unresolved external symbol _xmlParseFile", I guess the

    problem
    > may result from VC++ settings which make VC++ co-work with c source code,
    > but I don't know how to fix the problem, if any of you has the experience
    > or solution, could you please reply me, I really appreciate it.
    >
    > Thank you very much!
    >
    > Hai Wang
    >
    >
    > The source codes are given which caused the problem:
    >
    > char* filename = "Wang"; // substitute it with the file name
    >
    > FILE* f =fopen(filename, "w");
    > f=fopen(filename, "w");
    > int res, size = 1024;
    > char chars[1024];
    > res = fread(chars,1, 1024, f);
    >
    > SYSTEMTIME sysTime;
    > COleDateTime timeNow = COleDateTime::GetCurrentTime();
    >
    >
    > WORD W_starttime, W_endtime = 0;
    >
    > if(!timeNow.GetAsSystemTime(sysTime))
    > {
    > // cout << "time format conversion is failed " << endl;
    > exit(1);
    > }
    >
    > W_starttime = sysTime.wMilliseconds;
    >
    > xmlDocPtr xml_xmlDocPtr;
    >
    >
    > for(int iterator1 = 0; iterator1 < 1000; iterator1++)
    > {
    > xml_xmlDocPtr = xmlParseMemory(chars, res); // attention! the

    function
    > call caused this problem
    > }



    Share on Google+

  3. #3
    hai wang Guest

    Re: linker error while calling a c function in a VC++ application


    Hello Jonathan,
    The libxml is housed in the DLL, I tried to call several other functions
    in the library, no one works, so I guess my library setting has some problems,
    but where?

    Thank you very much!
    Hai wang
    "Jonathan Morrison" <jonathanm@mindspring.com> wrote:
    >Hai,
    >The linker error you are getting means that the linker is looking for a
    >function written in C named xmlParseFile. The reason that the error message
    >says _xmlParseFile is because the compiler mangles the name of C functions
    >this way. Where is the libxml library housed (a DLL or LIB).
    >
    >-Jonathan
    >"hai wang" <hwang@accuris.ie> wrote in message
    >news:3a1436ca$1@news.devx.com...
    >>
    >> Hello everybody,
    >> Now I am working with a xml c libray called libxml, I have compiled
    >> the library by using VC++ 6, and then I wrote my own application which

    is
    >> calling the xml c library functions, I can compile the application without
    >> any error, but I couldn't create an executable file because a linker error
    >> "error LNK2001: unresolved external symbol _xmlParseFile", I guess the

    >problem
    >> may result from VC++ settings which make VC++ co-work with c source code,
    >> but I don't know how to fix the problem, if any of you has the experience
    >> or solution, could you please reply me, I really appreciate it.
    >>
    >> Thank you very much!
    >>
    >> Hai Wang
    >>
    >>
    >> The source codes are given which caused the problem:
    >>
    >> char* filename = "Wang"; // substitute it with the file name
    >>
    >> FILE* f =fopen(filename, "w");
    >> f=fopen(filename, "w");
    >> int res, size = 1024;
    >> char chars[1024];
    >> res = fread(chars,1, 1024, f);
    >>
    >> SYSTEMTIME sysTime;
    >> COleDateTime timeNow = COleDateTime::GetCurrentTime();
    >>
    >>
    >> WORD W_starttime, W_endtime = 0;
    >>
    >> if(!timeNow.GetAsSystemTime(sysTime))
    >> {
    >> // cout << "time format conversion is failed " << endl;
    >> exit(1);
    >> }
    >>
    >> W_starttime = sysTime.wMilliseconds;
    >>
    >> xmlDocPtr xml_xmlDocPtr;
    >>
    >>
    >> for(int iterator1 = 0; iterator1 < 1000; iterator1++)
    >> {
    >> xml_xmlDocPtr = xmlParseMemory(chars, res); // attention! the

    >function
    >> call caused this problem
    >> }

    >
    >


    Share on Google+

Similar Threads

  1. VB6 vs VB.NET...Procedure Calling Syntax
    By Patrick Troughton in forum .NET
    Replies: 78
    Last Post: 08-13-2002, 12:18 PM
  2. Function calling
    By Tom in forum VB Classic
    Replies: 0
    Last Post: 08-05-2002, 09:21 AM
  3. syntax for calling stored function
    By Joar Vatnaland in forum Database
    Replies: 1
    Last Post: 06-11-2001, 03:07 AM
  4. linker error while calling a c function from VC++ application
    By hai wang in forum authorevents.morrison
    Replies: 1
    Last Post: 11-17-2000, 11:21 AM
  5. I am helpless - Edit Info form
    By Dan in forum VB Classic
    Replies: 0
    Last Post: 03-17-2000, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center