我需要编译一个C ++库以与Zolertia Re-Mote上的contiki一起使用。我先尝试一个简单的程序:
#include "contiki.h"
#include "misc.h"
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
say_hello();
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/* C++ implementation */
#ifdef CONTIKI_TARGET_ZOUL
void* __dso_handle;
void* __exidx_end;
void* __exidx_start;
#endif
#include <iostream>
using namespace std;
void cpp_say_hello(){
cout << "Hello world!" << endl;
}
/* C wrapper */
extern "C"{
#include "misc.h"
void say_hello(){
cpp_say_hello();
}
}
#ifndef _MISC_H_
#define _MISC_H_
/**
* \brief Prints hello to stdout
*/
void say_hello();
#endif /* _MISC_H_ */
ifeq ($(TARGET),)
TARGET = native
endif
CONTIKI_PROJECT = hello-world
all: $(CONTIKI_PROJECT)
PROJECT_LIBRARIES = obj_$(TARGET)/misc.o
include $(CONTIKI)/Makefile.include
obj_$(TARGET)/misc.o: misc.cpp
@mkdir -p obj_$(TARGET)
$(TRACE_CXX)
$(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) -c $^ -o $@
这(对contiki Makefile进行了一些修改:here)使我可以将C ++代码用于“本地”目标。但是,当我尝试为Zolertia Re-Mote平台(TARGET = zoul)进行编译时,出现以下错误:
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: hello-world.elf section `.ARM.extab.text._Z13cpp_say_hellov' will not fit in region `FLASH_CCA'
/usr/lib/gcc/arm-none-eabi/8.2.0/../../../../arm-none-eabi/bin/ld: region `FLASH_CCA' overflowed by 788 bytes
collect2: error: ld returned 1 exit status
make: *** [/home/wellsaid/contiki/cpu/cc2538/Makefile.cc2538:103: hello-world.elf] Error 1
rm hello-world.co obj_zoul/startup-gcc.o
有什么办法解决这个问题?