Use POSIX pthreads in pkg

Hi,

I have a library which includes <pthreads.h>. I use a github repo and create a static library with Cmake. It copies it then to binddir of riot.

I basically copied another libraries Makefile, to understand how it supposed to work.

all: $(PKG_BUILDDIR)/src/Makefile $(MAKE) -C $(PKG_BUILDDIR) &&
cp $(PKG_BUILDDIR)/libiota_wallet.a $(BINDIR)/iota-wallet.a

$(PKG_BUILDDIR)/src/Makefile: $(TOOLCHAIN_FILE) cd $(PKG_BUILDDIR) &&
cmake -DCMAKE_TOOLCHAIN_FILE=$(TOOLCHAIN_FILE)
-DCCNL_RIOT=1 -DRIOT_CFLAGS="$(RIOT_CFLAGS)" -DBUILD_TESTING=OFF .

$(TOOLCHAIN_FILE): git-download $(RIOTTOOLS)/cmake/generate-xcompile-toolchain.sh > $(TOOLCHAIN_FILE)

I got another file named Makefile.dep, where I placed my dependencies:

USEMODULE += posix USEMODULE += pthread

and a Makefile.include

INCLUDES += -I$(PKGDIRBASE)/iota-wallet/src

When I start make in my application folder I get the following error message:

/home/citrullin/git/riot_libs/examples/iota_transaction_light/bin/pkg/bluepill/iota-wallet/src/iota/bundle.c: In function ‘create_bundle_bytes’: /home/citrullin/git/riot_libs/examples/iota_transaction_light/bin/pkg/bluepill/iota-wallet/src/iota/bundle.c:62:5: error: implicit declaration of function ‘pthread_mutex_lock’; did you mean ‘pthread_atfork’? [-Werror=implicit-function-declaration] pthread_mutex_lock(&iota_wallet_bundle_essence_mutex); ^~~~~~~~~~~~~~~~~~ pthread_atfork

The bundle.c and the bundle.h have:

#include <pthread.h>

So, that shouldn’t be an issue. So what did I miss. How do I make it possible that the compiler finds the pthread implementation?

Thanks for you help :slight_smile:

best regards

Philipp

Hi Philipp,

Hey Kaspar,

yes, I pushed it to my repo: https://github.com/Citrullin/RIOT/tree/iota_new_implementation/examples/iota_transaction_light

That’s the application where I use this package. I used make to compile it for my bluepill.

best regards

Philipp

Hi Philip,

yes, I pushed it to my repo: https://github.com/Citrullin/RIOT/tree/iota_new_implementation/examples/iota_transaction_light

That's the application where I use this package. I used make to compile it for my bluepill.

I quickly tried it, it compiles fine here.

What Host OS and toolchain are you using? What's the output of "dist/tools/ci/print_toolchain_versions.sh"?

Kaspar

Hi Kaspar,

I am using Ubuntu 16.04.3.

as requested, it produces the following output:

Installed compiler toolchains

Hi Kaspar,

Sorry, I didn’t pushed the change ^^ So, updated the branch. Still this branch: https://github.com/Citrullin/RIOT/tree/iota_new_implementation/examples/iota_transaction_light

best regards

Philipp