2017-07-26 9 views
0

私はesp8266コーディングにArduino IDEを使用していますが、もう少し強力な環境に移行したいと考えています。私はMinGW GCCツールチェーンを使ってEclipse CDT環境に初めて参加しています。 -Eclipse CDT - ESP8266 - espressif hello_world_cppの例

EDIT私はこのEclipseのC Arduinoのプラグインがインストールされていません。 https://marketplace.eclipse.org/content/eclipse-c-ide-arduino

しかし、プロジェクトの作業を取得するために私の最初の試みで、私はすべてコンパイルを取得しようとしている問題の多くに実行していることだし、リンクされた。私はEspressif SDKからhello_world_cppサンプルを選択しました。私が遭遇したいくつかの問題を修正しましたが、以下のリンク問題をどのように回避するかを理解できないようです。出力はメインプロジェクトコードの後に​​コピーされます。

皆さん、私はこの問題を調べ始める可能性のある箇所を指摘できますか?私はライブラリが欠けているように見えますが、私の生活のために、欠けている機能を含むライブラリを見つけることができません。役に立つと思われる情報があれば教えてください。ここで

メインのCPPファイルです:

/* 
    The hello world c++ demo 
*/ 

#include <ets_sys.h> 
#include <osapi.h> 
#include <os_type.h> 
#include <gpio.h> 

#define DELAY 1000 /* milliseconds */ 

// ============================================================================================= 
// C includes and declarations 
// ============================================================================================= 
extern "C" 
{ 
#include "driver/uart.h" 
#include <user_interface.h> 

void *pvPortMalloc(size_t xWantedSize); 
void vPortFree(void *pv); 
void *pvPortZalloc(size_t size); 

// declare lib methods 
extern int ets_uart_printf(const char *fmt, ...); 
void ets_timer_disarm(ETSTimer *ptimer); 
void ets_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg); 
void ets_timer_arm_new(ETSTimer *ptimer,uint32_t milliseconds, bool repeat_flag, bool); 

#define os_malloc pvPortMalloc 
#define os_free  vPortFree 
#define os_zalloc pvPortZalloc 

}//extern "C" 

// ============================================================================================= 
// These methods shall be defined anywhere. 
// They are required for C++ compiler 
// ============================================================================================= 
void *operator new(size_t size) 
{ 
    return os_malloc(size); 
} 

void *operator new[](size_t size) 
{ 
    return os_malloc(size); 
} 

void operator delete(void * ptr) 
{ 
    os_free(ptr); 
} 

void operator delete[](void * ptr) 
{ 
    os_free(ptr); 
} 

extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); 
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); 
extern "C" void abort() 
{ 
    while(true); // enter an infinite loop and get reset by the WDT 
} 

void __cxa_pure_virtual(void) { 
    abort(); 
} 

void __cxa_deleted_virtual(void) { 
    abort(); 
} 

// ============================================================================================= 
// Example class. It show that the global objects shall be initialyzed by user 
// (see user_init method) 
// ============================================================================================= 

class A 
{ 
    int a; 
    int b; 

public: 
    A() 
    : a(5) 
    , b(6) 
    { 
    } 

    A(int k, int m) 
    : a(k) 
    , b(m) 
    { 
    } 

    void print() 
    { 
     ets_uart_printf("a = %d, b = %d\n", a, b); 
    } 
}; 

// ============================================================================================= 
// global objects 
// ============================================================================================= 

LOCAL os_timer_t hello_timer; 
A a; 


// ============================================================================================= 
// Pointers to the constructors of the global objects 
// (defined in the linker script eagle.app.v6.ld) 
// ============================================================================================= 

extern void (*__init_array_start)(void); 
extern void (*__init_array_end)(void); 

// Initialyzer of the global objects 
static void do_global_ctors(void) 
{ 
    void (**p)(void); 
    for (p = &__init_array_start; p != &__init_array_end; ++p) 
      (*p)(); 
} 

// ============================================================================================= 
// User code 
// ============================================================================================= 

LOCAL void ICACHE_FLASH_ATTR hello_cb(void *arg) 
{ 
    static int counter = 0; 
    ets_uart_printf("Hello World #%d!\r\n", counter++); 
    a.print(); 
} 


