Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12709 Discussions

Problems with the chrono library in NIOS II

CaptainPrice15
1,476 Views

Even though the includes in the bsp has the chrono library and #include<chrono> doesn't throw any error, when the library is used, there is always an error

 

For Example,

when I use "std::chrono::high_resolution_clock::duration timeout = std::chrono::seconds(0)" the following error is thrown:

Multiple markers at this line
- Type 'std::chrono::high_resolution_clock::duration' could not be
resolved
- Function 'seconds' could not be resolved.

 

I am using a NIOS II/e core in Quartus Prime Lite 18.0 for Max 10. 

P.S. The exact same piece of code works in normal C++ environment but not in NIOS II environment.

0 Kudos
1 Solution
aikeu
Employee
1,272 Views

Hi CaptainPrice15,


The screenshot is just to show the application is able to run with the chrono library.

Try to compile/build all even when you see the errors while editing the code.


Thanks.

Regards,

Aik Eu


View solution in original post

0 Kudos
12 Replies
aikeu
Employee
1,415 Views

Hi CaptainPrice15,


Just a simply quick check, If you try the below, will there be any error?


#include <iostream>   

#include <chrono>   

 

int main ()

{

  using namespace std::chrono;

  // std::chrono::milliseconds is an 

  // instantiation of std::chrono::duration:- 1 second

  milliseconds mil(1000); 

   

  mil = mil*60;


  std::cout << "duration (in periods): ";

  std::cout << mil.count() << " milliseconds.\n";

 

  return 0;

}


Thanks.

Regards,

Aik Eu


0 Kudos
CaptainPrice15
1,396 Views

Hello @aikeu,

 

Thanks a lot for your reply.

 

Yes, there will be an error in the code. In the line "using namespace std::chrono;" it says Symbol chrono could not be resolved. 

 

I have checked that the chrono library is present in includes and is under path "Quartus installation path"/nios2eds/bin/gnu/nios2-elf/include/c++/5.3.0

 

In project properties, under Nios II Application Properties, the user flag -std=c++11 is also specified (as chrono library requires atleast C++11) and ofcourse the BSP project is linked as well.

 

Best Regards

 

 

0 Kudos
aikeu
Employee
1,331 Views

Hi CaptainPrice15,


Sorry for late reply, with the help of my team member he was able to notice the error but you can proceed to build all for the program to work.


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
1,328 Views

Temp86.png

0 Kudos
CaptainPrice15
1,275 Views

Hi @aikeu ,

 

Thanks a lot for your reply.

 

It is a bit bit difficult to understand the solution just from this screenshot. Could you please explain in detail what exactly the solution is and how can I use the chrono library in NIOS II?

 

Thanks in advance.

0 Kudos
aikeu
Employee
1,296 Views

Hi CaptainPrice15,


I will close the thread if no further feedback from the case.


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
1,273 Views

Hi CaptainPrice15,


The screenshot is just to show the application is able to run with the chrono library.

Try to compile/build all even when you see the errors while editing the code.


Thanks.

Regards,

Aik Eu


0 Kudos
CaptainPrice15
1,271 Views

Hi @aikeu ,

 

Thanks for the quick reply. I did try that. But as said before, the code doesn't build and the compiler throws the above mentioned errors.

0 Kudos
aikeu
Employee
1,262 Views

Hi CaptainPrice15,


Let me check back with my team member who managed to build an example application and get back to you next week, he is on leave today.

With build all, supposed you will see the BSP build complete and generate the elf file to run the application. Let me show some additional screenshots after this.


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
1,260 Views

aikeu_0-1725606755772.pngaikeu_1-1725606779163.pngaikeu_2-1725606813392.png

 

0 Kudos
CaptainPrice15
1,227 Views

Hi @aikeu 

 

Thanks for your support. The problem has been resolved. The problem was apparently with std::chrono::high_resolution_clock::duration. Replaced that with std::chrono::_V2::system_clock::duration and it works now. 

As you said, it still throws an error while editing the code (which can be ignored) but it does build properly.

 

Thanks a lot once again!

0 Kudos
aikeu
Employee
1,095 Views

Hi CaptainPrice15,


Glad to hear that the issue has been resolved, I now transition this thread to community support. If you have a new question, Please login to ‘https://supporttickets.intel.com/s/?language=en_US’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


Thanks.

Regards,

Aik Eu


0 Kudos
Reply