Visual studio: question about linking functions between two projects

前端 未结 2 1945
迷失自我
迷失自我 2021-01-24 03:19

I guess this is a newbie question, but anyway. I\'ve got a solution composed of two projects (1 DLL and 1 console app). The console app includes some headers from the DLL projec

相关标签:
2条回答
  • 2021-01-24 03:41

    I'm going to guess you use Visual Studio and don't know about dllexport.

    Visual Studio by default does not export the names of your functions on the outside of your DLL. To do so you need to tell it that explicitly:

    __declspec(dllexport) void f() {...}
    

    and on the side of the one using the DLL:

    __declspec(dllimport) void f();
    

    That way the second one will use the imported function and the first will export it.

    0 讨论(0)
  • 2021-01-24 03:59

    Make sure that the dll project is a dependency for the console app (right-click on the console project in the solution explorer and select project dependencies)..

    Then, in the console project properties under configuration properties->linker->general, ensure that 'Link Library Dependencies' is set to yes.

    0 讨论(0)
提交回复
热议问题