Search code examples
cpthreadsopenwrt

OpenWrt SDK custom package 'make' fails because of missing libpthread.so.0


So I wrote a program to run on a Tp-link device running OpenWrt Attitude Adjustment 12.09.

I wrote the makefiles successfully in the /OpenWrt-SDK../package/myprogram/src/Makefile and it all ran smoothly when I did a 'make'.

Now I added threads in my program so I configured the Makefile like this:

# build myprogram executable when user executes "make"
LDFLAGS=-pthread

myprogram: myprogram.o
    $(CC) $(LDFLAGS) myprogram.o -o myprogram
myprogram.o: myprogram.c
    $(CC) $(CFLAGS) -c myprogram.c

# remove object files and executable when user executes "make clean"
clean:
    rm *.o myprogram

and when I 'make' inside the package/myprogram/src folder it compiles successfully and runs just fine on my PC.

Now when I go to the root OpenWrt-SDK directory to 'make' I get a missing dependencies error:

Package myprogram is missing dependencies for the following libraries:
libpthread.so.0

So what do I need to do to include these dependencies?

I went to my OpenWrt-SDK root and tried:

./scripts/feeds search libpthread

And I got this result:

./scripts/feeds search libpthread
Search results in feed 'trunk':
libpthread                  POSIX thread library

Should I install that or is that not it? I do not know if I am doing something else wrong.

I will appreciate any help! Thanks.


Solution

  • Under package definition add

    DEPENDS:=+libpthread