0
votes

I have these 3 commands that compile my program:

  1. g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest.cpp"
  2. g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"
  3. g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

How is possible to create a makefile considering these 3 commands?

In Eclipse I receive output from the program in the shell, but in my bash, when I compile the bin file called "Crypto" and launch it, I have no output in my bash shell. Why?

1
Consider moving your last two lines to a separate question with more comments and explanations.Andrejs Cainikovs

1 Answers

2
votes

This will work:

all:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest.cpp"
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"
  g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

And you can break it down a little like this:

AESBest.o:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"AESBest.d" -MT"AESBest.d" -o "AESBest.o" "AESBest.cpp"

main.o:
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"

Crypto:
  g++ -L/usr/include/cryptopp -o "Crypto" AESBest.o main.o -lcryptopp -lpthread

And then simplify like this:

AESBest.o main.o: %.o : %.cpp
  g++ -I/usr/include/cryptopp -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF$*.d -MT$*.d -o $@ $<

Crypto: AESBest.o main.o
  g++ -L/usr/include/cryptopp -o $@ $^ -lcryptopp -lpthread