単独でコンパイルするコードの下にあります。 libtea.dllとlibtea.dllを別のオブジェクト(実行可能ファイルや別のdll)とリンクさせるためにlibtea.dllと.libを生成します。私には、C++、MSVC/Visual Studio 2017で奇妙なリンカエラーが発生しました。 DLLの暗黙的なリンク
U */Linuxの古いg ++ユーザーとして、私は本当にundestandできませんtstring.ccファイルに実装されているtstring :: word :: operator()()を "クライアント"プロジェクトのリンク時に共有(解決)することができないtstringクラスメンバーのMSVC(Windows)すべてのアクセス可能な...?
P.S .:あまりにも一般的な名前のlib "茶"を判断しないでください...私は多くのお茶を飲むのが好きなので! :)私は ...コードは、私はMSVCに対して直面何を明らかに示している願っています
//...
[libtea.h]
#pragma once
#ifdef TEA_EXPORTS // Well defined
#define TEA_API __declspec(dllexport) // <-- Compiling the lib
#else
#define TEA_API __declspec(dllimport) // <-- Compiling the client project
#endif
[EOF libtea.h]
// ...
[tstring.h]
#pragma once
#include <libtea.h>
#include ...
//...
class TEA_API tstring{
//...
struct word { // x64: 48 bytes;
string::iterator begin;
string::iterator end;
string operator()(); // ---> LNKC2019 ...external unresolved...
using array_t = std::vector<word>;
};
struct cword { // x64: 16 bytes;
const char* begin;
const char* end;
string operator()(); // -----> LNKC2019 ...external unresolved...
using array_t = std::vector<cword>;
};
//...
[EOF tstring.h]
Client(-test) program main:
#include <tstring.h>
//...
using namespace std;
auto main() -> int { // c++ 14 : why not ? :-)
tstring str;
str << "libtea.dll: size of tstring::word=[%d] <> std::string:[%d] <> tstring::cword[%d]\n";
str.arg(sizeof(tstring::word)).arg(sizeof(string)).arg(sizeof(tstring::cword));
cout << str();
tstring::cword::array_t words;
size_t sz = str.cwords(words, "", true);
cout << "words: " << sz << ":\n";
for (auto& w : words) {
cout << "[" << w() << "]\n"; // tstring::cword::operator()(void): cannot be resolved....LNKC2019 ...external unresolved...
}
Sleep(2000);
return 0;
}
はご静聴ありがとうございました:)
あなたが取得しているか、エラー状態ではないのですか? –
'#define TEA_API __declspec(dllexport)< - libをコンパイルする'あなたはこれらのステートメントをそのまま受けていないと思いますか?コメントを使用して強調表示します。 – user0042
Anon Mail:LNKC2019。それはコードのコメントとして埋め込まれています... :) – Bretzelus