473,756 Members | 7,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(.tex t+0x123): In function `main':
: undefined reference to `annAllocPt(int , float)'
/tmp/ccrhNdym.o(.tex t+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::AN Nkd_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 3868
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(.tex t+0x123): In function `main':
: undefined reference to `annAllocPt(int , float)'
/tmp/ccrhNdym.o(.tex t+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::AN Nkd_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(.tex t+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(.tex t+0x1e0): In function `main':
: undefined reference to `ANNkd_tree::AN Nkd_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
11506
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 lot, in an inner loop, and then I add each new point x,y to the list. I know the range of x and y in
11
2469
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 difficult to understand. I've described it as GOTO's on steroids, and that's what it is!. One argument against abolishing it it that it is useful for conditional compilation when porting code, etc. Well, it seems to me C++ supports that...
0
1377
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 completely unclear to me. 1.) 2 Web Sites in solution, 1 DAL library, 1 BLL library, 1 Schema library (all in same solution). 2.) DAL and BLL libraries are inheriting ServicedComponent, referencing and importing System.EnterpriseServices,...
13
2074
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 zoomed area to be drawn on full screen. I want to draw it smoth not a square of 60 pixels x 60 pixels with one color, because I can see blocks and it's not good. There is a way to interpoate the colors between rectangles to show a smoth zoom?
1
3215
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 elements are exactly 225 characters in length. All elements are made up of 1's and 0's
10
3352
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. But to my surprise, adding it to itself 100000 times results in a number smaller than 10000. Can anybody tell me why? Thanks! #include <stdio.h>
3
1591
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 3 1 3 3 1 3 3 1 2 0 3 2 1 3 2 1 0 2 3 0 0 2 1 0 0 0 2 1 3 2 1 2 2 1 0 3 1 1 3 2 0 3 1 1 0 2 2 0 1 3 1 3 0 0 2 1 1 3 3 1 2 1 2 3 3 3 1 3 0 3 3 1 2 1 3 3 1 3 0 3 3 3 3 0 1 3 3 2 0 3 3 3 3 1 3 3 1 3 1 0 3 2 3 0 2 0 3 2 1 2 2 1 2 3 0 3 1 3 0 2 2 1 0...
0
287
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. Least of all at something like an original value. If you take account of that the question to do a correct back-conversion is obsolete. Of course, if you make some assumptions about the expected values and the domain of the values a conversion...
8
1343
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
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.