DSP Header Files Are Not Found

New to XMOS and XCore? Get started here.
student_researcher
Junior Member
Posts: 6
Joined: Sat Mar 13, 2021 7:29 pm

DSP Header Files Are Not Found

Post by student_researcher »

Hello,
I am trying to use the DSP library for my XCORE-200 MC Audio. I am using the DSP library which I obtained from here: https://github.com/xmos/lib_dsp/tree/master
My method of importing the library to my workspace is as follows: download the Zip from GitHub, extract the zip to the workspace location, and use xTimeComposer to import an existing project into the workspace.
The Zip I downloaded comes with many examples that use lib_dsp. I am able to successfully run several of these examples (i.e. app_adaptive). However, when I #include <dsp.h> in my project and build it, I receive errors:

Code: Select all

xmake CONFIG=Default all 
Checking build modules
WARNING: Required version of lib_i2c is >=4.0.0 and actual version has greater major version: 5.0.0. There could be API incompatibilities.
WARNING: Required version of lib_i2s is >=2.2.0 and actual version has greater major version: 3.0.0. There could be API incompatibilities.
WARNING: Required version of lib_logging is >=2.1.0 and actual version has greater major version: 3.1.0. There could be API incompatibilities.
Using build modules: lib_dsp(6.2.0) lib_gpio(1.1.0) lib_i2c(5.0.0) lib_i2s(3.0.0) lib_logging(3.1.0) lib_xassert(3.0.0)
Analyzing dsp_adaptive.c
"C:\Program Files (x86)\XMOS\xTIMEcomposer\Community_14.4.1\build\xcommon\module_xcommon/build/mkdir.bat"  .build _l_dsp src  > nul 2>&1
cd .build && xcc -pre-compilation-analysis  -O2 -report -g     -DCONFIG=Default      @_iflag.rsp "C:/Users/user/Documents/Research/Active Noise Canceling/xTime Workspace/lib_dsp-6.2.0/lib_dsp-6.2.0/lib_dsp/src/dsp_adaptive.c" -x none ".././src/XR-AUDIO-216-MC.xn"  "..\.\config.xscope" -o "../.build/_l_dsp/src/dsp_adaptive.c.pca.xml.decouple" > nul
C:/Users/user/Documents/Research/Active Noise Canceling/xTime Workspace/lib_dsp-6.2.0/lib_dsp-6.2.0/lib_dsp/src/dsp_adaptive.c:5:10: fatal error: 'dsp_qformat.h' file not found
#include "dsp_qformat.h"
         ^
1 error generated.
xmake[1]: *** [.build/_l_dsp/src/dsp_adaptive.c.pca.xml.decouple] Error 1
xmake: *** [analyze] Error 2

13:34:31 Build Finished (took 5s.983ms)
So the error seems to show that there is an issue with the file dsp_adaptive.c because it cannot find one of the lib_dsp header files - dsp_qformat.h. But why would dsp_adaptive.c not work for my project, but work for the examples? There must be an issue including the header file locations in my project, but I can not find what it is.

What I have tried:

As a temporary fix to this problem, I can modify dsp_adaptive.c and change the line from "#include dsp_qformat.h" to "#include "../api/dsp_qformat.h". Then the error will go away, but the next header file (dsp_math.h) in dsp_adaptive will give a similar issue. So I can prefix the ../app/ path to every header include statement, but then a different file than dsp_adaptive gives me problems. So I do not think this is an appropriate fix.

I have also examined my projects properties -> C/C++ General -> Paths and Symbols -> Include directories and verified that /lib_dsp and /lib_dsp/src and /lib_dsp/api are all present.

How can I successfully build my project with this library and use the header files? Thank you.
User avatar
akp
XCore Expert
Posts: 580
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Did you add the library to your Makefile?
student_researcher
Junior Member
Posts: 6
Joined: Sat Mar 13, 2021 7:29 pm

Post by student_researcher »

Yes, I did. Here is my Makefile:

Code: Select all

# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling
TARGET = XR-AUDIO-216-MC

# The APP_NAME variable determines the name of the final .xe file. It should
# not include the .xe postfix. If left blank the name will default to
# the project name
APP_NAME = 

# The USED_MODULES variable lists other module used by the application.
USED_MODULES = lib_dsp(>=6.0.0) lib_gpio(>=1.1.0) lib_i2c(>=4.0.0) lib_i2s(>=2.2.0) lib_logging

# The flags passed to xcc when building the application
# You can also set the following to override flags for a particular language:
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
# xcc for the final link (mapping) stage.
XCC_FLAGS = -O2 -report -g

# The VERBOSE variable, if set to 1, enables verbose output from the make system.
VERBOSE = 1

CONFIG = complex all


test: bin/i2s_loopback_demo.xe
	xsim bin/i2s_loopback_demo.xe --plugin LoopbackPort.dll '-port tile[0] XS1_PORT_1D 1 0 -port tile[1] XS1_PORT_1E 1 0'

XMOS_MAKE_PATH ?= ../..
-include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

INCLUDE_DIRS = 
student_researcher
Junior Member
Posts: 6
Joined: Sat Mar 13, 2021 7:29 pm

Post by student_researcher »

Ope, just realized my mistake :)

My issue was that the folder structure of the library was lib_dsp6.2 -> lib_dsp6.2 -> lib_dsp + examples + other stuff.
So I guess the example projects could see the actual library, but my project was one folder removed from the library. So I deleted the arbitrary lib_dsp6.2 folder and it built perfectly!

Thanks for the help.