Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build for android failed due to unable to find library -lpthread #193

Closed
leleliu008 opened this issue Nov 11, 2021 · 4 comments
Closed

build for android failed due to unable to find library -lpthread #193

leleliu008 opened this issue Nov 11, 2021 · 4 comments
Labels
bug Something isn't working pr welcome Please contribute a pull request

Comments

@leleliu008
Copy link
Contributor

leleliu008 commented Nov 11, 2021

android has no separated libpthread, it is included in libc

reference:https://developer.android.com/ndk/guides/stable_apis#c_library

in android.toolchain.cmake has folloing code which can be used to check if is Android platform

set(CMAKE_SYSTEM_NAME Android)
@leleliu008 leleliu008 added the bug Something isn't working label Nov 11, 2021
@zeux zeux added the pr welcome Please contribute a pull request label Nov 11, 2021
@zeux
Copy link
Collaborator

zeux commented Nov 12, 2021

Note that lpthread is only needed by the CLI, which I wouldn't necessarily expect to build with the NDK? If you do need the CLI, feel free to submit a PR that fixes this.

@leleliu008
Copy link
Contributor Author

leleliu008 commented Nov 13, 2021

there are two workaround, I would like to known which do fou prefer?

1

if (UNIX)
    find_library(LIBPTHREAD pthread)
    if (LIBPTHREAD)                      
         target_link_libraries(Luau.Repl.CLI PRIVATE pthread)
    endif()
endif()

2

if (UNIX)
    if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL Andriod)          
         target_link_libraries(Luau.Repl.CLI PRIVATE pthread)
    endif()
endif()

@zeux
Copy link
Collaborator

zeux commented Nov 14, 2021

Either of these is probably fine. The first one seems a bit cleaner.

@zeux
Copy link
Collaborator

zeux commented Nov 15, 2021

Fixed by #203.

@zeux zeux closed this as completed Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr welcome Please contribute a pull request
Development

No branches or pull requests

2 participants