0

我有这 3 个命令来编译我的程序:

  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 "加密" AESBest.o main.o -lcryptopp -lpthread

考虑到这 3 个命令,如何创建生成文件?

在 Eclipse 中,我从 shell 中的程序接收输出,但在我的 bash 中,当我编译名为“Crypto”的 bin 文件并启动它时,我的 bash shell 中没有输出。为什么?

4

1 回答 1

2

这将起作用:

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

你可以像这样分解它:

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

然后像这样简化:

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
于 2011-11-03T23:45:24.950 回答