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

undefined reference to pthread, for examples #110

Open
cantbothertoshave opened this issue Jun 28, 2022 · 3 comments
Open

undefined reference to pthread, for examples #110

cantbothertoshave opened this issue Jun 28, 2022 · 3 comments

Comments

@cantbothertoshave
Copy link

I am trying to cross-compile this for arm-linux-gnueabihf (raspberry pi), so I created a toolchain file setting compilers, assembler, linker etc to those prefixed toolchain binaries.

The library builds.

When I try "make timer.fcgi" (or other examples), it gives me a linker error: undefined reference to 'pthread_cond_clockwait' and 'pthread_create'.

Now I know pthread-related linker errors when quickly setting up an own little project and just add an option to statically link that.
But this shouldn't happen here, right?
Is there a conceivable way of how that can happen due to the cross-compilation setup missing something?
I'm not exactly experienced in CMake.

@cantbothertoshave
Copy link
Author

Ok, feeling like a monkey poking an ant hill with a stick, I found, in CMakeLists.txt the loop where it goes through the examples, i.e. line 213: target_link_libraries(${EXAMPLE}.fcgi PRIVATE Fastcgipp::fastcgipp pthread) --- I added that "pthread", and then it all builds.
But for timer.fcgi, there are a bunch of warnings relating to std containers, something about "parameter passing changed in GCC 7.1" and such.
I was using GCC 10.2 (cross compiler for arm-linux-gnueabihf, running on Debian11 in a VirtualBox VM on an Intel i7 laptop)

@Erroneous1
Copy link
Contributor

Make sure your cmake project is doing find_package(Fastcgipp) and that you're calling target_link_libraries(targetname PRIVATE Fastcgipp::fastcgipp) (could be public if needed). Fastcgi++ requires C++20 and the Threads cmake target which should be automatically linked to your target if you link to the Fastcgipp::fastcgipp target.

If you need to manually set your flags you'll want to add -std=c++20 and -lpthread for linux systems on GCC and Clang.

@rockingdice
Copy link

Make sure your cmake project is doing find_package(Fastcgipp) and that you're calling target_link_libraries(targetname PRIVATE Fastcgipp::fastcgipp) (could be public if needed). Fastcgi++ requires C++20 and the Threads cmake target which should be automatically linked to your target if you link to the Fastcgipp::fastcgipp target.

If you need to manually set your flags you'll want to add -std=c++20 and -lpthread for linux systems on GCC and Clang.

this DEFINITELY should be in the README file! @eddic

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

No branches or pull requests

3 participants