/****************************************************************************** 
* FunctionName : user_rf_cal_sector_set 
* Description : SDK just reversed 4 sectors, used for rf init data and paramters. 
*    We add this function to force users to set rf cal sector, since 
*    we don't know which sector is free in user's application. 
*    sector map for last several sectors : ABBBCDDD 
*    A : rf cal 
*    B : at parameters 
*    C : rf init data 
*    D : sdk parameters 
* Parameters : none 
* Returns  : rf cal sector 
*******************************************************************************/ 
extern "C" uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void) 
{ 
    enum flash_size_map size_map = system_get_flash_size_map(); 
    uint32 rf_cal_sec = 0; 

    switch (size_map) { 
     case FLASH_SIZE_4M_MAP_256_256: 
      rf_cal_sec = 128 - 8; 
      break; 

     case FLASH_SIZE_8M_MAP_512_512: 
      rf_cal_sec = 256 - 5; 
      break; 

     case FLASH_SIZE_16M_MAP_512_512: 
     case FLASH_SIZE_16M_MAP_1024_1024: 
      rf_cal_sec = 512 - 5; 
      break; 

     case FLASH_SIZE_32M_MAP_512_512: 
     case FLASH_SIZE_32M_MAP_1024_1024: 
      rf_cal_sec = 1024 - 5; 
      break; 

     default: 
      rf_cal_sec = 0; 
      break; 
    } 

    return rf_cal_sec; 
} 

extern "C" void ICACHE_FLASH_ATTR user_rf_pre_init(void) 
{ 
} 

extern "C" void ICACHE_FLASH_ATTR user_init(void) 
{ 
    do_global_ctors(); 
    // Configure the UART 
    uart_init(BIT_RATE_115200, BIT_RATE_115200); 
    ets_uart_printf("System init...\r\n"); 

    // Set up a timer to send the message 
    // os_timer_disarm(ETSTimer *ptimer) 
    os_timer_disarm(&hello_timer); 
    // os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) 
    os_timer_setfn(&hello_timer, (os_timer_func_t *)hello_cb, (void *)0); 
    // void os_timer_arm(ETSTimer *ptimer,uint32_t milliseconds, bool repeat_flag) 
    os_timer_arm(&hello_timer, DELAY, 1); 

    ets_uart_printf("System init done.\r\n"); 
} 

、出力を構築する:

19:44:02 **** Rebuild of configuration Default for project hello_world_cpp **** 
Info: Internal Builder is used for build 
gcc -I../include "-IC:\\Espressif\\ESP8266_SDK\\include" -O2 -g -Wall -c -fmessage-length=0 -o "driver\\uart.o" "..\\driver\\uart.c" 
In file included from C:\Espressif\ESP8266_SDK\include/ets_sys.h:12:0, 
       from ..\driver\uart.c:12: 
..\driver\uart.c: In function 'uart_config': 
C:\Espressif\ESP8266_SDK\include/eagle_soc.h:250:38: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses] 
             & (~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) \ 
            ^
C:\Espressif\ESP8266_SDK\include/eagle_soc.h:50:98: note: in definition of macro 'WRITE_PERI_REG' 
#define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val) 
                            ^~~ 
..\driver\uart.c:36:9: note: in expansion of macro 'PIN_FUNC_SELECT' 
     PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); 
     ^~~~~~~~~~~~~~~ 
In file included from ..\driver\uart.c:12:0: 
C:\Espressif\ESP8266_SDK\include/ets_sys.h:61:5: warning: implicit declaration of function 'ets_isr_attach' [-Wimplicit-function-declaration] 
    ets_isr_attach(ETS_UART_INUM, (func), (void *)(arg)) 
    ^
..\driver\uart.c:39:9: note: in expansion of macro 'ETS_UART_INTR_ATTACH' 
     ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff)); 
     ^~~~~~~~~~~~~~~~~~~~ 
In file included from C:\Espressif\ESP8266_SDK\include/ets_sys.h:12:0, 
       from ..\driver\uart.c:12: 
C:\Espressif\ESP8266_SDK\include/eagle_soc.h:250:38: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses] 
             & (~(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) \ 
            ^
C:\Espressif\ESP8266_SDK\include/eagle_soc.h:50:98: note: in definition of macro 'WRITE_PERI_REG' 
#define WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val) 
                            ^~~ 
..\driver\uart.c:41:9: note: in expansion of macro 'PIN_FUNC_SELECT' 
     PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); 
     ^~~~~~~~~~~~~~~ 
..\driver\uart.c:44:5: warning: implicit declaration of function 'uart_div_modify' [-Wimplicit-function-declaration] 
    uart_div_modify(uart_no, UART_CLK_FREQ/(UartDev.baut_rate)); 
    ^~~~~~~~~~~~~~~ 
..\driver\uart.c: In function 'uart0_tx_buffer': 
..\driver\uart.c:163:9: warning: implicit declaration of function 'uart_tx_one_char' [-Wimplicit-function-declaration] 
     uart_tx_one_char(buf[i]); 
     ^~~~~~~~~~~~~~~~ 
