Microchip 链接器问题

发布于 2024-07-17 10:16:28 字数 1323 浏览 4 评论 0原文

当我尝试在 MPLAB 中构建我的项目时,我收到此构建错误消息。

    Clean: Deleting intermediary and output files.
Clean: Deleted file "M:\12 CCP PWM\12 CCP PWM.o".
Clean: Done.
Executing: "C:\MCC18\bin\mcc18.exe" -p=18F46K20 "12 CCP PWM.c" -fo="12 CCP PWM.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
MPLAB C18 v3.20 (feature limited)
Copyright 1999-2005 Microchip Technology Inc.
This version of MPLAB C18 does not support the extended mode
and will not perform all optimizations.  To purchase a full
copy of MPLAB C18, please contact your local distributor or
visit buy.microchip.com.

Executing: "C:\MCC18\bin\mplink.exe" /l"C:\MCC18\lib" "C:\MCC18\lkr\18f46k20i.lkr" "12 CCP PWM.o" /u_CRUNTIME /o"12 CCP PWM.cof" /M"12 CCP PWM.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - could not find definition of symbol 'main' in file 'C:\MCC18\lib/c018i.o'.
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Release build of project `M:\12 CCP PWM\12 CCP PWM.mcp' failed.
Thu Apr 16 14:34:41 2009
----------------------------------------------------------------------
BUILD FAILED

我已检查链接器库的路径是否正确。我怀疑它与我的源代码有关...任何帮助都非常好非常感激。

这是我的源代码.. http://cl1p.net/mplabc18

when i was trying to build my project in MPLAB,i got this Build error message..

    Clean: Deleting intermediary and output files.
Clean: Deleted file "M:\12 CCP PWM\12 CCP PWM.o".
Clean: Done.
Executing: "C:\MCC18\bin\mcc18.exe" -p=18F46K20 "12 CCP PWM.c" -fo="12 CCP PWM.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
MPLAB C18 v3.20 (feature limited)
Copyright 1999-2005 Microchip Technology Inc.
This version of MPLAB C18 does not support the extended mode
and will not perform all optimizations.  To purchase a full
copy of MPLAB C18, please contact your local distributor or
visit buy.microchip.com.

Executing: "C:\MCC18\bin\mplink.exe" /l"C:\MCC18\lib" "C:\MCC18\lkr\18f46k20i.lkr" "12 CCP PWM.o" /u_CRUNTIME /o"12 CCP PWM.cof" /M"12 CCP PWM.map" /W
MPLINK 4.20, Linker
Copyright (c) 2008 Microchip Technology Inc.
Error - could not find definition of symbol 'main' in file 'C:\MCC18\lib/c018i.o'.
Errors    : 1

Link step failed.
----------------------------------------------------------------------
Release build of project `M:\12 CCP PWM\12 CCP PWM.mcp' failed.
Thu Apr 16 14:34:41 2009
----------------------------------------------------------------------
BUILD FAILED

I have checked that the path to the linker library was correct.I suspect it has something to do with my source code...Any helps are very much appreciated.

Here is my source code.. http://cl1p.net/mplabc18

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

饮湿 2024-07-24 10:16:28

编译器可能正在寻找 main 的不同定义。 我在一些 PIC 代码中看到了这一点:

// Main application entry point.
#ifdef __C30__
int main(void)
#else
void main(void)
#endif
{ ... }

The compiler may be looking for a different definition of main. I have seen this in some PIC code:

// Main application entry point.
#ifdef __C30__
int main(void)
#else
void main(void)
#endif
{ ... }
风轻花落早 2024-07-24 10:16:28

将特定的链接器文件添加到您的项目中是一个好主意。 如果您使用的是 MPLAB,请在工作区下右键单击链接器文件,然后从 mcc16\lkr 文件夹中添加特定处理器的链接器文件。
清理并重新编译解决方案

It is a good idea to add the specific linker file to your project. If you are using MPLAB, under the workspace, right click on linker files and add the linker file from mcc16\lkr folder for the specific processor.
Clean and Re-compile the solution

悲欢浪云 2024-07-24 10:16:28

在你的源文件中唯一让我印象深刻的是 ISR 声明的这一部分:

#pragma 代码 InterruptVectorLow = 0x18

您正在使用的编译器的用户指南指出这应该是:

#pragma 代码 low_vector=0x18

由于此声明位于主函数之前,因此可能会给您带来麻烦。

编辑:

所提供的解决方案似乎都不起作用,因此我只是将您的代码复制粘贴到为 PIC18F46K20 器件设置的新 MPLAB 项目中。 它可以用 MCC18 编译器编译得很好。 该项目唯一缺少的是“12 CCP PWM.h”头文件(我没有)。 因此,问题要么是您的头文件有问题,要么是您的项目设置有问题,或者是我使用的是 MCC18 3.30 而不是 3.20。

The only thing that stood out to me in your source file is this part of the ISR declaration:

