2015-05-19 16 views
-3
#include "stdafx.h"       //In order to use Visual C++ 

#include <iostream> 
#include <Loki\SmallObj.h>     //The header file to manage 
               // smalls objects allocator 

class MySmallObj : public Loki::SmallObjAllocator //inherit from the base 
                //class SmallObjAllocator 
{ 
public: 
    MySmallObj():SmallObjAllocator(sizeof(char), sizeof(long),0){}; 
}; 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    MySmallObj * premier = new MySmallObj;              //declaring my object derived from smallobjallcator 
    char * myChar = static_cast<char*>(premier->Allocate(1, true));   //calling allocate from my object and conveting the void pointer to char* 
    premier.Deallocate(myChar, 1); 

    return 0; 
} 

Библиотека Локи использует в основном родовое программирование на C++ Я получил код там, используя небольшой объект распределителем памяти (Loki :: SmallObjAllocator) Я использую Visual C++ 2010Локи из памяти

Я получаю эти ошибки:

> MyLoki.cpp 
1>MyLoki.obj : error LNK2019: unresolved external symbol "public: void __thiscall Loki::SmallObjAllocator::Deallocate(void *,unsigned int)" ([email protected]@[email protected]@[email protected]) referenced in function _wmain 
1>MyLoki.obj : error LNK2019: unresolved external symbol "public: void * __thiscall Loki::SmallObjAllocator::Allocate(unsigned int,bool)" ([email protected]@[email protected]@[email protected]) referenced in function _wmain 
1>MyLoki.obj : error LNK2019: unresolved external symbol "protected: __thiscall Loki::SmallObjAllocator::SmallObjAllocator(unsigned int,unsigned int,unsigned int)" ([email protected]@@[email protected]@Z) referenced in function "public: __thiscall MySmallObj::MySmallObj(void)" ([email protected]@[email protected]) 
+0

H Вы добавили конфигурацию для ссылки на libs? – EdChum

+1

Соблазн отметить это как дубликат «что такое неразрешенная ошибка внешнего символа и как его решить». –

+0

ваш первый вопрос @EdChum должен знать, связал ли я библиотеку с компилятором ? Да. – Ninda

ответ

0

Я основал ответ на свой первый вопрос.

#include "stdafx.h"       //In order to use Visual C++ 

#include <iostream> 
#include <Loki\SmallObj.h>     //The header file to manage 
               // smalls objects allocator 

class MySmallObj : public Loki::SmallObjAllocator //inherit from the base 
                //class SmallObjAllocator 
{ 
public: 
    MySmallObj():SmallObjAllocator(sizeof(char), sizeof(long),1){}; //the chunkSize < maxObjsize 
}; 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    MySmallObj * premier = new MySmallObj;              //declaring my object derived from smallobjallcator 
    char * myChar = static_cast<char*>(premier->Allocate(1, true));   //calling allocate from my object and conveting the void pointer to char* 
    premier->Deallocate(myChar, 1); 

    return 0; 
} 

ошибки множественных

неразрешенный внешний символ

являются из SmallObj.cpp, Локи, который не был включен в проект

, например Локи :: SmallObjAllocator, Loki :: SmallObject here

 Смежные вопросы

  • Нет связанных вопросов^_^