【问题标题】:Getting a Botan library test program to compile under Windows 7 (MinGW, Code::Blocks)在 Windows 7 下编译 Botan 库测试程序(MinGW,Code::Blocks)
【发布时间】:2014-01-26 06:46:13
【问题描述】:

我一直试图编译这个测试程序,但没有成功

   #include <botan/botan.h>


   int main()
   {
       Botan::LibraryInitializer init;
   }

我已经从网站下载了库源。我运行了configure.py,它运行良好。 然后我尝试运行 MinGW-make

这是我得到的错误

c:\Botan-1.11.7>mingw32-make
g++  -m64 -pthread -fPIC -fvisibility=hidden -std=c++11 -D_REENTRANT -fstack-pro
tector -O3 -momit-leaf-frame-pointer -Wall -Wextra -Wstrict-aliasing -Wstrict-ov
erflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wold-s
tyle-cast -Wzero-as-null-pointer-constant -Ibuild\include -c C:\Botan-1.11.7\src
\lib\algo_base\scan_name.cpp -o build\obj\lib\src_lib_algo_base_scan_name.obj
C:\Botan-1.11.7\src\lib\algo_base\scan_name.cpp:1:0: warning: -fPIC ignored for
target (all code is position independent) [enabled by default]
C:\Botan-1.11.7\src\lib\algo_base\scan_name.cpp:1:0: sorry, unimplemented: 64-bi
t mode not compiled in
mingw32-make: *** [build\obj\lib\src_lib_algo_base_scan_name.obj] Error 1

我搜索了 Google 和任何我能找到的可用论坛。我在他们网站的隐藏文件夹中找到了 Windows 的预建库。但是,该软件包包含 lib 和 dll 文件,而不是 MinGW 需要的 .a 文件。我尝试使用创建 .a 文件的程序 LIB2A。我已将此文件添加到我的 code::blocks 链接器选项中。我还包括了包含文件夹。

当我尝试编译时出现此错误。

C:\botan\include\botan\init.h|41|undefined reference to `_imp___ZN5Botan18LibraryInitializer10initializeERKSs'|

它似乎看不到带有函数定义的库,但我不知道从哪里开始。

【问题讨论】:

    标签: c++ codeblocks mingw32 botan


    【解决方案1】:

    mingw32-make 设置了 -m64 标志,这意味着它正在尝试构建一个 64 位库。要构建 64 位库,您需要获取 MinGW-w64。

    当您运行 configure.py 时,它可能会设置您的 MakeFile 以构建 64 位库。您需要检查其输出中设置了哪些选项。这包括构建 32 位或 64 位的选项。无论哪种方式,您都需要一些变体:python configure.py --os=mingw --cc=gcc

    这个问题有一个类似的错误,建议使用MinGW-w64,它可以让你构建一个64位的库:Building 64 bit dll with MinGW 32 bit in Eclipse

    为了在命令行下使用 mingw32-make 进行构建,您还需要将 MinGW-w64 bin 目录添加到您的 Windows 路径中,并可能从您的路径中删除 Code::Blocks 打包的 MinGW 以避免冲突.您仍将使用 mingw32-make 使用 MinGW-w64 构建库;即使它被命名为 mingw32-make,它也会构建 64 位。

    如果您决定构建 64 位库,则还需要构建 64 位应用程序,因此您需要为 Code::Blocks 设置 MinGW-w64。要在 Code::Blocks 中设置 MinGW-w64,请参阅此问题:Setting up MingW and Code::Blocks in Windows 8 64 bit

    【讨论】:

      最近更新 更多