2

I wrote a small program that uses the crypto++library using kdevelop in Ubuntu. I get the output correctly when I compile it from the terminal using -lcryptopp. I would like to build and execute the program using the cmake from kdevelop itself. How can I include the CRYPTOPP_DIR in the cmake configuration for doing this.

Any help will be appreciated. Thankyou.

jww
  • 97,681
  • 90
  • 411
  • 885
Jackzz
  • 1,417
  • 4
  • 24
  • 53
  • I don't know about `kdevelop` and `cmake`, but Crypto++ supplies a `GNUmakefile`. You can see what files it compiles when building `libcryptopp.a` by issuing `make static`. You can see what files it compiles when building `libcryptopp.so` by issuing `make dynamic`. And you can see what files it compiles when building the executable by issuing `make cryptest.exe`. – jww Jan 23 '15 at 22:50
  • Accordong to a tutorial I have executed `make static dynamic test` and then `cryptest.exe v`. Still building results in so many errors due to unknown `CRYPTOPP` library. – Jackzz Jan 24 '15 at 02:37

1 Answers1

2

Adding the following piece of code to cmake file helped me:

FIND_LIBRARY(CRYPTOPP crypto++ /usr/lib) ## location of libcryptopp.so or libcryptopp.a
IF ( CRYPTOPP )
TARGET_LINK_LIBRARIES(${PROGRAM_NAME} cryptopp ) ## Specifying cryptopp in uppercase gave me link error.
ENDIF( CRYPTOPP )

If pthread library is needed, also add it in the cmake file. This worked for me. Got the solution from https://forum.anope.org

Jackzz
  • 1,417
  • 4
  • 24
  • 53