Setting OCPI_LIB_DIR and OCPI_EXPORT_DYNAMIC

I am trying to build an ACI application with a makefile, following the instructions in the application development guide page 61.
The build is failing stating that it cannot find any of the OCPI libs since the env variable OCPI_LIB_DIR is not set. Checking the other OCPI variables I can see that OCPI_EXPORT_DYNAMIC is also not set, all others appear to be set correctly.

The part of my makefile that adds things specific to openCPI is as follows:

include $(OCPI_CDK_DIR)/include/ocpisetup.mk
OCPI_PREREQUISITES_LIBS := lzma gmp gpsd ad9361
OCPI_API_LIBS := application remote_support container library msg metadata transport xfer drc drc_ad9361 base util foreign os
CFLAGS += $(OCPI_EXPORT_DYNAMIC)
LIB += -L $(OCPI_LIB_DIR) $(OCPI_API_LIBS:%=-locpi_%) \
$(OCPI_PREREQUISITES_LIBS:%=$(OCPI_LIB_DIR)/lib%.a) \
$(OCPI_SYSTEM_LIBS:%=-l%)

I had this working previously with the same makefile so I’m assuming there is some script that needs to be run to set these correctly.

Thanks,
Dan

I believe I have found the root of the issue but not sure what the solution is.
It appears that the OCPI_INC_DIR variable is not being set correctly
I added the following rule to my makefile:

printenv:
	@echo "OCPI_CDK_DIR: " $(OCPI_CDK_DIR)
	@echo "OCPI_INC_DIR: " $(OCPI_INC_DIR)
	@echo "OCPI_LIB_DIR: " $(OCPI_LIB_DIR)
	@echo "OCPI_EXPORT_DYNAMIC: " $(OCPI_EXPORT_DYNAMIC)

And get the following output:

OCPI_CDK_DIR:  /home/dwp/git/opencpi/cdk
OCPI_INC_DIR:  /home/dwp/git/opencpi/cdk/include/aci OCPI_LIB_DIR=/home/dwp/git/opencpi/cdk/ubuntu22_04/lib OCPI_EXPORT_DYNAMIC=-Xlinker -export-dynamic -Wl,-z,relro -Wl,-z,now OCPI_API_LIBS=application remote_support container library msg_driver_interface metadata transport xfer util foreign os OCPI_SYSTEM_LIBS=rt dl pthread OCPI_PREREQUISITES_LIBS=lzma gmp gpsd
OCPI_LIB_DIR: 
OCPI_EXPORT_DYNAMIC:

Workaround solution was to add the following to the makefile to set the variables manually.
Do this after include $(OCPI_CDK_DIR)/include/ocpisetup.mk

OCPI_INC_DIR := /home/dwp/git/opencpi/cdk/include/aci
OCPI_LIB_DIR := /home/dwp/git/opencpi/cdk/ubuntu22_04/lib
OCPI_EXPORT_DYNAMIC := -Xlinker -export-dynamic -Wl,-z,relro -Wl,-z,now
OCPI_API_LIBS := application remote_support container library msg metadata transport xfer drc drc_ad9361 base util foreign os
OCPI_SYSTEM_LIBS := rt dl pthread
OCPI_PREREQUISITES_LIBS := lzma gmp gpsd ad9361

Had a mess with this today, and I’m unable to replicate your output.

I made the following Makefile (/tmp/makefile.mk):

include $(OCPI_CDK_DIR)/include/ocpisetup.mk

$(info OCPI_CDK_DIR: $(OCPI_CDK_DIR))
$(info OCPI_INC_DIR: $(OCPI_INC_DIR))
$(info OCPI_LIB_DIR: $(OCPI_LIB_DIR))
$(info OCPI_EXPORT_DYNAMIC: $(OCPI_EXPORT_DYNAMIC))
$(info OCPI_API_LIBS: $(OCPI_API_LIBS))
$(info OCPI_SYSTEM_LIBS: $(OCPI_SYSTEM_LIBS))
$(info OCPI_PREREQUISITES_LIBS: $(OCPI_PREREQUISITES_LIBS))

I then manually set OCPI_CDK_DIR and ran it:

export OCPI_CDK_DIR=/home/opencpi/opencpi/cdk
make -f /tmp/makefile.mk

This caused an error:

/home/opencpi/opencpi/cdk/include/ocpisetup.mk:28: *** missing separator.  Stop.

After some messing around it looks like this is because cdk/opencpi-setup.sh -r can produce text on stdout, so I edited ocpisetup.mk to pipe it to /dev/null:

diff --git a/tools/include/ocpisetup.mk b/tools/include/ocpisetup.mk
index f17db7c97..16cd84299 100644
--- a/tools/include/ocpisetup.mk
+++ b/tools/include/ocpisetup.mk
@@ -26,4 +26,4 @@ define OCPI_NL

 endef
 $(eval $(subst ;,$(OCPI_NL),\
-  $(shell source $(OCPI_CDK_DIR)/opencpi-setup.sh -r &> /dev/null; make -n -r -s -f $(OCPI_CDK_DIR)/include/setup-target-platform.mk ShellExternalVars=1)))
+  $(shell source $(OCPI_CDK_DIR)/opencpi-setup.sh -r; make -n -r -s -f $(OCPI_CDK_DIR)/include/setup-target-platform.mk ShellExternalVars=1)))

Note: This change might not be necessary for you. On the OpenCPI branch I tested this on I’ve made edits to the cdk/opencpi-setup.sh script, so this might be due to my changes.

After making this change, running the makefile again produces this:

OCPI_CDK_DIR: /home/opencpi/opencpi/cdk
OCPI_INC_DIR: /home/opencpi/opencpi/cdk/include/aci
OCPI_LIB_DIR: /home/opencpi/opencpi/cdk/arch/lib
OCPI_EXPORT_DYNAMIC: -Xlinker -export-dynamic -Wl,-z,relro -Wl,-z,now
OCPI_API_LIBS: application remote_support container library  msg_driver_interface metadata transport xfer util foreign os
OCPI_SYSTEM_LIBS: rt dl pthread
OCPI_PREREQUISITES_LIBS: lzma gmp gpsd

Some of the libs listed are different to yours, but I think that’s because I did this on an older commit, and I don’t know the build state of the repo.