Question

I have a small project to create in a course at my University that requires using the Crypto++ libraries. The requirement is that we don't include the whole source code/binary files of Crypto++ but link it from an outside directory. (E.g. C:\cryptopp). This is because the reviewer will link his/her own directory to asses my code.

Now, I am really bad at creating Makefiles and don't understand the content of them completely.

I am using MinGW on Windows 7.

So my main question would be, what do I need to write in the Makefile to use Crypto++ in my project from an outside folder?

Was it helpful?

Solution

Suppose you have the following makefile:

unit.exe: unit.o
  g++ unit.o -o unit.exe

unit.o: unit.cc unit.h
  g++ -c unit.cc -o unit.o

In order to modify it to use an external library you have to use the GCC -I and -L options:

unit.exe: unit.o
  g++ unit.o -o unit.exe -L /c/cryptopp -l ws2_32 -l cryptopp

unit.o: unit.cc unit.h
  g++ -I /c/cryptopp -c unit.cc -o unit.o

Often a makefile would contain a variable that is passed to the compiler and a variable that is passed to the linker, for example CFLAGS and LDFLAGS. If that is the case, then it might be easier to add the "-I" and "L" options to the compiler and linker variables.

See also here for a way to comiple CryptoPP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top