私はここ数日、自分でこれを理解しようとして過ごし、幸運に恵まれました.
注:静的ライブラリ(.lib)に対してのみこれを試しました
.lib ファイルの問題は、ライブラリの関数を呼び出した場合にのみ使用され、プロジェクトに接続されることです。最小限のプロジェクトの問題は、メイン機能しかないことです。しかし、これはあなたのプロジェクトによって呼び出されていないので、どのように接続されていますか?
私の解決策は、それほどエレガントではないかもしれませんが、私にとってはうまくいきます.lib.hをインクルードするLibConnection.hを作成し、lib.cppから1つのダミー関数を呼び出します. 私の意見では、悪い点は、lib.h と Connectionlib.h をプロジェクト ファイルに含める必要があることです。
このような:
//Lib.h
void ConnectionFunction();
//Lib.cpp
int main(int argc, char* argv[])
{
//do some stuff
}
//This function doesn't do anything but it is important
//that you define it in your lib.h and declare it in your lib.cpp
void ConnectionFunction()
{
}
基本的なライブラリができたので、次のような接続ファイルを作成する必要があります。
//LibConnection.h
#include "Lib.h"
//now we call the connectionfunction
//remember non of this get really called but it makes possible connecting with your
//almost empty library
void Dummy()
{
ConnectionFunction();
}
そして、空のプロジェクトで:
//testapp.cpp
#include "LibConnection.h"
//remember to include the lib.h and the libconnection.h into your project files
void Foo()
{
//this function doesn't get called but your project is running!
}
お役に立てれば :)