Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Rebuild OpenCV libraries in NIOS II (8.0)

:confused:

Hello

I want make a video tracking project on NIOS II.

My project can be successfully built in Eclipse(with CDT) after some configuration work( include path, library path, libraries ), and it can run normaly.

But when I do the same configuration work in a NIOS II project(Hello_world template ), it failed when building project.

I got confused, NIOS II is also base on eclipse, why the same configuration doesn't work?

Is it because the different CDT version or something?

Any one can help me ?

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Should I rebuild OpenCV libraries in NIOS II (8.0)?

    I'm a newbie, can somebody tell me how to build external source code into libraries in NIOS?

    Thank you
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The errors are because you are missing quite a few# includes.

    I'd start aff of adding (probably)# include <stdint.h> in order to get the fixed sized types (eg uint64_t) defined.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks, dsl

    I don't think that is the reason, because with the same configration, the same code can compile and run well in normal eclipse ide.

    I think maybe it's because the cdt vesion in nios2-ide is tool low. In "Nios II Software Developer’s Handbook", it says "The Nios II IDE uses GCC 3, and IDE projects can only be built with GCC 3.", but in my normal eclipse ide, the gcc version is newest(and the OpenCV2.3.1 source code is built by gcc 4.6.1).

    So I want to build the OpenCV source with nios2-ide's compiler to get compatible libraries, but untill now, I still do not know how.

    Yang
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    No this is all about header files and the build environment, not the IDE.

    Your 'working' build is (if I understand you) targetted at a completely different environment.

    You need stdint.h from somewhere.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    No this is all about header files and the build environment, not the IDE.

    Your 'working' build is (if I understand you) targetted at a completely different environment.

    You need stdint.h from somewhere.

    --- Quote End ---

    dsl,

    I found you're right about the stdint.h thing.

    I add "\usr\include\" in the include path, and add# include <stdint.h> in the cpp file. Then errors about "int64" disappeared, but new errors come, shown as follows:

    
    Severity and Description	Path	Resource	Location	Creation Time	Id
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error:   initializing argument 1 of `void* std::memchr(void*, int, size_t)'		hello_world_opencv	line 262	1331094172861	1533
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `memcmp' was not declared in this scope		hello_world_opencv	line 254	1331094172859	1530
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `memcpy' was not declared in this scope		hello_world_opencv	line 270	1331094172863	1535
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `memmove' is not a member of `std'		hello_world_opencv	line 186	1331094172858	1529
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `memmove' was not declared in this scope		hello_world_opencv	line 266	1331094172862	1534
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `memset' was not declared in this scope		hello_world_opencv	line 274	1331094172864	1536
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: `strlen' was not declared in this scope		hello_world_opencv	line 258	1331094172860	1531
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/char_traits.h error: invalid conversion from `const void*' to `void*'		hello_world_opencv	line 262	1331094172861	1532
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/codecvt.h error: `strcmp' is not a member of `std'		hello_world_opencv	line 460	1331094172893	1567
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_classes.h error: `strcmp' is not a member of `std'		hello_world_opencv	line 538	1331094172871	1537
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_classes.h error: `strcpy' is not a member of `std'		hello_world_opencv	line 579	1331094172872	1538
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcmp' was not declared in this scope		hello_world_opencv	line 1167	1331094172889	1565
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcmp' was not declared in this scope		hello_world_opencv	line 1182	1331094172892	1566
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcpy' was not declared in this scope		hello_world_opencv	line 897	1331094172887	1561
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcpy' was not declared in this scope		hello_world_opencv	line 962	1331094172888	1562
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcpy' was not declared in this scope		hello_world_opencv	line 1099	1331094172888	1563
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `memcpy' was not declared in this scope		hello_world_opencv	line 1152	1331094172889	1564
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `strcmp' is not a member of `std'		hello_world_opencv	line 1898	1331094172895	1568
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `strcmp' is not a member of `std'		hello_world_opencv	line 2653	1331094172897	1569
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.h error: `strcmp' is not a member of `std'		hello_world_opencv	line 3932	1331094172901	1572
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1749	1331094172905	1574
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1756	1331094172908	1576
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1764	1331094172910	1577
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1771	1331094172911	1578
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1783	1331094172912	1579
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1790	1331094172913	1580
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1793	1331094172913	1581
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1805	1331094172915	1582
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1810	1331094172917	1583
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc error: invalid use of undefined type `struct tm'		hello_world_opencv	line 1818	1331094172918	1584
    /opt/altera8.0/nios2eds/bin/nios2-gnutools/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/3.4.6/../../../../../include/c++/3.4.6/bits/locale_facets.tcc 
    ...
    

    Can you explain these errors?

    thanks

    Yang
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You are missing more system headers.

    Probably string.h and sys/time.h

    It is also worth always using the unix '/' in directory paths, rather than the microsoft '\'. The former is valid in almost all microsoft tools.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    You are missing more system headers.

    Probably string.h and sys/time.h

    It is also worth always using the unix '/' in directory paths, rather than the microsoft '\'. The former is valid in almost all microsoft tools.

    --- Quote End ---

    After making some change in the original project, I finally passed the compile phase, but when linking, there are errors said the opencv libraries can not be found.

    So I think the problem still lies in the incompatibility between nios2-elf-gcc compiled files and the gcc on my computer system(mine is Ubuntu 11.10)

    So I think I still need to recompile the opencv libraries by nios2-elf-gcc.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You'll need to compile everything with the nios2 compiler.

    The linker will give you errors if you try to link together code from different cpu architectures.

    You also need to make sure the nios compiler isn't reading any header files from /usr/include - they will be the wrong ones. Even if the code compiles it may not run.