Thread: Problem with Building My Own Project with Crypto++ (Probably Simple Newbie Issue)

  1. #1
    Registered User TangoOversway's Avatar
    Join Date
    Mar 2013
    Posts
    20

    Problem with Building My Own Project with Crypto++ (Probably Simple Newbie Issue)

    I don't know if I'm dealing with a total newbie problem, or if this is specific to Crypto++ or specific to Eclipse and the CDT, but I'd like to figure out how to build my project with Crypto++ included (or, prefferably, just the files I need to include).


    I'm sure if I were more experienced in C++, I'd know just where to look to figure this out. I've been reading tutorials and code examples. While I'm new to C++, I have done a lot of work in Perl and Java. I can understand or work through a lot of the actual writing of code, but I'm still learning C++ syntax and dealing with issues around building a program.


    In this case, I have a very simple program with just main() and a test subroutine. It builds and does a "Hello World" fine. I'm using the CDT in Eclipse 4.2.1 to do this. I'm on OS X 10.8.2. Eclipse is, by default, using gcc to compile and the MacOS X C++ Linker. (I'd like to use GNU tools for linking, too, just for consistency - using one set of tools, but I guess that doesn't really matter.) Crypto++ is 5.6.2.


    Even though I know Crypto++ is complex, one reason I want to use this from the start is because I know as I get more and more advanced in C++, I won't outgrow it - I'll find more and more that I can use in it.


    I imported Crypto++ into Eclipse as a project with a makefile and it builds successfully on its own.


    The short of it is that I want to use Blowfish (which I've used before under Java) and, later, the DEFLATE/INFLATE features of Crypto++.


    I've been doing a lot of searching on this, but I'm still confused. I thought I needed to add all the .o files to my current project by adding them in the Linker->Miscellaneous section under "Other Objects," and tried that, but then I still needed the header files, so I tried adding the .h files.


    The problem was if I added blowfish.h, then I had to add more headers - and no matter what I did, it needed several dozen header files added. It seems like I can add either all the files (excluding testing, validating, and benchmarking files) or none. I can't just add a few. (This is using .o and .h files from the Crypto++ project.)


    Then I found this example (https://groups.google.com/forum/?fro...rs/QEkVYpNuj84). It's specifically for blowfish and uses a total of 5 includes from Crypto++:


    #include "crypto521/cryptlib.h"
    #include "crypto521/modes.h"
    #include "crypto521/blowfish.h"
    #include "crypto521/files.h"
    #include "crypto521/hex.h"


    I then tried adding a directory for Crypto++ within my project and copying over the .cpp and .h files listed above to that directory and using just those 5 includes. I didn't add any code to my program - just added the includes like shown above. I ran into the same thing. One include required more and more and more. I kept having problems with each header or .cpp file referencing symbols that it couldn't find or needing a .h file it couldn't find until I added the include statement. I had to add all the Crypto++ .h and .cpp files (again, excluding the testing, validating, and benchmarking files).


    So I've tried using .o files that are in another project and have been built. I've also tried using the source files and headers within my project. In both cases, I need to add more and more files.


    With all the .h and .cpp files from Crypto++ in the directory within my project, I always run into an error in salsa. I figure that is because I'm not making it with the Crypto++ makefile, so something is being left out.


    My goal, for now, is to be able to build my program using only what is needed for using blowfish from Crypto++. From there, I'm used to namespaces and objects and classes and there are many examples to figure out how to use blowfish.


    Is this an easy newbie problem because I just don't know the rules yet about building? If it's possible, I'd like to know what I need to be searching for or reading so I have a better understanding of how to work through things like this on my own.


    And, of course, any immediate help is also greatly appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I imported Crypto++ into Eclipse as a project with a makefile and it builds successfully on its own.
    What sort of directory structure did you get out of it?

    You should have something like
    /path/to/crypto521 which contains all the (public) header files for the library.

    You should also have say
    /path/to/lib/libcrypto++.a

    In the project which uses this library, you do the following things (these are concept ideas, I don't know the exact details for Eclipse)
    1. Compiler->pre-processor->additional search directories, specify /path/to
    On the g++ command line, this would be -I/path/to

    2. Linker->additional search directories, specify /path/to/lib
    On the g++ command line, this would be -L/path/to/lib

    3. Linker->additional libraries, specify crypto++ (in Unix tradition, lib prefix and .a suffix are automatically assumed)
    On the g++ command line, this would be -lcrypto++

    If you've been copying files from the crypto++ project hierarchy into your own project, you need to undo all that - it's the wrong way to go.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User TangoOversway's Avatar
    Join Date
    Mar 2013
    Posts
    20
    Thanks, Salem! Took me a while to step through that, since, when I was doing it, I wanted to make sure I knew what I was doing.

    I can't be sure, but it seems, in the Eclipse configuration, that I can't just specify a path to the lib files, but have to specify each file individually.

    In this case, part of the issue is that I'm linking to .o files and not .a files. Crypto++ is made up of around 100 (I think closer to 120) .o files when compiled. Fortunately I was able to use a one line bash script to give me a listing and cut and past them into the config file instead of adding each one by clicking through several steps.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I would just use the library libcryptopp.a and see if it works. Likely try cryptopp as the lib name.
    Tim S.
    Linux - Crypto++ Wiki

    Mac Stuff
    http://www.cryptopp.com/wiki/IOS
    Last edited by stahta01; 03-10-2013 at 03:22 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User TangoOversway's Avatar
    Join Date
    Mar 2013
    Posts
    20
    Quote Originally Posted by stahta01 View Post
    I would just use the library libcryptopp.a and see if it works. Likely try cryptopp as the lib name.
    Tim S.
    Linux - Crypto++ Wiki

    Mac Stuff
    IOS - Crypto++ Wiki
    Maybe I'm an idiot - or I could be just off for now as I get used to a new language - and C++ is rather challenging with all the syntax and pointer issues, but I must have missed something. Anyway, just to be sure, I rebuilt Crypto++ and it did include libcryptopp.a in the build. (I admit I could have missed it the first time.)

    So I'll be using that instead of the object files. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with a Crypto Library
    By mpre in forum C Programming
    Replies: 6
    Last Post: 02-07-2012, 06:09 PM
  2. Building my (biggest yet) project
    By Vespasian in forum C Programming
    Replies: 19
    Last Post: 10-12-2011, 03:18 AM
  3. building the project issue
    By beach king in forum Windows Programming
    Replies: 9
    Last Post: 01-01-2011, 09:18 AM
  4. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  5. MFC newbie --- simple problem
    By gemini_shooter in forum Windows Programming
    Replies: 3
    Last Post: 04-03-2006, 04:17 PM