A
A
allsettingsdone2014-08-03 11:19:02
Microcontrollers
allsettingsdone, 2014-08-03 11:19:02

How to compile simple C++ project for ARM in sublime text3?

I installed the compiler "GNU Tools ARM Embedded" and Make, PATH was added to the system, here is the contents of the st3.sublime-project project file:

{
  "folders":
  [
    {
      "follow_symlinks": true,
      "path": "."
    }
  ],

"build_systems":
  [
    {
      "name": "ARM build",
      "cmd": ["make"],
      "working_dir": "${project_path}"
    }
  ]
}

Trying to compile main.cpp:
int main(void)
{
  while(1)
  {
    
  }
}

When I try to compile, the console says:
arm-none-eabi-gcc main.cpp
[Finished in 0.4s with exit code 2]
[cmd: ['make']]
[dir: X:\st3]
c:/program files (x86)/gnu tools arm embedded/4.8 2014q2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status
make: *** [all] Error 1

I am using this makefile:
TARGET = arm-none-eabi-

CHIP = STM32F0XX

LDSCRIPT = STM32F030x6.ld

all:
  arm-none-eabi-gcc main.cpp

What could be the problem? I think the problem is that the compiler doesn't take or see "startup_stm32f10x_md_vl.s".
Here is the attached project: https://copy.com/u4vtHeATYVaweCc7

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Shetani, 2014-08-03
@Shetani

Try to do as suggested here .

G
GavriKos, 2014-08-03
@GavriKos

You don't seem to have an error in the C++ file. Maybe somewhere along the way Russian is present, for example.

A
allsettingsdone, 2014-08-03
@allsettingsdone

Shetani, Yes, it partially helped, but now when I try to assemble it, this is written:

arm-none-eabi-gcc main.cpp
c:/program files (x86)/gnu tools arm embedded/4.8 2014q2/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib\libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status
make: *** [all] Error 1
[Finished in 0.3s with exit code 2]

For the project to work correctly, I slightly changed its settings (now it calls make when building, not the compiler):
{
  "folders":
  [
    {
      "path": "."
    }
  ],

  "build_systems":
  [
    {
      "name": "arm build",
      "cmd": ["make"],
      "working_dir": "${project_path}/"
    }
  ],

  "settings":
  {
    "sublimeclang_options":
    [
      "-std=c++11",
      "-Wall",
      "-I${project_path}/"
    ]
  }
}

And here is the makefile respectively:
all:
  arm-none-eabi-gcc main.cpp

What can be done in this case? (PS: never wrote a makefile before and generally only worked from the IDE).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question