You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux命令行下使用g++编译Crypto++ 5.6.5时遇构建问题

Fixing Crypto++ Undefined Reference Linker Error

Hey Sarah, that undefined reference error is a classic linker issue—let's walk through the fixes step by step:

1. Fix Path Spelling Mistakes

First, I notice typos in your compile command that are throwing off the compiler/linker:

  • You wrote -I/home/thirdParty and -L/home/thirParty, but your actual Crypto++ path is /home/thirdparty/cryptopp (note the lowercase thirdparty and missing d in thirParty).
  • The include path should point directly to the Crypto++ directory where header files live, and the library path should target where compiled libcryptopp.a or libcryptopp.so files are stored (usually the same directory if you built the library in-place).

2. Add the Crypto++ Linker Flag

The linker is complaining because you haven't told it to link against the Crypto++ library. You need to add -lcryptopp to your command—this flag tells the linker to look for the Crypto++ library file in the path you specified with -L.

Corrected Compile Command

Here's the fixed command that addresses both issues:

g++ -I/home/thirdparty/cryptopp channelSwitch.cpp -L/home/thirdparty/cryptopp -lcryptopp -o test-cs.exe

Extra Checks If It Still Fails

  • Make sure you've compiled the Crypto++ library first—you can't link against it if you only downloaded the source. Run make in /home/thirdparty/cryptopp to build the library files.
  • If you're using a dynamic build of Crypto++, you might need to set the LD_LIBRARY_PATH environment variable to include your Crypto++ directory so the runtime can find the shared library:
    export LD_LIBRARY_PATH=/home/thirdparty/cryptopp:$LD_LIBRARY_PATH
    

内容的提问来源于stack exchange,提问作者Sarah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:37:00