Я вижу по вопросу, что не удалось связать статическую библиотеку C ++ / CLI, поэтому я сгенерировал динамическую библиотеку и попытался связать ее в консольном проекте C ++ CLR, но безуспешно получаю: Ошибка 1, ошибка LNK2020: неразрешенный токен (06000001) cBox ::. ctor pTest9.obj
Я ставлю dll (Project -> reference-> add new reference), устанавливаю включаемые файлы в проект (включаемый файл без кода)
Я не знаю, что делать (я новичок в C ++ / CLI)
спасибо за предложения / решение
Библиотечный проект объявлен как DLL
#include "stdafx.h"
using namespace System;
ref class cBox
{
public:
cBox() ;
cBox(double lv,double bv,double hv);
double Volume();
private:
double Length;
double Width;
double Height;
};
КОД БИБЛИОТЕКИ:
#include "stdafx.h"
#include "cBox.h"
cBox::cBox()
{
Console::WriteLine(L"No arg constructor called");
Length = 1.0 ;
Width = 1.0 ;
Height = 1.0 ;
}
cBox::cBox(double lv,double bv,double hv)
{
Console::WriteLine(L"Constructor called");
Length = lv;
Width = bv;
Height = hv;
}
double cBox::Volume()
{
return Length*Width*Height;
}
Затем в консольном проекте CLR я пытаюсь связать эту библиотеку, я получаю ее файл .h
#include "stdafx.h"
#include "cBox.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Test Library:\n");
cBox^ oBox; // handle of type box
oBox = gcnew cBox;
Console::WriteLine(L"Default Box Volume {0}",oBox->Volume());
return 0;
}