Solved

Need some help compiling a C++ code for a R*-tree

Posted on 2009-07-03
10
281 Views
Last Modified: 2012-05-07
I have this code in C++ that I'm learning how to use, but I cannot compile it because I get an error saying it cannot find the io.h.

Isn't the io.h part of the OS?
0
Comment
Question by:Trexgreen
  • 6
  • 3
10 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 24773797
Compiler? Version? Example of code? Exact error?
0
 

Author Comment

by:Trexgreen
ID: 24773891
I got that to compile... now I'm having some other problems, linking the files.

Here are the files that I have.

main.cpp ( links to Rjoinr.hpp)
Rjoinr.cpp ( links to Rjoinr.hpp, Heap.hpp, kHeap.hpp, PQMxMxD.hpp)
Heap.cpp (links to Heap.hpp)
kheap.cpp (links to kheap.hpp, Rstart.cpp)
PQMxMxD.cpp (links to PQMxMxD.hpp, Rstart.cpp)
Rstar.cpp (links to Rstar.hpp, lrubuff.hpp)
lrubuff.cpp (links to lrubuff.hpp)

I compiled all the files using g++ -c filename.cpp
now I have al the .o files, but when I try to compile the main.cpp file g++ -o main main.o

I get the following error.
main.cpp: (. text+0x2445): undefined reference to 'RjoinR::statistics()'
....

I also get the same error when I do this g++ -o main main.o RjoinR.o

You can download the files here
http://tinyurl.com/myat8o
0
 

Author Comment

by:Trexgreen
ID: 24773901
g++ Version 4.3.3 Debian 4.3.3-10
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:Trexgreen
ID: 24773961
Add more points to the question, so I can get some help with the rest of the compilation.
0
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24773999
Your sources might be corrupted, but anyways, try gcc -o main main.cpp Rjoinr.cpp Heap.cpp kheap.cpp PQMxMxD.cpp Rstar.cpp lrubuff.cpp
0
 
LVL 12

Expert Comment

by:Let_Me_Be
ID: 24774000
Uh, sorry g++ of course.
0
 

Author Comment

by:Trexgreen
ID: 24774084
Here is the error I'm getting....

This error only occure when I compile the main.cpp with all the others .o files, because the .o files I'm able to create without a problem.
/tmp/cckUsHqn.o: In function `main':
main.cpp:(.text+0x5ba): undefined reference to `RjoinR::closestPQBuff(bool)'
main.cpp:(.text+0x724): undefined reference to `RjoinR::closestPQSortBuff(bool)'
main.cpp:(.text+0x895): undefined reference to `RjoinR::closestPQHeapBuff(bool, int)'
main.cpp:(.text+0xe89): undefined reference to `RjoinR::closestPQBuff_DHT(bool)'
main.cpp:(.text+0xff3): undefined reference to `RjoinR::closestPQSortBuff_DHT(bool)'
main.cpp:(.text+0x1164): undefined reference to `RjoinR::closestPQHeapBuff_DHT(bool, int)'
main.cpp:(.text+0x12e5): undefined reference to `RjoinR::K_closestPQBuff_DHT(int, bool, bool, bool)'
main.cpp:(.text+0x1466): undefined reference to `RjoinR::K_closestPQSortBuff_DHT(int, bool, bool, bool)'
main.cpp:(.text+0x15ee): undefined reference to `RjoinR::K_closestPQHeapBuff_DHT(int, bool, bool, bool, int)'
main.cpp:(.text+0x19c4): undefined reference to `RjoinR::closestPQPlaneSweepBuff(bool, bool)'
main.cpp:(.text+0x1b3d): undefined reference to `RjoinR::closestPQHeapPSBuff(bool, bool, int)'
main.cpp:(.text+0x1fb8): undefined reference to `RjoinR::closestPQPlaneSweepBuff_DHT(bool, bool)'
main.cpp:(.text+0x2131): undefined reference to `RjoinR::closestPQHeapPSBuff_DHT(bool, bool, int)'
main.cpp:(.text+0x22b2): undefined reference to `RjoinR::K_closestPQPlaneSweepBuff_DHT(int, bool, bool, bool)'
main.cpp:(.text+0x243a): undefined reference to `RjoinR::K_closestPQHeapPSBuff_DHT(int, bool, bool, bool, int)'
/tmp/ccsAlRGx.o: In function `RjoinR::K_closestPQPlaneSweepBuff(kHeap*,
int, int, int, int, bool, bool)':
RjoinR.cpp:(.text+0x5c5b): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x629f): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x65a2): undefined reference to `RjoinR::quickSort(double*, int, int)'
/tmp/ccsAlRGx.o: In function `RjoinR::K_closestPQSortBuff(kHeap*, int, int, int, int, bool, bool)':
RjoinR.cpp:(.text+0x7dbc): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x7e3f): undefined reference to `RjoinR::mergeSortCPQ(ArrayElement*, int, int)'
RjoinR.cpp:(.text+0x818c): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x8212): undefined reference to `RjoinR::mergeSortCPQ(ArrayElement*, int, int)'
RjoinR.cpp:(.text+0x8510): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x8596): undefined reference to `RjoinR::mergeSortCPQ(ArrayElement*, int, int)'
/tmp/ccsAlRGx.o: In function `RjoinR::K_closestPQBuff(kHeap*, int, int, int, int, bool, bool)':
RjoinR.cpp:(.text+0x931a): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x960d): undefined reference to `RjoinR::quickSort(double*, int, int)'
RjoinR.cpp:(.text+0x988b): undefined reference to `RjoinR::quickSort(double*, int, int)'
collect2: ld returned 1 exit status

Open in new window

0
 

Author Comment

by:Trexgreen
ID: 24774089
Also all I'm trying to do is read a datafile, and build the index creating the r-tree, and if I have a set of queries I need to calculate the AVG. execution time and the AVG. IO.
0
 
LVL 12

Accepted Solution

by:
Let_Me_Be earned 500 total points
ID: 24774102
I just downloaded the project.

First of all, the project has incorectly named files. kheap.hpp and kheap.cpp should be called kHeap.hpp and kHeap.cpp

Also main is not returning int (it should).

Otherwise the compilation is completely straitforward, just run:
g++ Heap.cpp  kHeap.cpp  lrubuff.cpp  main.cpp  PQMxMxD.cpp  RjoinR.cpp  RjoinR0.cpp  RjoinR1.cpp  RjoinR2.cpp  Rstar.cpp -o main
0
 

Author Comment

by:Trexgreen
ID: 24774273
Let Me Be:

Thank you for the comment.. I had the kHeap fixed... but I was compiling the without the two other RjoinR files... :) I guess I'm tired...

Any way... thank you so much.. it worked...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ standard library based binary archive format 6 104
Add values of each row in an array 3 63
Copy output image from TWindowsMediaPlayer 6 48
C++ Code Issue 4 23
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question