タイトルに記載されているエラーが発生します。ライブラリが含まれ、追加が正しく
設定されているディレクトリを含め、ディレクトリを含める - - プロパティでは、サブシステムは、私のコードにLNK2019:VSユニットテストで未解決の外部シンボル
コメントをコンソールに設定されている
: LifeLibクラスを含むプロジェクトで、私は次のことを確保しました私はいくつかの方法をテストしたいと思っています。クラスは名前空間LifeLibで定義されています。それらの1つはStornoTafelです。 testVariablesはどの名前空間にも定義されていません。
StornoTafelで2つのコンストラクタと1つのメソッドに対してリンクエラーが3回発生します(コードに記載されています)。詳細に
//project Tester
#include "stdafx.h"
#include "CppUnitTest.h"
#include "../LifeLib/StornoTafel.h"
#include "../LifeLib/testVariables.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace Tester
{
TEST_CLASS(AggSelTest)
{
public:
LifeLib::StornoTafel stornoTafel_; // LNK2019
LifeLib::StornoTafel *stornoTafel_; // no error, but I need an instance and not a reference to proceed -> see init method
LifeLib::testVariables test_vars_; // everything is fine
TEST_METHOD_INITIALIZE(init) {
stornoTafel_ = StornoTafel(test_vars_.lapseProb); // when this line is commented out I only get the first error (see below)
}
}
}
// testVariables.h
#pragma once
#include <iostream>
#include <vector>
class testVariables {
public:
testVariables() {};
// here are a lot of vectors with values for testing purposes
std::vector<double> _lapseProb= {0,1,2}; // [...]
};
// StornoTafel.h
#pragma once
#include "masterheader.h"
namespace LifeLib {
class StornoTafel {
public:
StornoTafel(); //LNK2019
StornoTafel(std::vector<double> ProbabilityOfLapseInYearT); //LNK2019
StornoTafel(const StornoTafel &obj); //no error
StornoTafel operator=(StornoTafel const& rhs); //LNK2019
//! \name Getter
//@{
const std::vector<double>& Stornowahrscheinlichkeit() const;
//@}
protected:
std::vector<double> Stornowahrscheinlichkeit_;
};
inline const std::vector<double>& StornoTafel::Stornowahrscheinlichkeit() const {
return Stornowahrscheinlichkeit_;
}
}
//StornoTafel.cpp
#include "StornoTafel.h"
LifeLib::StornoTafel::StornoTafel() {
}
LifeLib::StornoTafel::StornoTafel(std::vector<double> ProbabilityOfLapseInYearT) {
Stornowahrscheinlichkeit_ = ProbabilityOfLapseInYearT;
}
LifeLib::StornoTafel::StornoTafel(const StornoTafel &obj) {
Stornowahrscheinlichkeit_ = obj.Stornowahrscheinlichkeit_;
}
LifeLib::StornoTafel LifeLib::StornoTafel::operator=(StornoTafel const& rhs) {
Stornowahrscheinlichkeit_ = rhs.Stornowahrscheinlichkeit_;
return *this;
}
//masterheader.h
#pragma once
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <ctime>
エラー:
- LNK2019未解決の外部シンボル "パブリック:__cdecl LifeLib :: StornoTafel :: StornoTafel(無効)" (?? 0StornoTafel @ LifeLib @@ QEAA @ XZ)関数で参照 "公共: __cdecl AggSelTester :: AggSelTest :: AggSelTest(無効)":__cdecl LifeLib :: S(?? 0AggSelTest @ AggSelTester @@ QEAA
- LNK2019未解決の外部 シンボル「パブリック)XZ @ tornoTafel :: StornoTafel(クラス std :: vector>) " (0StornoTafel @ LifeLib @@ QEAA @ V?$ vector @ NV?$ allocator @ N @ std @@@ std @@@Z) 機能 "パブリックます:void __cdecl AggSelTester :: AggSelTest ::のinit(無効)"(@ AggSelTest @ AggSelTester @@ QEAAXXZのinit?)
- LNK2019未解決の外部シンボル 「公共:クラスLifeLib :: StornoTafel __cdecl LifeLib: :関数 で参照される "(4StornoTafel @ LifeLib @@ QEAA?AV01 @ AEBV01 @@ Z)" public:void __cdecl AggSelTester :: AggSelTest :: init(StornoTafel :: operator =クラスLifeLib :: StornoTafel const &) (void)」 (?init @ AggSelTest @ AggSelTester @@ QEAAXXZ)
なぜ発生するのですか?
すべてが64ビットで実行されるので、そうであってはならない。私が述べたように、私は正しいインクルードパスなどを入れることを確信しています。 – Steve