This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-J7200: how to use C++ in SDK7200

Part Number: PROCESSOR-SDK-J7200

I  want to use C++  in SDK 7200 in my project,

base on a demo provide by TI's support , i have some questions as follows:

1 about the Compiler options

in a C and C++ mixed project, 

for a c file  , use -fg 

fro a cpp file ,use  -c++14 –fg 

is it right ?  

all files are identified as cpp file, is it ok?

beside c++14  , is there other options  supported by ti-cgt-arm_20.2.0.LTS ?

2  it is only  libc.a in ti-cgt-arm_20.2.0.LTS ,  

is there any libc++.a ?

3.  I defined a global variable , 

, CStudent g_cstu;   this will give link error:

<Linking>

error: creating output section ".init_array" without a SECTIONS specification

error: errors encountered during linking;

   "C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packag

   es/ti/binary/udma_baremetal_memcpy_testapp/bin/j7200_evm/udma_baremetal_memc

   py_testapp_mcu1_0_debug.xer5f" not built

 

>> Compilation failure

can you kindly help me to fix it ?

 

  1. 关于编译选项,

main_baremetal.c 文件的编译, 原来用的是 –fc, 改后,用的是 –fg

CStudent.cpp 用的是 -c++14 –fg

 

我的问题,如下处理是否正确?:

如果有C 和C++ 的混合项目, 不管是 c 还是cpp 后缀,都用  -fg , 也就是都视为C++ 文件,因为但看文件名也不能判断里面是否是C还是Cpp语法。

如果是cpp后缀,再增加 -c++14

 

 

  1. 关于链接

log中的链接如下, 语言库只有  libc.a

且在C:\ti-processor-sdk-rtos-j7200-evm-07_03_00_07\ti-cgt-arm_20.2.0.LTS xim 也只有一个 libc.a  文件 没有一个 libcxx  或者 libc++.a

我的问题: 无论c 还是c++ , 语言库只链接 libc.a?

C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/ti-cgt-arm_20.2.0.LTS/bin/armcl -O4 --run_linker --emit_warnings_as_errors -w -q -u _c_int00 -c -mv7R5 --diag_suppress=10063  -x --zero_init=on     C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/binary/udma_baremetal_memcpy_testapp/obj/j7200_evm/mcu1_0/debug/main_baremetal.oer5f  C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/binary/udma_baremetal_memcpy_testapp/obj/j7200_evm/mcu1_0/debug/CStudent.oer5f  C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/build/j7200/linker_r5.lds  -o C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/binary/udma_baremetal_memcpy_testapp/bin/j7200_evm/udma_baremetal_memcpy_testapp_mcu1_0_debug.xer5f -m C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/binary/udma_baremetal_memcpy_testapp/bin/j7200_evm/udma_baremetal_memcpy_testapp_mcu1_0_debug.xer5f.map -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/csl/lib/j7200/r5f/debug/ti.csl.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/uart/lib/j7200/r5f/debug/ti.drv.uart.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/i2c/lib/j7200/r5f/debug/ti.drv.i2c.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/board/lib/j7200_evm/r5f/debug/ti.board.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/udma/lib/j7200/mcu1_0/debug/udma.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/gpio/lib/j7200/r5f/debug/ti.drv.gpio.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/pmic/lib/j7200_evm/r5f/debug/pmic.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/pm/lib/j7200/r5f/debug/pm_lib.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/sciclient/lib/j7200/mcu1_0/debug/sciclient_direct.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/sciclient/lib/j7200/mcu1_0/debug/rm_pm_hal.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/osal/lib/nonos/j7200/r5f/debug/ti.osal.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/csl/lib/j7200/r5f/debug/ti.csl.init.aer5f -lC:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packages/ti/drv/udma/lib/j7200/mcu1_0/debug/udma_apputils.aer5f  C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/ti-cgt-arm_20.2.0.LTS/lib/libc.a

  1. 链接问题

如果 Student 定义在函数中,也就是局部变量,link是成功的,

如果我定义全局变量, CStudent g_cstu; 报错如下:

<Linking>

error: creating output section ".init_array" without a SECTIONS specification

error: errors encountered during linking;

   "C:/ti-processor-sdk-rtos-j7200-evm-07_03_00_07/pdk_j7200_07_03_00_29/packag

   es/ti/binary/udma_baremetal_memcpy_testapp/bin/j7200_evm/udma_baremetal_memc

   py_testapp_mcu1_0_debug.xer5f" not built

 

>> Compilation failure

 

我的问题,如何解决?

 

源码和log附件附上, 期待您的答复

/*CStudent.cpp */
#include <CStudent.h>

using namespace std;

CStudent::CStudent(){
    this->id = -1;
}
CStudent::~CStudent(){}


int CStudent::getId() const {return id;}
void CStudent::setId(int val) {id=val;}

std::string CStudent::getName()  {return name;}
void CStudent::setName(std::string val) {name=val;}

/*CStudent.h */
#ifndef C_STUDENT_H
#define C_STUDENT_H
#include <iostream>
#include <string> // the C++ Standard String Class


class CStudent{

public:
    CStudent();
    ~CStudent();
    int getId() const;
    void setId(int val);
    void setName(std::string val);
    std::string getName();

private:
    int id;
	std::string name;
};
#endif