如何建立东方图书馆

时间:2016-11-29 00:53:07

标签: c++ linux eastl

最近我试图在Linux 3.10 x86_64中构建eastl库但是失败了。

https://github.com/electronicarts/EASTL

有"编译来源"网页:

https://github.com/electronicarts/EASTL/blob/master/CONTRIBUTING.md

按照说明操作并获取libEASTL.a,ar -t libEASTL.a get:

allocator_eastl.cpp.o
assert.cpp.o
fixed_pool.cpp.o
hashtable.cpp.o
intrusive_list.cpp.o
numeric_limits.cpp.o
red_black_tree.cpp.o
string.cpp.o
thread_support.cpp.o

然后是一个很小的测试来源:

#include <EASTL/vector.h>
#include <EASTL/fixed_vector.h>
int main()
{
    eastl::fixed_vector<int,10,true> v ;
    int iarr[10]  ;
    for(int idx=0;idx<10;idx++){
        iarr[idx] = idx + 1 ;
        v.push_back( iarr[idx] ) ;
    }
}

编译:

g ++ --std = c ++ 11 -O2 test1.cpp -I / home / mars / tools / EASTL-master / include -I / home / mars / tools / EASTL-master / test / packages / EABase / include / Common /home/mars/tools/EASTL-master/thelib/libEASTL.a -o test1.exe

会收到链接错误:

未定义对`operator new []的引用(unsigned long,char const *,int,unsigned int,char const *,int)&#39;

eastl库应该有一个简单的方法来构建和包含头文件, 我很想念,任何建议都非常感谢。

编辑:

添加此新功能后,链接错误消失了!!!

void* operator new[](size_t size, const char* pName, 
int flags, unsigned debugFlags, const char* file, int line)
{
    ;
}

所以剩下的唯一问题是:我需要对这个新功能进行编码!!!! 要做到这一点,任何文件都可以给我一个线索?!

Edit2:

根据本网站信息:

https://wuyingren.github.io/howto/2016/02/11/Using-EASTL-in-your-projects/

void* operator new[](size_t size, const char* pName, int flags, unsigned     debugFlags, const char* file, int line) 
{
    return malloc(size);
}  

void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* pName, int flags, unsigned debugFlags, const char* file, int line) 
{
    return malloc(size);
}  

然后工作就完成了。

1 个答案:

答案 0 :(得分:0)

但在原始网站上推荐此&gt;&gt; https://github.com/electronicarts/EASTL/blob/master/doc/CMake/EASTL_Project_Integration.md#setting-up-your-code

void* operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line)
{
    return new uint8_t[size];
}
相关问题