我正在尝试在64位Linux计算机(Linux Mint 14)上使用AngelScript。我已经安装了AngelScript sdk附带的gnuc项目,并尝试使用以下命令进行编译:

g++ -fno-strict-aliasing main.cpp -langelscript

这会导致以下链接器错误:
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadManager::asCThreadManager()':
as_thread.cpp:(.text+0x12a): undefined reference to `pthread_key_create'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadManager::~asCThreadManager()':
as_thread.cpp:(.text+0x381): undefined reference to `pthread_key_delete'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadManager::CleanupLocalData()':
as_thread.cpp:(.text+0x453): undefined reference to `pthread_getspecific'
as_thread.cpp:(.text+0x4b8): undefined reference to `pthread_setspecific'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadManager::GetLocalData()':
as_thread.cpp:(.text+0x4f7): undefined reference to `pthread_getspecific'
as_thread.cpp:(.text+0x557): undefined reference to `pthread_setspecific'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadCriticalSection::TryEnter()':
as_thread.cpp:(.text+0x6a0): undefined reference to `pthread_mutex_trylock'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::asCThreadReadWriteLock()':
as_thread.cpp:(.text+0x6c5): undefined reference to `pthread_rwlock_init'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::~asCThreadReadWriteLock()':
as_thread.cpp:(.text+0x708): undefined reference to `pthread_rwlock_destroy'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::AcquireExclusive()':
as_thread.cpp:(.text+0x722): undefined reference to `pthread_rwlock_wrlock'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::ReleaseExclusive()':
as_thread.cpp:(.text+0x73c): undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::AcquireShared()':
as_thread.cpp:(.text+0x756): undefined reference to `pthread_rwlock_rdlock'
/usr/local/lib/libangelscript.a(as_thread.o): In function `asCThreadReadWriteLock::ReleaseShared()':
as_thread.cpp:(.text+0x770): undefined reference to `pthread_rwlock_unlock'
collect2: error: ld returned 1 exit status

似乎很多事情是不确定的。我认为这是库安装的问题。

最佳答案

AngelScript需要定义一个用于线程的库。在GNU / Linux上,可以通过在编译命令中添加-lpthread来添加Posix线程来启用此功能。

09-04 18:16