- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am relatively new to Psoc5 and Creator and am re-acquainting myself with C++. I am having difficulties getting a particular program to build. I know that Creator is C based but that one can also "force" it to recognize and compile C++ code. The program is extremely simple:
#include <iostream>
using namespace std;
int GetFibNumber(int FibIndex)
{
if (FibIndex < 2)
return FibIndex;
else
return GetFibNumber(FibIndex - 1) + GetFibNumber(FibIndex - 2);
}
int main()
{
cout << "Enter 0-based index of desired Fibonacci Number: ";
int Index = 0;
cin >> Index;
cout << "Fibonacci number is: " << GetFibNumber(Index) << endl;
return 0;
}
In the Build Settings associated with all .c files I have added "-x c++" as a custom flag in the command line. The errors I get when I build this is:
prj.M0120: undefined symbol `Reset' referenced in expression
prj.M0120: The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
Any ideas what I'm missing? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I've been digging and reading forum posts...
One setting that I had wrong was with the toolchain. I was not using the ARM GCC Generic toolchain but I fixed that. Then I discovered that the path was incorrect...I fixed that.
Now I'm getting the following:
prj.M0120: The command 'arm-none-eabi-as.exe' failed with exit code '1'.
Still hoping for some helpful insights
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good reading
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, I read that article earlier and it helped me eliminate a ton of build errors but alas two remain:
undefined symbol `Reset' referenced in expression
The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
I tried specifying the generic toolchain ARM Generic and also ARM GCC 4.4.1 with identical results.
I'm about to abandon efforts to force C++ in Creator and conform to C, although I still believe C++ is a better overall tool. The upside is that eventually I'll know both!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have had success with using C++ with PSoC Creator (I am the author of that article on cladlab that is linked above).
Hmmm, I see you are using <iostream>. This defines standard in and out stream objects, and can include other headers also. It might be that this is too much for an embedded design (an overflowing memory). I do remember trying to use the << stream notation before and having RAM overflows, although I can't remember if it was iostream or not that caused the issue.
Other than that, you mention "failed with exit code 1". This is normally the generic error shown on the "notice list". If you switch to the output window, you might be able to glean more about the error, as you will see compiler output messages. Have a look there and post anything that gives more information on what is wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thats interesting, that you got "-x c++" to work in the global build settings, since that would make every file be compiled as C++, and as far as I'm aware, the Cypress-generated peripheral code does not have C++ header guards (the #ifdef __cplusplus extern C{ } #endif directive).
So it worked even for these files, and just produced warnings? I will have to make a test project myself sometime and see how far you can take this. Including "-x c++" just once in the build settings could have many possible advantages, including making it simpler (as opposed to entering in "-x c++" in every C++ files settings, which if moved to a different file location are lost), and also may mean that you can include some of the other C++ stuff that seems to be missing (__cxa_guard_aquire/__cxa_guard_release e.t.c).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
gbmhunter:
The Cypress generated code doesn't have the #ifdef __cplusplus stuff, but that isn't necessary because GCC realizes the the .c files are straight C. Of course, if you include the generated .h files into a C++ file, you'll need to wrap them in extern "C" {...};
Each .c file with "-x c++" generates a single warning from GCC saying that option doesn't apply. I'd much prefer a totally clean build, but those warnings are fairly easy to ignore. Having to add "-x c++" to each .cc file seems more onerous, IMO. The entire problem would go away if they used GNU make.
Related to the OP's use of <iostream>, is there any way of getting text output off the chip and into the debugger console? I think this is called "semi-hosting" in the ARM world.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
andyTurk:
Strange, because "-x c++" is meant to force the compiler to treat any file as a C++ file, no matter the extension. So if you added it to the global build settings, I would of thought it would try to compile the PSoC peripheral API code as C++.
So maybe is DOES compile as C++? IIRC, C++ was desinged so that it could compile C code without any problems. I know there are issues such as name mangling (which is what those guards are for), but maybe this is not relevant in this case?