/usr/bin/ld: Undefined symbols with openssl on Mac OS X 10.4

S

smartie

Hello everybody,
i'm writing some simple C code (in Mac OS X 10.4) that uses an openssl
library. The library is included with:

#include <openssl/bn.h>

and I have installed it correctly because when in my program I
declare:

BIGNUM *a;
BIGNUM *b;
BIGNUM *n;

everything compiles correctly.

I experience an error when i compile:

a = BN_new();
b = BN_new();
n = BN_new();

The output is the following:

/usr/bin/ld: Undefined symbols:
_BN_new
collect2: ld returned 1 exit status

How can i fix this problem?
Thank you very much for your interest.
Paolo
 
M

Martin Ambuhl

smartie said:
Hello everybody,
i'm writing some simple C code (in Mac OS X 10.4) that uses an openssl
library. The library is included with:

#include <openssl/bn.h>

I doubt that you are right. That is a header which provides an
interface (API in the jargon de jour) to the library, which library
almost certainly must be linked with your compilation to form an
executable.
and I have installed it correctly because when in my program I
declare:

BIGNUM *a;
BIGNUM *b;
BIGNUM *n;

everything compiles correctly.

I experience an error when i compile:

a = BN_new();
b = BN_new();
n = BN_new();

The output is the following:

/usr/bin/ld: Undefined symbols:
_BN_new
collect2: ld returned 1 exit status

Which suggests strongly that you did not link the appropriate library.
Your implementation's documentation will almost certainly tells you how
to do this.
How can i fix this problem?

By reading the documentation and by learning C before blindly rushing
into things for which you are unprepared.
Thank you very much for your interest.

Bummer. I found this not at all interesting.
 
S

smartie

By reading the documentation and by learning C before blindly rushing
into things for which you are unprepared.
I think that is a clear example of how to NOT reply to a post. Maybe
you're very prepared on this argument, but I think that you have very
much to learn about politeness.
Bummer. I found this not at all interesting.

If you found this not at all interesting, you could not reply.
Probably it would be better for you...and for me. Please do not reply
anymore, considering that I write just boring things.

I hope that someone else could help me much better.

Thank you all very much (except someone).
 
E

Eric Sosman

smartie wrote On 07/02/07 16:25,:
I think that is a clear example of how to NOT reply to a post. Maybe
you're very prepared on this argument, but I think that you have very
much to learn about politeness.




If you found this not at all interesting, you could not reply.
Probably it would be better for you...and for me. Please do not reply
anymore, considering that I write just boring things.

I hope that someone else could help me much better.

Thank you all very much (except someone).

Well, he *did* tell you what was probably wrong --
twice, in fact -- and gave the reasoning behind his
diagnosis of the likely problem. If you can't carry
the ball after he's handed it to you, well ...

Why didn't he tell you exactly which keys to press
to make your problem go away? I don't know for sure,
but one possible reason is that he doesn't know. He
may be unfamiliar with the compiler you use and with the
ways you tell it how to find libraries; he may not know
where on your system the necessary library is stored.
Filling in such blanks is your job, not his, hence the
recommendation to read the documentation.

Finally, the "learn C" and "unprepared" part: Any
programmer who has not yet learned how to manage libraries
that aren't part of the provided-by-default set hasn't
had any significant amount of programming experience and
may justifiably be called unprepared, and any C programmer
who does not understand the difference between a header full
of declarations and a library full of implementations has
not yet learned C. There's no shame in being ignorant or
unprepared -- we all begin that way -- but you should not
allow the initial state to persist if you want to justify
your E-mail alias.
 
C

CBFalconer

smartie said:
i'm writing some simple C code (in Mac OS X 10.4) that uses an
openssl library. The library is included with:

#include <openssl/bn.h>

and I have installed it correctly because when in my program I
declare:

BIGNUM *a;
BIGNUM *b;
BIGNUM *n;

everything compiles correctly.

I experience an error when i compile:

a = BN_new();
b = BN_new();
n = BN_new();

The output is the following:

/usr/bin/ld: Undefined symbols:
_BN_new
collect2: ld returned 1 exit status

How can i fix this problem?

Link the library. If the library is "libblah.a" use "-lblah" with
gcc. For other compilers read the documentation.
 
M

Mark McIntyre

I think that is a clear example of how to NOT reply to a post. Maybe
you're very prepared on this argument, but I think that you have very
much to learn about politeness.

You too have much to learn. Usenet is not kindergarten, and you will
meet rude people, and you will have to either ignore them or spend a
lot of time being offended.

As it happens, Martin was also helpful. Taking into account that this
is a FAQ (10.10b), he could have been much ruder...
 
S

SM Ryan

# Hello everybody,
# i'm writing some simple C code (in Mac OS X 10.4) that uses an openssl
# library. The library is included with:
#
# #include <openssl/bn.h>

This gives the compiler the declarations of the library
entry points, but it does not tell the loader where the
object code is loaded. Unfortunately this tends to be
poorly documented, if at all.

DESCRIPTION
The Big Number library is part of libcrypto. It performs arithmetic
operations on integers of arbitrary size. It was written for use in
public key cryptography, such as RSA and Diffie-Hellman.

suggests the library is libcrypto.... which means you need
the loader option -lcrypto.

On Unix as a last resort you can do something like
nm /usr/lib/lib* | grep BN_new
and poke around a bit.



/ cat t.c
#include <openssl/bn.h>

int main(int N,char **P) {
puts("begin");
BIGNUM *a;
BIGNUM *b;
BIGNUM *n;
a = BN_new();
b = BN_new();
n = BN_new();
puts("end");
return 0;
}

/ cc t.c -lcrypto
/ a.out
begin
end
 
J

J. J. Farrell

I think that is a clear example of how to NOT reply to a post. Maybe
you're very prepared on this argument, but I think that you have very
much to learn about politeness.


If you found this not at all interesting, you could not reply.
Probably it would be better for you...and for me. Please do not reply
anymore, considering that I write just boring things.

I hope that someone else could help me much better.

Thank you all very much (except someone).

I'm puzzled by your response. Martin corrected your misapprehension,
told you what was wrong, and told you what you needed to do to correct
it. He may have been a little rude, but it is also rude to post
questions without looking for the answers in the FAQ list first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top