In file included from ..\driver\uart.c:12:0: 
..\driver\uart.c: In function 'uart_init': 
C:\Espressif\ESP8266_SDK\include/ets_sys.h:67:5: warning: implicit declaration of function 'ets_isr_unmask' [-Wimplicit-function-declaration] 
    ets_isr_unmask((1<<inum)) 
    ^
C:\Espressif\ESP8266_SDK\include/ets_sys.h:76:5: note: in expansion of macro 'ETS_INTR_ENABLE' 
    ETS_INTR_ENABLE(ETS_UART_INUM) 
    ^~~~~~~~~~~~~~~ 
..\driver\uart.c:182:5: note: in expansion of macro 'ETS_UART_INTR_ENABLE' 
    ETS_UART_INTR_ENABLE(); 
    ^~~~~~~~~~~~~~~~~~~~ 
In file included from ..\driver\uart.c:13:0: 
C:\Espressif\ESP8266_SDK\include/osapi.h:13:26: warning: implicit declaration of function 'ets_install_putc1' [-Wimplicit-function-declaration] 
#define os_install_putc1 ets_install_putc1 
         ^
..\driver\uart.c:185:5: note: in expansion of macro 'os_install_putc1' 
    os_install_putc1((void *)uart1_write_char); 
    ^~~~~~~~~~~~~~~~ 
g++ "-IC:\\Espressif\\ESP8266_SDK\\include\\" -I../include -O2 -g -Wall -c -fmessage-length=0 -o "user\\user_main.o" "..\\user\\user_main.cpp" 
g++ -Lc:/MinGW/msys/1.0/lib "-LF:\\Espressif\\lib" -o hello_world_cpp "driver\\uart.o" "user\\user_main.o" 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible F:\Espressif\lib/libgcc.a when searching for -lgcc 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible F:\Espressif\lib\libgcc.a when searching for -lgcc 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible F:\Espressif\lib/libgcc.a when searching for -lgcc 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: skipping incompatible F:\Espressif\lib\libgcc.a when searching for -lgcc 
driver\uart.o: In function `uart_config': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:39: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:39: undefined reference to `ets_isr_attach' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:44: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:44: undefined reference to `uart_div_modify' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:46: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:46: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:46: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:46: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:57: undefined reference to `UartDev' 
driver\uart.o: In function `uart0_tx_buffer': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:163: undefined reference to `uart_tx_one_char' 
driver\uart.o: In function `uart_init': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:178: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:180: undefined reference to `UartDev' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:182: undefined reference to `ets_isr_unmask' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../driver/uart.c:185: undefined reference to `ets_install_putc1' 
user\user_main.o: In function `hello_cb': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:135: undefined reference to `ets_uart_printf' 
user\user_main.o: In function `ZN1A5printEv': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:100: undefined reference to `ets_uart_printf' 
user\user_main.o: In function `user_rf_cal_sector_set': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:155: undefined reference to `system_get_flash_size_map' 
user\user_main.o: In function `do_global_ctors': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:124: undefined reference to `__init_array_start' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:124: undefined reference to `__init_array_end' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:124: undefined reference to `__init_array_end' 
user\user_main.o: In function `user_init': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:194: undefined reference to `ets_uart_printf' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:198: undefined reference to `ets_timer_disarm' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:200: undefined reference to `ets_timer_setfn' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:202: undefined reference to `ets_timer_arm_new' 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:204: undefined reference to `ets_uart_printf' 
user\user_main.o:C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:137: undefined reference to `pvPortMalloc' 
user\user_main.o: In function `Znaj': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:47: undefined reference to `pvPortMalloc' 
user\user_main.o:C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:47: undefined reference to `vPortFree' 
user\user_main.o: In function `ZdaPv': 
C:\Espressif\examples\ESP8266\hello_world_cpp\Default/../user/user_main.cpp:57: undefined reference to `vPortFree' 
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `[email protected]' 
collect2.exe: error: ld returned 1 exit status 

19:44:03 Build Finished (took 890ms) 

答えて

0

コードを生成するために必要なのgccクロスコンパイラとは対照的に、CDTは、ホスト開発のためのgccを実行して表示されますあなたのArduinoボード用。

「バニラ」CDTを使用しているか、Eclipse用のArduinoプラグインを使用していますか?私は、CDTが第二のプラグインと呼ば思っ何らかの理由で

+0

を考慮すべき

つ。私は両方を見て、スローバー版よりもEclipse-C-ide-Arduinoを好きだった。私はこれをインストールしました: https://marketplace.eclipse.org/content/eclipse-c-ide-arduino –