Hello,
I've always wrote my own header files (maximum of 2) and programs from scratch in classes. Now that I'm doing research, I need to use someone else's libraries for cryptography. I've downloaded the code, but I don't really understand how I'm supposed to use it. If anyone is interested, I'm trying to work with the libecc library located here.
Anyway, I'd really like someone to point me in the direction of a tutorial or just give me some advice on how to incorporate someone else's code (such as libecc) into my own.
Thanks!
How to Use Libraries?
Page 1 of 113 Replies - 3885 Views - Last Post: 27 June 2011 - 04:05 PM
Replies To: How to Use Libraries?
#2
Re: How to Use Libraries?
Posted 25 June 2011 - 08:27 AM
Which compiler? The process is different depending on your compiler (and sometimes IDE).
#4
Re: How to Use Libraries?
Posted 25 June 2011 - 08:56 AM
Assuming the name of the library is libecc.a, you will use a command line like
The manual on this
g++ -ggdb3 -Wall -pedantic -o myprog myprog.cpp -L/path/to/directory/containing/libecc.a -lecc
The manual on this
#5
Re: How to Use Libraries?
Posted 25 June 2011 - 09:07 AM
While there might be a couple of generalities the actual process changes from library to library.
The two BIG points are: a. Tell the compiler where the include files are, b. tell the compiler/linker where the libraries are (and tell the compiler/linker which ones you need).
So for libecc it looks like you run
./configure
make
make install
and it will put the includes and libs in /usr/local directory and (I am not a linux/unix guy) I think that should already be setup with your compiler so you should just have to add a -lecc
I could be wrong (alas I am on windows so...)
The two BIG points are: a. Tell the compiler where the include files are, b. tell the compiler/linker where the libraries are (and tell the compiler/linker which ones you need).
So for libecc it looks like you run
./configure
make
make install
and it will put the includes and libs in /usr/local directory and (I am not a linux/unix guy) I think that should already be setup with your compiler so you should just have to add a -lecc
I could be wrong (alas I am on windows so...)
#6
Re: How to Use Libraries?
Posted 25 June 2011 - 09:37 AM
Thanks for the help so far. I'll see how far this gets me and let you know if I run into issues.
#7
Re: How to Use Libraries?
Posted 25 June 2011 - 12:04 PM
I ran './configure' in the directory, but after that 'make' and 'make install' wouldn't work. In addition to that, 'locate ecc.a' returned nothing.
Any ideas?
Any ideas?
#8
Re: How to Use Libraries?
Posted 25 June 2011 - 12:07 PM
No errors on configure or make? You didn't perhaps get this error on configure?
configure: error: * Cannot find -lgmpxx (see config.log for more info), did you configure gmp with --enable-cxx? * You need gmp version 4.1 or higher (rpm: gmp-4.1 and gmp-devel-4.1), see http://swox.com/gmp/.
#9
Re: How to Use Libraries?
Posted 25 June 2011 - 12:31 PM
Nice catch. I just saw that it ended and assumed all was well. 
Any ideas on how I can fix that?
Any ideas on how I can fix that?
#10
Re: How to Use Libraries?
Posted 25 June 2011 - 12:33 PM
I would hazard to say that you need to acquire libgmp and compile it with the noted flag, --enable-cxx. But that's just a guess from reading the error!
#11
Re: How to Use Libraries?
Posted 25 June 2011 - 12:53 PM
Right.
I have these currently on my computer:
I'm assuming it's not one of these, nor is it apt-getable.
So I decided to go to the website, download it, and try the same thing that I did with this (run './configure').
Now I'm in the same boat with:
I'm just wondering if this is going to be an endless string of missing dependencies.
I have these currently on my computer:
/usr/lib/libgmp.so.3 /usr/lib/libgmp.so.3.5.2 /usr/lib/libgmpxx.so.4 /usr/lib/libgmpxx.so.4.1.2 /usr/lib/ssl/engines/libgmp.so /usr/lib32/ssl/engines/libgmp.so
I'm assuming it's not one of these, nor is it apt-getable.
So I decided to go to the website, download it, and try the same thing that I did with this (run './configure').
Now I'm in the same boat with:
checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons).
I'm just wondering if this is going to be an endless string of missing dependencies.
This post has been edited by xTorvos: 25 June 2011 - 12:56 PM
#12
Re: How to Use Libraries?
Posted 26 June 2011 - 10:31 AM
Is it necessary to use ./configure and make? Can't I just move the directories with the header files to where I'm developing? I tried doing this and got errors, but shouldn't this be possible?
#13
Re: How to Use Libraries?
Posted 26 June 2011 - 02:45 PM
That is only possible in the case of "header only libraries" and this is not one.
Think about how compiling works:
the preprocessor takes a .c file and several .h files and pastes them all together and feeds them to the compiler. The compiler generates an .o (or .obj on windows -- an object file) and passes it on the the linker. The liker takes the .o file(s) and extracts the "object code" which it links together with other object files and libraries (.a or .lib) to produce the final output executable.
So -- headers tell the compiler how to call functions that has object code (compiled code) stored in an object file or a library. So just having the header file does not give the linker the object code it needs. So while you will be able to compile, you will not be able to link.
the ./configure will customize the make files (and other files) for your environment, and the make will compile the source code to object files and then put the object files into libraries.
So yes you do need these steps. UNLESS you can find a pre-compiled version of the library compatible with your compiler (which actually can be very hard which is why the ./configure is required in the first place).
What environment are you using?
Think about how compiling works:
the preprocessor takes a .c file and several .h files and pastes them all together and feeds them to the compiler. The compiler generates an .o (or .obj on windows -- an object file) and passes it on the the linker. The liker takes the .o file(s) and extracts the "object code" which it links together with other object files and libraries (.a or .lib) to produce the final output executable.
So -- headers tell the compiler how to call functions that has object code (compiled code) stored in an object file or a library. So just having the header file does not give the linker the object code it needs. So while you will be able to compile, you will not be able to link.
the ./configure will customize the make files (and other files) for your environment, and the make will compile the source code to object files and then put the object files into libraries.
So yes you do need these steps. UNLESS you can find a pre-compiled version of the library compatible with your compiler (which actually can be very hard which is why the ./configure is required in the first place).
What environment are you using?
#14
Re: How to Use Libraries?
Posted 27 June 2011 - 04:05 PM
Thanks for the quick lesson. 
I'm running Ubuntu 11.04 x64 and using the gcc/g++ compiler. If that's not what you meant then please elaborate.
Thanks again!
I'm running Ubuntu 11.04 x64 and using the gcc/g++ compiler. If that's not what you meant then please elaborate.
Thanks again!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|