473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dev-C++/gcc compile question

mikejfe
12
Hi all. I've written a program that dynamically allocates memory for a 3dim array, reads a file into that array, does some stuff to the data in the array and then outputs the array to a file.

I can compile my program with Dev-C++ and run it all day long on my laptop (Windows XP). The problem with this is my laptop is slow. So, I tried to compile the code with gcc on my Linux box. gcc, however, doesn't seem to like my code.

The error I get says: "In function `__static_initialization_and_destruction_0(int, int':." Then errors go on for another page or two. I've included the code that makes the array (if I need to include more code, I'll be more than happy).

I know about enough C++ to get done what I need, and am a new Linux user.

Thanks in advance for your help.

Expand|Select|Wrap|Line Numbers
  1. #include<fstream>
  2. #include<iostream>
  3. #include<math.h>
  4. #include<string>
  5.  
  6. using namespace std;
  7.  
  8. // Voxel information array
  9. float ***xyz = NULL;
  10.  
  11. int main()
  12. {
  13. // Ask user for input file
  14. string filename;
  15. cout << "File, array size (*.* DIM DIM DIM): ";
  16. int numOfVoxelsX;
  17. int numOfVoxelsY;
  18. int numOfVoxelsZ;
  19. cin >> filename >> numOfVoxelsX >> numOfVoxelsY >> numOfVoxelsZ;
  20. string outputFileName;
  21. cout << endl;
  22. cout << "Output File Name (*.*): ";
  23. cin >> outputFileName; 
  24.  
  25. cout << "Initializing" << endl;
  26.  
  27. xyz = new float**[numOfVoxelsX];
  28. for (i = 0; i<numOfVoxelsX; i++)
  29.   {
  30.     xyz[i] = new float*[numOfVoxelsY];
  31.     for (j = 0; j<numOfVoxelsY; j++)
  32.       {
  33.         xyz[i][j] = new float[numOfVoxelsZ];
  34.       }
  35.   }
  36. cout << "Space allocated." << endl;
  37.  
  38. .....
  39.  
Nov 16 '07 #1
2 2404
weaknessforcats
9,208 Expert Mod 8TB
You didn't post this function: __static_initialization_and_destruction_0.

And you didn't post the errors you are getting. Generally, only the first error is important. Fix it and the others may go away.
Nov 16 '07 #2
mikejfe
12
Honestly, I don't even know what function that is. I didn't knowingly call it. This program is so simplistic; there is no header file and everything I do is completely contained in int main().

The first few lines of the errors are:
Expand|Select|Wrap|Line Numbers
  1. /tmp/ccN8BUK4.o: In function `__static_initialization_and_destruction_(int, int)':
  2. VoxelizedPhantomResizer.cpp:(.test+0x23): undefiend reference to 'std::ios_base:Init:Init()'
  3. /tmp/ccN8BUK4.o: In function `__static_initialization_and_destruction_(int, int)':
  4. VoxelizedPhantomResizer.cpp:(.test+0x23): undefiend reference to 'std::ios_base:Init:~Init()'
  5.  
The rest of my code follows (continuing from my first post):
Expand|Select|Wrap|Line Numbers
  1. ......
  2.  
  3. // Some vars for counting things in loops
  4. int i = 0;
  5. int j = 0;
  6. int k = 0;
  7.  
  8. // Used to convert the var read from file into a double
  9. const char *filevalueConstChar;
  10. float filevalueFloat;
  11. string filevalue;
  12.  
  13. // Write to the 3Dim array
  14. i = 0; j = 0; k = 0;
  15. ifstream fin(filename.c_str(), ios::in);
  16.   if (fin.is_open())
  17.     {
  18.       cout << endl;
  19.       cout << "Loading " << filename.c_str() << endl;
  20.       while(!fin.eof())
  21.         {          
  22.           ws(getline(fin,filevalue, ' '));
  23.           filevalueConstChar = filevalue.c_str();
  24.           filevalueFloat = (float) atof (filevalueConstChar);
  25.           xyz[i][j][k] = filevalueFloat;
  26.  
  27.           i = (i+1)%numOfVoxelsX;
  28.           if (i==0)
  29.               {j = (j+1)%numOfVoxelsY;}
  30.           if (i==0 && j==0)
  31.             {
  32.               if ((int)k%(numOfVoxelsZ/10)==0)
  33.                 {
  34.                   cout << (float) k*100.0/numOfVoxelsZ << "%" << endl;
  35.                 }
  36.               k = (k+1)%numOfVoxelsZ;
  37.             }
  38.         }
  39.       fin.close();
  40.     }
  41.   else
  42.     {
  43.       cout << endl;
  44.       cout << "--ERROR--" << endl;
  45.       cout << "Unable to open file: " << filename.c_str() << endl << endl << endl;          
  46.     }
  47. cout << filename.c_str() << " loaded." << endl;
  48.  
  49. // Find the phantom edges and clip
  50. i=0;
  51. j=0;
  52. k=0;
  53. // Vars used for setting places to clip superfluious voxels
  54. int maxX = 0, minX = numOfVoxelsX;
  55. int maxY = 0, minY = numOfVoxelsY;
  56. int maxZ = 0, minZ = numOfVoxelsZ;
  57. // Flags for finding edges
  58. bool foundMinX = false;
  59. bool foundMinY = false;
  60. bool foundMinZ = false;
  61.  
  62. cout << "Finding phantom edges...";
  63. while(k!=numOfVoxelsZ)
  64.   {
  65.     if(xyz[i][j][k] != 0) 
  66.       {
  67.         if (i<minX)
  68.             {minX = i;}
  69.         foundMinX = true;
  70.  
  71.         if (j<minY)
  72.             {minY = j;}
  73.         foundMinY = true;
  74.  
  75.         if (k<minZ)
  76.             {minZ = k;}
  77.         foundMinZ = true;
  78.       }
  79.  
  80.     if(xyz[i][j][k] == 0 && foundMinX == true)
  81.       {
  82.         if (maxX<i)
  83.             {maxX = i;}
  84.         foundMinX = false;
  85.       }
  86.  
  87.     if(xyz[i][j][k] == 0 && foundMinY == true)
  88.       {
  89.         if (maxY<j)
  90.             {maxY = j;}
  91.         foundMinY = false;
  92.       }
  93.  
  94.     if(xyz[i][j][k] == 0 && foundMinZ == true)
  95.       {
  96.         if (maxZ<k)
  97.             {maxZ = k;}
  98.         foundMinZ = false;
  99.       }
  100.  
  101.     i = (i+1)%numOfVoxelsX;
  102.     if (i==0)
  103.         {j = (j+1)%numOfVoxelsY;}
  104.     if (i==0 && j==0)
  105.         {k++;}
  106.   }
  107. cout << "done." << endl;
  108. // This is the end of finding the phantom edges.
  109.  
  110. cout << "Reorganizing...";
  111.  
  112. int clippingVolumeUB;
  113. int clippingVolumeLB;
  114.  
  115. if (maxX>maxY && maxX>maxZ)
  116.   {
  117.     clippingVolumeUB = maxX;
  118.   }
  119. if (maxY>maxX && maxY>maxZ)
  120.   {
  121.     clippingVolumeUB = maxY;
  122.   }
  123. if (maxZ>maxX && maxZ>maxX)
  124.   {
  125.     clippingVolumeUB = maxZ;
  126.   }
  127.  
  128. i=clippingVolumeUB;
  129. j=clippingVolumeUB;
  130. k=clippingVolumeUB;
  131.  
  132. if (minX<minY && minX<minZ)
  133.   {
  134.     clippingVolumeLB = minX;
  135.   }
  136. if (minY<minX && minY<minZ)
  137.   {
  138.     clippingVolumeLB = minY;
  139.   }
  140. if (minZ<minX && minZ<minX)
  141.   {
  142.     clippingVolumeLB = minZ;
  143.   }
  144.  
  145. i=clippingVolumeLB;
  146. j=clippingVolumeLB;
  147. k=clippingVolumeLB;
  148.  
  149. cout << "Writing " << outputFileName.c_str() << endl << endl;
  150.  
  151. ofstream fOut(outputFileName.c_str(),ios::out);
  152. if (!fOut)
  153.   {
  154.     cout << "Unable to open file for writing" << endl;
  155.   }
  156. else
  157.   {
  158.     for(k=0; k<numOfVoxelsZ; k++)
  159.       {
  160.         if((int)k%(numOfVoxelsZ/10)==0)
  161.           {
  162.             cout << "Writing Slice: " << k+1;
  163.           }
  164.         for(j=0; j<numOfVoxelsY; j++)
  165.           {
  166.             for(i=0; i<numOfVoxelsX; i++)
  167.               {
  168.                 fOut << xyz[i][j][k] << " ";
  169.               }
  170.             fOut << endl;
  171.           }
  172.           if(k%(numOfVoxelsZ/10)==0)
  173.             {
  174.               cout << "    Percent Done: " << (k*100/numOfVoxelsZ) << endl;
  175.             }
  176.  
  177.       }
  178.    fOut.close();
  179.    }
  180.  
  181. return(0)
  182.  
Nov 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: simduss | last post by:
Hi, First of all, I'm a beginner with Unix. I have a "make" (Unix command) problem with a Pro*C sub-program since I installed Oracle8i (before I was at 7.3.4). I have a script builder that...
2
by: renagade629 | last post by:
Can anybody help me understand what i'm doing wrong or what I'm missing? Is there anyother good and commendable C++ program I can use (free) from the internet like Dev C++? I'm having trouble doing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.