Author Topic: advanced C++ features with GNU GCC for ARM  (Read 18949 times)

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
advanced C++ features with GNU GCC for ARM
« on: October 30, 2014, 01:17:52 pm »
Hello

Apparently "GNU GCC for ARM" possede features, similar to STL (standard template library) ... like array, vector, algorithms, etc.
I'm aware if someone suceeded to use these features.

I tried ... but problems occur when I merely include headers.
For example, the following instruction:

#include <vector>

provokes the error
..... fatal error: vector: No such file or directory

Hoever the file vector does exists in the root directory of GCC.

Thanks in advance

Pavel

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #2 on: November 05, 2014, 01:09:42 pm »
In the meantime I searched for the solution on GNU GCC forum.
Apparently the reason of error on the instruction
#include <vector>
is the extention of my source file (which is .c).
So, if my comprehension is correct, for .c files it's a "C compiler" that is used, whereas for .cpp files the "C++ compiler" is used.

I created simple .cpp file with only 1 line:
#include <vector>

and tried to compile it.
Here is Code::Block output:

-------------- Build: Debug in link_v1 (compiler: GNU GCC Compiler for ARM)---------------

Running command: make.exe -f Makefile
using saved target 'cc2538dk'
g++   -mcpu=cortex-m3 -mthumb -nostartfiles -T obj_cc2538dk/cc2538.ld -Wl,-Map=test_cpp,--cref,--no-warn-mismatch -Wl,--gc-sections  test_cpp.cpp   -o test_cpp
make: g++: Command not found
make: *** [test_cpp] Error 127
<builtin>: recipe for target 'test_cpp' failed
Process terminated with status 2 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

If my comprehension is correct, the Code::Block didn't find the correct executable for C++ compiler.
In the log here above it uses g++ as executable, whereas it the compiler settings I specified arm-none-eabi-g++.exe !!!

Where is a problem ?

Regards

Pavel.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: advanced C++ features with GNU GCC for ARM
« Reply #3 on: November 05, 2014, 02:07:30 pm »
Where is a problem ?
Do you have a project?
If you have then have you selected the correct compiler for the target/s?
If not then what is your default compiler?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #4 on: November 05, 2014, 02:27:32 pm »
Yes I have project.
If you want I can send you.

Here are compiler settings (please see the images below).
The problem is the tool (Code::Blocks) doesn't take the correct compiler executable (that should be arm-none-eabi-g++.exe)

Regards

Pavel


Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #5 on: November 05, 2014, 02:28:16 pm »
Compiler options: cont.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: advanced C++ features with GNU GCC for ARM
« Reply #6 on: November 05, 2014, 03:29:51 pm »
Yes I have project.
If you want I can send you.
No, I don't want your project.

Have you selected "GNU GCC compiler for ARM" for your project?
You can check this in Project -> Build options.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #7 on: November 05, 2014, 04:07:27 pm »
Of course

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: advanced C++ features with GNU GCC for ARM
« Reply #8 on: November 05, 2014, 04:14:14 pm »
Here is Code::Block output:

-------------- Build: Debug in link_v1 (compiler: GNU GCC Compiler for ARM)---------------

Running command: make.exe -f Makefile

NOTE: Please note when you are using a custom CB Makefile instead of a normal CB Project!!
It is easy to miss that fact.

If you want more help change to a normal CB Project; otherwise fixing the problem in your makefile is NOT a CB issue.

Tim S.
« Last Edit: November 05, 2014, 04:15:52 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #9 on: November 05, 2014, 05:02:28 pm »
Hello Tim,

Thanks a lot for your assistance.
Here is makefile:
Code
all: test_cpp
APPS=servreg-hack
CONTIKI=../..

UIP_CONF_IPV6=1
#SERVER_REPLY=1

CFLAGS+= -DUIP_CONF_IPV6_RPL

ifdef WITH_COMPOWER
APPS+=powertrace
CFLAGS+= -DCONTIKIMAC_CONF_COMPOWER=1 -DWITH_COMPOWER=1 -DQUEUEBUF_CONF_NUM=4
endif

ifdef SERVER_REPLY
CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
endif
ifdef PERIOD
CFLAGS+=-DPERIOD=$(PERIOD)
endif

include $(CONTIKI)/Makefile.include

As you can state there is no any option related to the choice of compiler executable.
So I think that compiler tool choice come from Code::Block options. Isn't it ?

