- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Can anyone point me to an example of actually building a Nios-II project with cpp? I have tried many ways and it always comes down to a build error. The problem seems to be related to the alt_main.c. There must be a simple method of creating a CPP program as the documentation states everywhere that CPP is supported. I cannot find a template or an example on the website. I see where the simple socket server has a cpp implementation but it is not a full example showing the linkage with a BSP. Thanks,Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all you should rename as alt_main.cpp.
Then, if your .cpp contain functions which are supposed to be called from .c sources, you must declare them as extern "C"- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply, but I have tried that before and run into bsp build errors with it not being able to find the alt_main.c file even thought I think (???) I changed the correct makefile to build a the cpp file.
Just one zipped up example of a complete project and bsp would be great if anyone has one. It just seems like it should be a no-brainer, but I just keep going around in circles. Thanks again.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with others known extensions like .cc .C
I've heard of this problem- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After much trial and error I have found a solution to building a simple CPP project.
- Build the BSP as usual (I make sure to check the enable small lib and small drivers).
- Build a NIOS-II project based on the BSP.
- With the project selected, add a new file to the project. I used the "File from Template". Make sure it has the .cpp extension. Now you should have the file insterted in your project, but it will have no code inside.
- Open the file for editing and insert the standard main() function, I used:

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page