链接器错误:对符号“pthread_rwlock_trywrlock@glibc_2.2.5”的未定义引用

时间:2021-08-10 05:31:00

I've been developing with CentOS, Qt 4.7, and GCC 4.4

我一直在开发CentOS, Qt 4.7和GCC 4.4

I've just installed Red Hat Developer Toolset 1.1 which includes GCC 4.7.2, and at the end of make, I get an error

我刚刚安装了Red Hat Developer Toolset 1.1,其中包含GCC 4.7.2,在make的最后,我得到一个错误

/usr/bin/ld: ../../bin/Solo: undefined reference to symbol 'pthread_rwlock_trywrlock@@GLIBC_2.2.5'
/usr/bin/ld: note: 'pthread_rwlock_trywrlock@@GLIBC_2.2.5' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

I'm guessing that Qt threads is referencing to that. How can I fix it?

我猜Qt线程正在引用它。我怎样才能修好它呢?

4 个解决方案

#1


14  

You want to compile with -pthread which does more than just link with libpthread:

您希望使用-pthread进行编译,它不仅仅是链接到libpthread:

Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.

使用pthreads库添加对多线程的支持。此选项为预处理器和链接器设置标志。

#2


4  

Read the note: try to add /lib64/libpthread.so.0 into Makefile (-lpthread after gcc command, or /lib64/libpthread.so.0 after ld (or after gcc -shared)), or something like LIB += -lpthread if there's such definition somewhere.

阅读注释:尝试添加/lib64/ libpthreadso。0进入Makefile (gcc命令后的-lpthread,或/lib64/ libpthreadso。0在ld之后(或gcc -shared之后),或者像LIB += -lpthread之类的东西,如果有这样的定义的话。

See also: Adding external library into Qt Creator project and http://www.qtcentre.org/threads/39144-How-to-add-a-lib-to-a-qt-project

参见:在Qt Creator项目和http://www.qtcentre.org/threads/39144- how -to-add- libto -a- Qt项目中添加外部库

Btw, post your Makefile, so somebody will be able to point to exact line.

顺便说一句,发布你的Makefile,这样别人就可以指出确切的行了。

#3


3  

You just need to add CONFIG += thread to your .pro file.

您只需将CONFIG += thread添加到.pro文件中。

#4


0  

In my little laptop Linux (where I have a mixed bag of libraries), I just had to add

在我的小笔记本Linux(我有一个混合的库包)中,我需要添加一些东西

LDFLAGS=-lpthread

AT THE END of the configure command arguments.

在configure命令参数的末尾。

After that, make did its job perfectly (With the existing libraries).

之后,make完成了它的工作(使用现有的库)。

#1


14  

You want to compile with -pthread which does more than just link with libpthread:

您希望使用-pthread进行编译,它不仅仅是链接到libpthread:

Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.

使用pthreads库添加对多线程的支持。此选项为预处理器和链接器设置标志。

#2


4  

Read the note: try to add /lib64/libpthread.so.0 into Makefile (-lpthread after gcc command, or /lib64/libpthread.so.0 after ld (or after gcc -shared)), or something like LIB += -lpthread if there's such definition somewhere.

阅读注释:尝试添加/lib64/ libpthreadso。0进入Makefile (gcc命令后的-lpthread,或/lib64/ libpthreadso。0在ld之后(或gcc -shared之后),或者像LIB += -lpthread之类的东西,如果有这样的定义的话。

See also: Adding external library into Qt Creator project and http://www.qtcentre.org/threads/39144-How-to-add-a-lib-to-a-qt-project

参见:在Qt Creator项目和http://www.qtcentre.org/threads/39144- how -to-add- libto -a- Qt项目中添加外部库

Btw, post your Makefile, so somebody will be able to point to exact line.

顺便说一句,发布你的Makefile,这样别人就可以指出确切的行了。

#3


3  

You just need to add CONFIG += thread to your .pro file.

您只需将CONFIG += thread添加到.pro文件中。

#4


0  

In my little laptop Linux (where I have a mixed bag of libraries), I just had to add

在我的小笔记本Linux(我有一个混合的库包)中,我需要添加一些东西

LDFLAGS=-lpthread

AT THE END of the configure command arguments.

在configure命令参数的末尾。

After that, make did its job perfectly (With the existing libraries).

之后,make完成了它的工作(使用现有的库)。