Linking library without a header file?

前端 未结 4 2060
谎友^
谎友^ 2021-02-02 17:57

I\'m attempting to link a static library in C++ using Visual Studio 2010. Trouble is, the library (and accompanying header ) have a lot of MFC objects in them. I would like to c

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 18:56

    If the function you want to call is using MFC bits you're going to have to added MFC support to your project as well. However, if it isn't, and the function has been exported by the library, you can simply add the prototype for the function in the file where you want to call it, and then link the library to your executable.

    For instance, you'll add a line like this to the file where you're calling the exported function:

    void __stdcall foo( int );
    

    Make sure you get the calling convention correct, it may be different from __stdcall. Also, you may have to add extern "C" to prevent name mangling.

提交回复
热议问题