473,396 Members | 1,972 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.

Compilation Error using ANN Approximate nearest neighbour library

Hi,
I am not very familiar with C++ so the problems I am having might be
simple and I just cannot see them or I am totally unaware of why something
would be incorrect. Anyway, I'm using the ANN approximate nearest
neighbour libraries written by David Mount and Sunil Arya. In the ANN.h
file there is a comment describing how the data types used to represent
the coordinates and distances between points can be modified by the user.
For my use of library it would be most convientent to use a float instead
of the default double type. When I compile the program initially with the
original settings I do not get errors, but when I modify the header file
for the float type I get the error:

[stewart@samples]$ g++ ann_sample.cc -I/home/stewart/ANN/include
-L/home/stewart/ANN/lib -lANN -Wno-deprecated
/tmp/ccrhNdym.o(.text+0x123): In function `main':
: undefined reference to `annAllocPt(int, float)'
/tmp/ccrhNdym.o(.text+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::ANNkd_tree[in-charge](float**, int,
: int, i
nt, ANNsplitRule)'
collect2: ld returned 1 exit status

The program I am using and the modified header file (the types of
ANNcoord and ANNdist are now float, and ANN_DIST_INF is now MAXFLOAT) are
rather long so I have links to each.

http://v5o5jotqkgfu3btr91t7w5fhzedja...a/~m0f14/ANN.h
http://v5o5jotqkgfu3btr91t7w5fhzedja.../ann_sample.cc

Thanks for any help,
Travis
Jul 22 '05 #1
4 3846
Travis Stewart wrote:
I am not very familiar with C++ so the problems I am having might be
simple and I just cannot see them or I am totally unaware of why something
would be incorrect. Anyway, I'm using the ANN approximate nearest
neighbour libraries written by David Mount and Sunil Arya. In the ANN.h
file there is a comment describing how the data types used to represent
the coordinates and distances between points can be modified by the user.
For my use of library it would be most convientent to use a float instead
of the default double type. When I compile the program initially with the
original settings I do not get errors, but when I modify the header file
for the float type
Don't. The library needs 'double', you have to give it double. Who in
the world told you that you could modify the header without modifying the
library itself?
I get the error:

[stewart@samples]$ g++ ann_sample.cc -I/home/stewart/ANN/include
-L/home/stewart/ANN/lib -lANN -Wno-deprecated
/tmp/ccrhNdym.o(.text+0x123): In function `main':
: undefined reference to `annAllocPt(int, float)'
/tmp/ccrhNdym.o(.text+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::ANNkd_tree[in-charge](float**, int,
: int, i
nt, ANNsplitRule)'
collect2: ld returned 1 exit status

The program I am using and the modified header file (the types of
ANNcoord and ANNdist are now float, and ANN_DIST_INF is now MAXFLOAT) are
rather long so I have links to each.

http://v5o5jotqkgfu3btr91t7w5fhzedja...a/~m0f14/ANN.h
http://v5o5jotqkgfu3btr91t7w5fhzedja.../ann_sample.cc

V
Jul 22 '05 #2
Travis Stewart wrote:

Hi,
I am not very familiar with C++ so the problems I am having might be
simple and I just cannot see them or I am totally unaware of why something
would be incorrect. Anyway, I'm using the ANN approximate nearest
neighbour libraries written by David Mount and Sunil Arya. In the ANN.h
file there is a comment describing how the data types used to represent
the coordinates and distances between points can be modified by the user.
For my use of library it would be most convientent to use a float instead
of the default double type.
Note that in technical applications, float is almost never the
data type one wants to use except in very rare circumstances and
only if the programmer knows what he is doing and is ready to fight
all the problems that come with the reduces precission of float.
When I compile the program initially with the
original settings I do not get errors, but when I modify the header file
for the float type I get the error:

[stewart@samples]$ g++ ann_sample.cc -I/home/stewart/ANN/include
-L/home/stewart/ANN/lib -lANN -Wno-deprecated
/tmp/ccrhNdym.o(.text+0x123): In function `main':
: undefined reference to `annAllocPt(int, float)'
The linker is telling you, that one of the prototypes
announced a function called annAllocPt which
takes an int and a float as arguments.
But when the linker searched for that function it could not find
it.

Since the whole thing links correctly when you use double, I bet
that there is a function annAllocPt which takes an int and
a double.

I suspect the original programmer to have made a mistake:
In the Ann.h file he introduced the prototype

ANNpoint annAllocPt(
int dim, // dimension
ANNcoord c = 0); // coordinate value (all equal)

But when implementing the function he did:

ANNpoint annAllocPt( int dim, double c )
{
// code goes here
}

Since the original program author did never use float for ANNcoord the
error went by undetected.

Search for the functions implementation and verify if my theory holds.

/tmp/ccrhNdym.o(.text+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::ANNkd_tree[in-charge](float**, int,
: int, i
nt, ANNsplitRule)'
collect2: ld returned 1 exit status


I guess this can be explained in pretty much the same way.
Since I think this *is* important, I would like to repeat one thing:
If you don't know what bag of worms you probably open by changing
double to float and have the knowledge of fighting against those
worms, don't use float!
I don't know you in person and I don't know if you are a newbie or not.
But if you are a newbie: don't use float!

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #3
Karl Heinz Buchegger wrote:


Ooops. I missed the fact, that you link against a prebuilt
library.
You can't do what you want. The library is cmopiled
for double, you have to use it that way.

The situation would be different, if you have the source
code and build the library on your own.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #4
As Karl pointed out, you need a library that is built with the float
option. I have been using the library of Arya and Mount for quite a
while and compiled it with the float option turned on. It works really
well (no problem in using float instead of double).
So, recompile the library and you should be fine.

Joes.
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John Hunter | last post by:
I have a list of two tuples containing x and y coord (x0, y0) (x1, y1) ... (xn, yn) Given a new point x,y, I would like to find the point in the list closest to x,y. I have to do this a...
11
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
0
by: Mythran | last post by:
I'm getting this error and Microsoft's site states that the way we are using our libraries is unsupported and the error is by design (go figure). My setup is simple and why it isn't supported is...
13
by: Crirus | last post by:
The main ideea: I havea 513x513 array of values....I draw a sort of map using that values for colors... so I have a realistic lanscape (map). I want to zoom about 60 times that map...and the...
1
by: maryjones11289 | last post by:
Hi All, I'm trying to write/find code that creates a Ternary Search Tree in Visual Basic (VB6 or .NET). Here's my situation: What I have is an array consisting of 60,000 string elements. All...
10
by: newgoat | last post by:
Hello, I wrote two program to test the inherent problem binary system has with representing floating points values. Adding 0.1 to itself 1000 times results in a number slightly larger than 100....
3
oll3i
by: oll3i | last post by:
When i have DNA test data like the data below just few first rows pasted here first number is the number of rows and second number is the number of columns 21st column is a decision 1186 21 1 2...
0
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
clintonb wrote: There is nothing like an original double amount. If you care about rounding errors you must not store any currency value in an approximate number. You must not do this even once....
8
by: Henrik Skak Pedersen | last post by:
Hi, I have the following very simple code snippet: line 1: float f; line 2: f = 100000.99f; Why is f: 100000.992 after line 2? I would assume it to be 100000.99. Cheers
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.