2

最近我正在尝试在 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)' 的引用

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

编辑 :

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

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

所以剩下的唯一问题是:我需要正确编写这个新函数!!!!要做到这一点,任何文件都可以给我一个线索?!

编辑2:

根据本网站信息:

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);
}  

然后工作就完成了。

4

1 回答 1

3

但在原始站点推荐这个>> 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];
}
于 2018-02-20T15:19:22.593 回答