首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MPLAB编译器无法编译( C30 -X集成开发环境)

MPLAB编译器无法编译( C30 -X集成开发环境)
EN

Stack Overflow用户
提问于 2012-07-18 10:17:46
回答 3查看 6.9K关注 0票数 0

我正在尝试编译一个非常简单的程序,我不明白为什么它不能编译。下面是我的程序:

代码语言:javascript
复制
/* General includes */
#include <stdio.h>
#include <stdlib.h>
#include <libpic30.h>
#include <p33FJ128GP804.h>

#include "RunLengthAlgorithm.h"
//#include "RunLengthAlgorithm.c"

int main(void) {

    int n;
    char source[10001];
    char target[100];

    for(n = 0; n < 1000; ++n){
        source[n] = "A";
    }
    for(n = 1000; n < 2000; ++n){
        source[n] = "B";
    }
    for(n = 2000; n < 3000; ++n){
        source[n] = "C";
    }
    for(n = 3000; n < 4000; ++n){
        source[n] = "D";
    }
    for(n = 4000; n < 5000; ++n){
        source[n] = "E";
    }
    for(n = 5000; n < 6000; ++n){
        source[n] = "F";
    }
    for(n = 6000; n < 7000; ++n){
        source[n] = "G";
    }
    for(n = 7000; n < 8000; ++n){
        source[n] = "H";
    }
    for(n = 8000; n < 9000; ++n){
        source[n] = "I";
    }
    for(n = 9000; n < 10000; ++n){
        source[n] = "J";
    }
    source[10001] = '\0';

    RLEncode(&source, &target);

    while(1);
    return (EXIT_SUCCESS);

}

.h和.c文件将添加到项目中。

代码语言:javascript
复制
#ifndef RUNLENGTHALGORITHM_H
#define RUNLENGTHALGORITHM_H

void RLEncode (char *source, char *target);

#endif

和.c文件:

代码语言:javascript
复制
#ifndef RUNLENGTHALGORITHM_C
#define RUNLENGTHALGORITHM_C
void RLEncode (char *source, char *target){
    int n, k = 0;
    for(n = 0; source[n] != '\0'; ++n){
        int length = 1;
        while(source[n+1] != '\0' && source[n] == source[n+1]){
            ++length; ++n;
        }
        target[k++] = length;
        target[k++] = source[n];
    }
    source[n] = '\0';
}

#endif

我正在使用带有C30编译器的MPLAB-X集成开发环境,它给出了这个错误:

代码语言:javascript
复制
CLEAN SUCCESSFUL (total time: 1s)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `D:/Datos (Disco)/Electronica/Multi portatil/Run-Length Algorithm.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Run-Length_Algorithm.X.production.hex
make[2]: Entering directory `D:/Datos (Disco)/Electronica/Multi portatil/Run-Length Algorithm.X'
Main.c: In function 'main':
Main.c:24: warning: assignment makes integer from pointer without a cast
Main.c:27: warning: assignment makes integer from pointer without a cast
Main.c:30: warning: assignment makes integer from pointer without a cast
Main.c:33: warning: assignment makes integer from pointer without a cast
Main.c:36: warning: assignment makes integer from pointer without a cast
Main.c:39: warning: assignment makes integer from pointer without a cast
Main.c:42: warning: assignment makes integer from pointer without a cast
Main.c:45: warning: assignment makes integer from pointer without a cast
Main.c:48: warning: assignment makes integer from pointer without a cast
Main.c:51: warning: assignment makes integer from pointer without a cast
Main.c:55: warning: passing argument 1 of 'RLEncode' from incompatible pointer type
Main.c:55: warning: passing argument 2 of 'RLEncode' from incompatible pointer type
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -g -omf=elf -x c -c -mcpu=33FJ128GP804 -MMD -MF build/default/production/Main.o.d -o **build/default/production/Main.o Main.c 
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe" -g -omf=elf -x c -c -mcpu=33FJ128GP804 -MMD -MF build/default/production/RunLengthAlgorithm.o.d -o build/default/production/RunLengthAlgorithm.o RunLengthAlgorithm.c 
"C:\Program Files (x86)\Microchip\MPLAB C30\bin\pic30-gcc.exe"   -omf=elf -mcpu=33FJ128GP804  -o dist/default/production/Run-Length_Algorithm.X.production.elf build/default/production/Main.o build/default/production/RunLengthAlgorithm.o build/default/production/RunLengthAlgorithm.o        -Wl,--defsym=__MPLAB_BUILD=1,-Tp33FJ128GP804.gld
build/default/production/RunLengthAlgorithm.o(.text+0x0): In function `_RLEncode':
: multiple definition of `_RLEncode'
build/default/production/RunLengthAlgorithm.o(.text+0x0): first defined here
c:\program files (x86)\microchip\mplab c30\bin\bin\..\bin/pic30-elf-ld.exe: Link terminated due to previous error(s).**
make[2]: Leaving directory `D:/Datos (Disco)/Electronica/Multi portatil/Run-Length Algorithm.X'
make[1]: Leaving directory `D:/Datos (Disco)/Electronica/Multi portatil/Run-Length Algorithm.X'
**make[2]: *** [dist/default/production/Run-Length_Algorithm.X.production.hex] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 8s)**

我不明白为什么,如果我把我的函数放在Main.c中,并且我没有包括#include "RunLengthAlgorithm.h“,它可以工作,但我不能让它工作,包括一个文件。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-07-18 10:30:41

好的,代码没有问题。这似乎是MPLAB-X v1.10的一个错误。

解决方案:关闭MPLAB-X并再次打开它,如果它不能工作,请在http://www.microchip.com/forums/m627705.aspx上阅读。

票数 0
EN

Stack Overflow用户

发布于 2013-11-25 15:03:15

我认为问题与内存映射有关。您应该根据使用的处理器系列在.gld或.lkr文件中重新定义堆栈的大小。当您声明具有非常大内存位置的变量源时,堆栈将溢出。

票数 0
EN

Stack Overflow用户

发布于 2015-09-29 21:36:57

当你"#include _your_func.h“你的函数,然后使用IDE> Projects>sourcefiles> Add existing item手动包含包含函数的文件时,就会发生这种情况。这两种方法中的任何一种都足够。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11533439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档