0

I am trying to port AprilTags to the Pi Pico. This has a dependancy on pthreads.

As is outlined in this SO question pthreads needs a posix layer. However there is this youtube video showing it working on the pico with the ardunio SDK on effectively bare metal?

How does the ardunio libary work around needing posix?

I am asking this with a view to using the native C/C++ SDK.


What I have tried: I've tried adding this to the top of the CMakeLists.txt file in my AprilTags checkout:

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

And changing the libarry type to be static on line 31:

add_library(${PROJECT_NAME} STATIC ${APRILTAG_SRCS} ${COMMON_SRC} ${TAG_FILES})

Which seems to run cmake just fine as a subdirectory in my main project however when running make -j4 I get:

[ 39%] Linking C static library libapriltag.a
[ 39%] Built target apriltag
make: *** [Makefile:130: all] Error 2

I understand that this means the build has encountered a problem in building however I'm not sure how to know what the problem is.

4
  • 1
    Too may questions.
    – joan
    Apr 1, 2021 at 20:52
  • I have reduced the number of questions to be more specific. Apr 2, 2021 at 8:22
  • The "*** Error" part here may or may not get logged to the display at exactly the point where/when the problem occured, partially because if you are on a multi-core system there will be different parts getting built in parallel, but there is only one display stream, so it appears to be events running in a seqence. My point is that there are no errors in the output you've posted; to find out what went wrong specifically you'd have to look back up through that output. Using cmake -j 1 will simplify this, as will directing stdout to a file or null (so you only see the stderr stuff).
    – goldilocks
    Mar 27, 2023 at 19:10
  • To clarify my last point: The cmake output you have posted does not include what specifically caused the error. If you want to find that, use cmake ... > /dev/null. This will redirect non-errors to nowhere, and you will only see errors. If you post that, there is a good chance someone can tell you what the problem is; linker errors are generally easy to remedy. Short of that, you're waiting for someone to come along who has done this and will post exact instructions for you, which may never happen.
    – goldilocks
    Apr 3, 2023 at 15:43

1 Answer 1

0

From man make.

A status of two will be returned if any errors were encountered.

1
  • Thank you for the response. My problem is more that I don't understand why it is erroring. I'm still fairly new to Makefiles and C in general and I am not quite sure what is the correct process to drill down and find out why. If it is line 130 in the top level make file causing the problem then line causing the error is $(MAKE) -f CMakeFiles/Makefile2 all. But I don't know how to find out why this is causing the error. Apr 2, 2021 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.