I work with Code::Block & GNU GCC for ARM since 4 monthes and built dozen of project for my ARM microcontroller.
But (if my comprehension is correct) all this time I used "C compiler".
Now I need more advance options for which "C++ compiler" is more appropriated.
But i seems that instead "right" executable for "C++ compiler" Code::Block uses something else.

I contacted GNU GCC support ... and their expert told me that correct executable for C++ compiler is arm-none-eabi-g++.exe.

Cordially

Pavel

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: advanced C++ features with GNU GCC for ARM
« Reply #10 on: November 05, 2014, 05:45:36 pm »
Since you ignored my advice I am now ignoring you!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: advanced C++ features with GNU GCC for ARM
« Reply #11 on: November 05, 2014, 06:46:33 pm »
Pavel_47:
When you've set your project to use custom makefile then you've told CB - "I know what I'm doing and handle everything related to the build".
So if you want to use one specific compiler with your makefile then you need to modify it. CB cannot set the compiler for you!

What you need to do is open a cmd window; cd to the root of your project and then run make -f <yourmakefile> then fix any errors you encounter.
Changing options in the compiler or project settings won't have any effect on your build.

So you're on your own here...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #12 on: November 17, 2014, 02:28:53 pm »
Since you ignored my advice I am now ignoring you!

Tim S.


Hello Tim,

Sorry
I was misunderstood.
I have no any intention to ignore your suggestions as well as anyone who answer me.
The problem with my projetc(s) - they are closely related to Contiki staff, where the code behavior is strongly dependent on different option flags that are placed in different locations - essentially in headers, but also in custom make files.
So, it's recommended by Contiki experts to use custom make files.

Probably there is another way to take into account Contiki compiler options put into make file.
For the moment I have no idea how to do it (i.e. where to place Contiki compiler options in CB interface) ... your suggestions here are wellcome.

Nevertheless I've tried to create project and compile it with "default" make.
The project type was "Console Application".
I've also tried with "ARM Project", but even couldn't succeed to create project - on step "Please select compiler to use" there were no any options in the "Compiler" combobox.
Here is compiler log with default make:
Code
||=== Build: Debug in C_Features_Test (compiler: GNU GCC Compiler for ARM) ===|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-exit.o)||In function `exit':|
exit.c:(.text.exit+0x2c)||undefined reference to `_exit'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-sbrkr.o)||In function `_sbrk_r':|
sbrkr.c:(.text._sbrk_r+0x18)||undefined reference to `_sbrk'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-writer.o)||In function `_write_r':|
writer.c:(.text._write_r+0x20)||undefined reference to `_write'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-closer.o)||In function `_close_r':|
closer.c:(.text._close_r+0x18)||undefined reference to `_close'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-fstatr.o)||In function `_fstat_r':|
fstatr.c:(.text._fstat_r+0x1c)||undefined reference to `_fstat'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-isattyr.o)||In function `_isatty_r':|
isattyr.c:(.text._isatty_r+0x18)||undefined reference to `_isatty'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-lseekr.o)||In function `_lseek_r':|
lseekr.c:(.text._lseek_r+0x20)||undefined reference to `_lseek'|
c:\program files (x86)\gnu tools arm embedded\4.8 2014q1\bin\..\lib\gcc\arm-none-eabi\4.8.3\..\..\..\..\arm-none-eabi\lib\libc.a(lib_a-readr.o)||In function `_read_r':|
readr.c:(.text._read_r+0x20)||undefined reference to `_read'|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Best Regards

Pavel



Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: advanced C++ features with GNU GCC for ARM
« Reply #13 on: November 17, 2014, 02:45:07 pm »
Pavel_47:
When you've set your project to use custom makefile then you've told CB - "I know what I'm doing and handle everything related to the build".
So if you want to use one specific compiler with your makefile then you need to modify it. CB cannot set the compiler for you!

Hello oBFusCATed

First, thanks for response.

1. If CB cannot set the compiler for me, what signifies the following interface (please, see the snapshot below)
2. I've tried to compile in cmd window as you suggested (i.e. run make -f <yourmakefile>). The output is exactly the same as in "Build log" window of CB ... so I still don't see which executables are used for making projects.

Best Regards

Pavel



[attachment deleted by admin]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: advanced C++ features with GNU GCC for ARM
« Reply #14 on: November 17, 2014, 08:19:44 pm »
If you use a custom makefile project, this dialog is ignored.
If you have a normal cb project, then try to rebuild it and post the full build log if it fails.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]