str=new char[103];
I am trying to program a few simple apps in C++ under Mandrake Linux using the gcc3.2 compiler. Everything works except the new operator. How can I get it working?>
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Well, did you say char *str first?
<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
yes, the error is that the new operator is "not defined"
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
krumms, that would only be a problem if A) his setup does not recognize standard C++ file extensions as C++ files, or, B) he is not using a standard C++ file extension. Modern versions of gcc recognize that a .cpp or .cc or .cxx, etc. files are C++ files, and should compile and link accordingly.
Of course, you should definately at least try this first, and that might tell you what the problem is.
<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
Of course, you should definately at least try this first, and that might tell you what the problem is.
<img src=http://webspace.utexas.edu/~mvdepala/random/resist-ignorance.png
April 29, 2003 12:35 AM
quote:
Original post by tHiSiSbOb
yes, the error is that the new operator is "not defined"
Do you mean something like this:
/tmp/ccyZ2uXU.o(.text+0x16): In function `main'':: undefined reference to `operator new[](unsigned)''/tmp/ccyZ2uXU.o(.text+0x2d): In function `main'':: undefined reference to `operator delete[](void*)''/tmp/ccyZ2uXU.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0''
If so, krumms is right. Use g++ and not gcc. Gcc will invoke g++ to compile your code, but it won''t link with the C++ library. Either use g++ or explicitly link with libstdc++:
g++ -o progname source.cc
or
gcc -o progname source.cc -lstdc++
If it doesn''t help, try to provide more informations, like the exact error message.
Hope this helps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement