简体   繁体   English

IAR 错误[Li005]:即使文件已添加到项目中并且文件路径在预处理器路径中,也没有函数定义

[英]IAR Error[Li005] : no definition for function even though the file is added in the project and the path to the file is in the pre-processor paths

I am having a strange problem.我有一个奇怪的问题。 I am trying to integrate the spi module from Nordic Semiconductors peripherals examples with the Central BLE Uart project.我正在尝试将 Nordic Semiconductors 外设示例中的 spi 模块与 Central BLE Uart 项目集成。

There is a library of component common to all the examples.有一个所有示例通用的组件库。 So what I did is add the spi_slave file nrf_drv_spis.c to my project, and added the path to that component in the preprocessor paths of the project.所以我所做的是将 spi_slave 文件nrf_drv_spis.c添加到我的项目中,并在项目的预处理器路径中添加该组件的路径。

$PROJ_DIR$\\..\\..\\..\\..\\..\\..\\..\\components\\drivers\\nrf_spi_slave is in my preprocessor paths and this is where nrf_drv_spis.c and nrf_drv_spis.h are. $PROJ_DIR$\\..\\..\\..\\..\\..\\..\\..\\components\\drivers\\nrf_spi_slave在我的预处理器路径中,这就是nrf_drv_spis.cnrf_drv_spis.h 所在的位置。

However, when I compiled the code, I get this error但是,当我编译代码时,出现此错误

Error[Li005]: no definition for "nrf_drv_spis_init" [referenced from D:\Repo\ble_projects\nRF5_SDK_12.3.0\examples\ble_central\ble_app_uart_c\pca10028\s130\iar\_build\main.o] 

nrf_drv_spis_init is a function found in nrf_drv_spis.c and the prototype is in nrf_drv_spis.h . nrf_drv_spis_init 是在nrf_drv_spis.c 中找到的函数,原型在nrf_drv_spis.h 中 The odd thing as well is that when I right click on nrf_drv_spis_init and "go to the definition", it always bring me to the prototype in the header file.奇怪的是,当我右键单击 nrf_drv_spis_init 并“转到定义”时,它总是将我带到头文件中的原型。 Normally, IAR presents me with either the prototype or the definition of the function and I need to click either the declaration or the prototype.通常,IAR 向我显示函数的原型或定义,我需要单击声明或原型。

So it does shows me that for whatever reason, the file nrf_drv_spis.c doesn't seem to be in the project, but I don't know what to do to fix this.所以它确实告诉我,无论出于何种原因,文件nrf_drv_spis.c似乎不在项目中,但我不知道如何解决这个问题。

Any help would be appreciated.任何帮助,将不胜感激。 Thanks.谢谢。

So the issue here is that I missed that in another crucial header file, some definitions were behind a #ifdef and thus when compiling the code, the right files weren't included.所以这里的问题是我在另一个关键的头文件中错过了这一点,一些定义在#ifdef 后面,因此在编译代码时,没有包含正确的文件。

Setting the right parameters made the code to compile correctly.设置正确的参数使代码能够正确编译。

I had the same issue, and the problem was global argument that I defined in the .h file (with extern).我遇到了同样的问题,问题是我在 .h 文件中定义的全局参数(使用 extern)。 When I moved them to the .c file it solved the problem.当我将它们移动到 .c 文件时,它解决了问题。 I don't understand why, but it worked.我不明白为什么,但它奏效了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尽管函数定义存在于包含路径的头文件中,但C ++中出现“未定义引用”错误 - 'Undefined reference to' error in C++ although function definition exists in header file in include path 将函数添加到先前链接文件后出现多个定义链接器错误 - multiple definition linker error after adding a function to a previously linking file 即使函数存在char *,仍然存在未解析的外部符号错误 - unresolved external symbol error even though the function exists char* 在C ++共享对象文件中找到完整的函数定义 - Find the complete function definition inside C++ shared object file 项目文件夹c ++中没有任何.cpp文件的main的多个定义 - Multiple definition of main without any .cpp file in project folder c++ 使用标头在turbo c项目文件中的链接器错误 - linker error in turbo c project file using header 为什么在头文件中声明和在文件中定义会出现多个定义错误? - Why does Declaring in header file and defining in file gives multiple definition error? 为什么即使在编译了我的 header 文件后,我仍然会收到 linker 错误? - Why do I keep getting a linker error even after compiling my header file? 在#Include指令中使用C文件时,C程序中出现错误(多个定义错误) - Error in C program when using a C file in #Include directive (Multiple definition error) 即使nm报告存在符号,运行时符号查找错误 - Symbol lookup error at runtime even though nm reports symbol present
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM