Skip to content

Fix compilation issues for OpenFST 1.8.4#4984

Open
weimeng23 wants to merge 1 commit into
kaldi-asr:masterfrom
weimeng23:fix-openfst-compile
Open

Fix compilation issues for OpenFST 1.8.4#4984
weimeng23 wants to merge 1 commit into
kaldi-asr:masterfrom
weimeng23:fix-openfst-compile

Conversation

@weimeng23

Copy link
Copy Markdown

Summary

This PR fixes an OpenFst build failure in tools/Makefile by explicitly linking pthread when configuring OpenFst.

On some Linux environments, building OpenFst 1.8.4 may fail while linking OpenFst binaries such as fstepsnormalize, with errors like:

undefined reference to `pthread_rwlock_wrlock'
undefined reference to `pthread_rwlock_unlock'
undefined reference to `pthread_rwlock_rdlock'

These symbols are used through C++ threading primitives, for example std::shared_mutex, but pthread was not explicitly passed to the OpenFst configure/link step.

Change

This PR updates the OpenFst configure command in tools/Makefile to include pthread flags:

CXXFLAGS="$(openfst_add_CXXFLAGS) $(CXXFLAGS) -pthread" \
LDFLAGS="$(LDFLAGS) -pthread" \
LIBS="-ldl -lpthread"

Why

-pthread ensures the compiler and linker are both aware of pthread usage, while -lpthread makes sure the pthread library is available during the final link step.

Without this, OpenFst may compile successfully but fail at the binary linking stage on systems where pthread is not pulled in implicitly.

Testing

Tested by rebuilding OpenFst from a clean state:

cd tools
rm -rf openfst openfst-1.8.4 openfst_compiled
make openfst

After this change, OpenFst builds successfully without the unresolved pthread_rwlock_* references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant