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++

*new* problem

Altera_Forum
Honored Contributor II
1,629 Views

I'm trying to create a C++ application for uClinux. Really all I need to do is include a class that I created. If I make a pointer to the class and then try to create a new instance of it, I get erros. If I try to create a static instance of the class I get errors. 

 

using new: 

 

// Class name and then pointer name 

Amd032 *p_AudioMem; 

 

// Pointer name = new instance of my class 

p_AudioMem = new Amd032; 

 

errors: 

(weird ones at the top to long to list) 

undefined refernce to 'Amd032::Amd032()' 

undefined reference to 'operator delete(void*)' 

 

 

staticly: 

 

Amd032 AudioMem; 

 

Neither method works. Is there way around this? Does new work? 

 

Thank you!!
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
349 Views

 

--- Quote Start ---  

originally posted by randog77@Jun 20 2005, 11:40 PM 

i'm trying to create a c++ application for uclinux. really all i need to do is include a class that i created. 

--- Quote End ---  

 

gcc does support new http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif (duh!) 

 

make certain that you use the C++ compiler: 

 

g++ -o myprog -Wl,-efl2flt myfile.c 

 

and not the gcc binary (C compiler). 

 

If I were you, I&#39;d think twice about writing C++ for a nommu arch http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif but that might just be me ...
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

Hi 

I had problems creating objects dynamically with new. 

gcc compiles ok, but in runtime, my application crashes and uClinux restarts when it reach to new sentence. 

If I change my application to use static objects, it works OK. 

 

Any Idea? 

 

Màrius
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

 

--- Quote Start ---  

originally posted by mariusmm@Jun 21 2005, 01:12 PM 

gcc compiles ok, but in runtime, my application crashes and uclinux restarts when it reach to new sentence. 

--- Quote End ---  

 

looks your program is using to much process memory (you cannot relocate with nommu). Try to add more stack space using flthdr.
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

In the Makefile if I change  

DEBUG = 1 

to  

DEBUG = 0 

 

my problem goes away. Strange. 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

mariusMM my program does the same thing as yours now. Dough! Crashes a the new allocation. 

 

what is flthdr?? 

 

I looked for that as a C++ function, I found nothing. 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

flthdr is a nios2 console command. 

 

It can increase stack size. I&#39;ve not tested it yet. 

 

Màrius
0 Kudos
Altera_Forum
Honored Contributor II
349 Views

 

--- Quote Start ---  

originally posted by randog77@Jun 21 2005, 05:11 PM 

what is flthdr?? 

--- Quote End ---  

 

 

I am using my own toolchain on GNU/Linux, but this tools should be available in a Windows install too. 

 

$ flthdr No input files provided usage: flthdr flat-file       Allows you to change an existing flat file       -p      : print current settings       -z      : compressed flat file       -d      : compressed data-only flat file       -Z      : un-compressed flat file       -r      : ram load       -R      : do not RAM load       -k      : kernel traced load (for debug)       -K      : normal non-kernel traced load       -s size : stack size       -o file : output-file                 (default is to modify input file) $ flthdr -p interface interface    Magic:        bFLT    Rev:          4    Build Date:   Wed Jun 22 11:10:40 2005    Entry:        0x44    Data Start:   0xa080    Data End:     0xedb8    BSS End:      0x10e2c    Stack Size:   0x1000    Reloc Start:  0xedb8    Reloc Count:  0x696    Flags:        0x1 ( Load-to-Ram ) $ flthdr -s 8192 interface $ flthdr -p interface interface    Magic:        bFLT    Rev:          4    Build Date:   Wed Jun 22 11:10:40 2005    Entry:        0x44    Data Start:   0xa080    Data End:     0xedb8    BSS End:      0x10e2c    Stack Size:   0x2000    Reloc Start:  0xedb8    Reloc Count:  0x696    Flags:        0x1 ( Load-to-Ram )
0 Kudos
Reply