I have a project in MCUXpresso using i.MX RT1024 processor with an SDK. In a source file I'm calling the functions SSPIEm() and SSPIEm_preset() both of which are declared in ./sspiem/SSPIEm.h and defined in SSPIEm.c. When I try to build the project it fails saying that these functions are undefined. From the calls I can navagate to the function declaration in the header file. From SSPIEm.c the functions will open the declaration, but opening the definition from the header fails. In the include settings, the ./sspiem folder is defined.
Function calls look like:
#include "../sspiem/SSPIEm.h"
int runSSPIEAlgorithm()
{
int siRetCode;
siRetCode = SSPIEm_preset(_T("test.sea"), _T("test.sed"));
siRetCode = SSPIEm(0xFFFFFFFF);
return siRetCode;
}
Is there a project setting wrong to have things find the declaration in the header, but not the definition in the source?
Hi @Klozano
It seems there are something wrong when you are coding for your application base MCUXpresso project.
You can find build log after you click build, it will give you some comments.
It seems the question is about how to use some APIs(e.g SSPIEm_preset) which are declared in other *.h (e.g sspiem.h), please take care of header including setting and include in your source code, then check from build logs. Also please check here to find MCUXPresso IDE guide which is base free Eclipse and GCC-based IDE for C/C++ development, you can find more detials from MCUXpresso IDE - User Guide:https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools...
If there are still some issues, plz clarify more so that I can understand more.
Best Regards,
Sam
Hi Sam,
Thanks for reaching out. Yes, the SSPIE include folder is in the includes settings. It's also in the C/C++ General > Paths and Symbols, include and source location settings as well. This was my first thought too. I know that it is linking to that folder for the headers at least, because if I move the function definitions to the SSPIEm.h file from the SSPIEm.c file, the errors for finding those two functions resolve, but move to the functions that they call. I've included the build logs for both cases below.
At the location trying to call those functions I can right click and open declaration, which takes me to the SSPIEm.h function declaration. Likewise, from the SSPIEm.c function definitions I can do the same. I notice though that from the SSPIEm.h header, I cannot go from the declaration to the definition.
In the normal set up with the declaration in the header and definition in the source the functions in interface.h/c will navigate back and forth between definition and declaration. When the SSPIEm.h header includes the definition of the functions in question and the needed includes as well, the interface.h stops navigating to its definition with the right click, and those functions are declared as undefined instead of the ones in SSPIEm.h. It's almost like the headers are found in that folder but not the source files?
Having the path to the sspiem file not be a workspace path and hard mapped to the specific directory makes no difference.
Hi @Klozano
1. From the build log you provided, the header files of your sspiem have be included yet as below(compile log).
-I"C:\Users\klozano\Documents\GiTea\CentPlus\CentPlus_1650_LaC_MCU\sspiem"
2. Link error shows "multiple definition", "undefined reference" in some dedicated files which developed from your side, please try to fix them based on the build logs, this is coding error and not related to IDE.
./sspiem/SSPIEm.o ./sspiem/core.o ./sspiem/hardware.o ./sspiem/intrface.o ./sspiem/main.o ./sspiem/util.o
arm-none-eabi/bin/ld.exe: ./sspiem/main.o: in function `SSPIEm': ../sspiem/SSPIEm.h:41: multiple definition of `SSPIEm'; ./sspiem/SSPIEm.o:../sspiem/SSPIEm.h:41: first defined here
arm-none-eabi/bin/ld.exe: ./source/fpga.o: in function `SSPIEm_preset(char const*, char const*)':
../source/../sspiem/SSPIEm.h:25: undefined reference to `algoPreset(char const*)'
arm-none-eabi/bin/ld.exe: ../source/../sspiem/SSPIEm.h:27: undefined reference to `dataPreset(char const*)'
arm-none-eabi/bin/ld.exe: ./source/fpga.o: in function `SSPIEm(unsigned int)':
../source/../sspiem/SSPIEm.h:43: undefined reference to `SSPIEm_init(unsigned int)'
arm-none-eabi/bin/ld.exe: ../source/../sspiem/SSPIEm.h:46: undefined reference to `SSPIEm_process(unsigned char*, unsigned int)'
collect2.exe: error: ld returned 1 exit status