#pragma code InterruptVectorLow = 0x18

The user guide of the compiler you're using states this should be:

#pragma code low_vector=0x18

Since this declaration is just before your main function it might be giving you trouble.

Edit:

None of the presented solutions seem to work so I have just copy-pasted your code into a new MPLAB project, set up for the PIC18F46K20 device. It compiles just fine with the MCC18 compiler. The only thing that's missing from the project is the "12 CCP PWM.h" header file (which I do not have). So either there's something wrong with your header file, there's something wrong with your project setup, or the fact that I'm using MCC18 3.30 instead of 3.20 is the problem.

难忘№最初的完美 2024-07-24 10:16:28

代码对我来说编译得很好(C18 3.30 full),

我的 MPLAB 有点崩溃,尤其是在大型源代码树上,很多时候重新启动就解决了这个问题,完全不知道为什么,尝试了其他所有方法,这是唯一的方法让 mplab 重置。

code compiles fine for me (C18 3.30 full)

i've had MPLAB flake out a bit on me especially on large source trees, many times a reboot has solved it, absolutely no idea why, tried everything else and it was the only way to get mplab to reset.

饮惑 2024-07-24 10:16:28

就我个人而言,我不会因为源文件名中包含多个空格而使实现的角落变得紧张,特别是对于嵌入式工具链!

但看起来他们正在做出合理的努力来添加所有双引号,所以也许这不是一个真正的问题。

您的代码中是否确实有“main”函数?如果有,它到底是如何定义的?

Personally I would not strain the corners of the implementation by having source file names with several spaces in, particularly with an embedded toolchain!

But it seems like they're making a reasonable effort to add all the double-quotes, so maybe that's not a real problem.

Do you actually have a 'main' function in your code, and if so, exactly how is it defined?

苍景流年 2024-07-24 10:16:28

我使用第三方编译器,因此我无法提供任何具体经验。 但我可能怀疑的一件事是代码中的某些内容导致编译中途停止。 这可以是未终止的注释,也可以是缺少右大括号的函数。 特别要考虑 #included 文件,因为当您查看主文件时,您无法在编辑器中看到效果,并且特别要检查您自己编写的任何 #includes。 列表顶部是“您最后更改了什么”?

我此时所做的就是制作一个分支副本,并开始无情地破解大量代码,只是为了看看错误何时消失。 分而治之。 当然,这可能很耗时,所以我可能会首先在 StackOverflow 上询问:)

I use a third-party compiler, so I can't offer any specific experience on that. But one thing I may suspect is that something in the code is causing the compilation to stop partway through. This can be an unterminated comment, or a function with a closing brace missing. Consider especially the #included files, because you can't see the effects in your editor when you look at the main file, and particularly check any #includes that you have written yourself. And at the top of the list is, "what did you change last"?

What I do at this point is make a branch copy, and start mercilessly hacking out huge blocks of code, just to see when the error goes away. Divide and conquer. Of course, this can be time consuming, so I'd probably ask on StackOverflow, first :)

差↓一点笑了 2024-07-24 10:16:28

已经有一段时间了,但我看到您在创建函数之前使用了编译指示来定义中断处理程序的位置,您是否需要对 main() 执行相同的操作?

它可能在 .h 文件中处理 - 我不确定。 我只在 PIC 上使用过 ASM,并且我明确地处理了所有事情(即,在 0x000 处跳转到主地址;在中断向量地址处跳转到该内存地址;在主地址处执行这些操作,等等)。 对我来说,“main”被定义为代码部分中的一个可用地址(我看到你已经完成了,启动了代码部分,然后定义了 main),但我相信我必须明确定义“main”是从代码段中的内存地址。 同样,它是 ASM,但我毫不怀疑您需要做类似的事情 - 将 main 定义为 main 的编译指示。

It's been a while, but I saw that you used a pragma to define the location of the interrupt handler before you created the function, might you need to do the same thing with main()?

It might be handled in the .h file - I'm not sure. I only ever used ASM on the PICs and I explicitly handled everything (ie, at 0x000 jump to main; at the interrupt vector address jump to this memory address; at main address do these things, etc). 'main' for me was defined to be an available address in the code section (which I see you've done, started the code section then defined main) but I believe I had to explicitly define that 'main' was to start at a memory address in the code section. Again, it was ASM, but I wouldn't doubt that you need to do something similar - a pragma to define main as main.

浮生面具三千个 2024-07-24 10:16:28

如果 c018i.o 包含重置向量,并且它通过名称引用函数 main,那么问题可能是 main 需要一个原型 - 即使在与函数本身相同的文件中,因此链接器可以选择它并放入 main在其功能列表中。

因此,尝试

void main (void);

在 main 函数的正上方插入:。

If c018i.o contains the reset vector, and it refers to the function main by name, then the issue could be that main needs a prototype - even in the same file as the function itself, so the linker can pick this up and put main in its list of functions.

So, try inserting:

void main (void);

immediately above the main function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文