2017-06-22 10 views
0

私はC++でいくつかのプロジェクトを完了しましたが、Windows XP以降でコンパイルする必要があります。C++プロジェクトをopensslスタティックライブラリにリンクできません

これは私のRsaEncryptorクラスのヘッダーファイルです(これはソースが投稿されても問題ありません。なぜなら、これはうまくいきますが、それが必要な場合は私がやることができるからです)

私はマシン上でC++開発のためにEclipse Neonの最新バージョンを使用します。

はまた、私は thisを読んだ:

(...) you will need to configure with no-async when building OpenSSL 1.1.0 and above for Windows XP or Vista

そして私はfollowing指示によって導かれました。

私は何をしました:

  1. Windows 10 x64の下で仮想ボックス内Ubuntu 17.04 x64をインストールします。

  2. mxeとすべての要件をインストールします(ただし、それをコンパイルし、私はmingw32を使用することを決定することはできません)Ubuntu

  3. からOpenSSLライブラリのダウンロード最新版は

  4. [email protected]:/home/user# apt-get install gcc-mingw-w64-i686

  5. 経由 mingw32をインストール
  6. アンパックOpenSSLライブラリ/home/user/openssl-x32

  7. ./Configure mingw --cross-compile-prefix=i686-w64-mingw32 --prefix=/home/user/builds/openssl-x32-static no-shared no-async

  8. 実行make

  9. 実行make install

  10. コピーlibssl.a/home/user/builds/openssl-x32-static/libからlibcrypto.aマシン(Windows 10 x64)をホストするためには、フォルダに/home/user/openssl-x32

  11. 実行に行くE:\MyProjects\my-app\libraries\

  12. フォルダ内の
  13. マシンをホストするUbuntuから

    コピーincludeディレクトリE:\MyProjects\my-app\include

  14. 私は私のプロジェクトをビルドすると、次しまった、そして、構成

  15. をコンパイラにincludeフォルダを追加するリンカー構成に

  16. librariesフォルダを追加します。答え:

11:58:09 **** Rebuild of configuration Debug for project app **** Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway. Info: Internal Builder is used for build g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o RsaEncryptor.o "..\RsaEncryptor.cpp" g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o main.o "..\main.cpp" In file included from ..\main.cpp:5:0: ..\FilesFinder.h: In member function 'void FilesFinder::FindRecursively(const string&, const FilesFilter&)': ..\FilesFinder.h:90:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while (destinationContainer.GetElementsCount() >= MAX_ELEMENTS_COUNT) { ^g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o aes256.o "..\aes256.cpp" g++ "-LC:\MyProjects\my-app\libraries" -static-libgcc -static-libstdc++ -static -lpthread -m32 -o C:/MyProjects/my-app/bin/Debug/app RsaEncryptor.o aes256.o main.o -lssl -lcrypto -lgdi32 C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xaa): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xe0): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x242): undefined reference to gai_strerrorW' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x820): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xb5d): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xba2): undefined reference to gai_strerrorW' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xd7): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xe8): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2c7): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2d8): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x3b1): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x40c): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x423): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x43c): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x48b): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x4a2): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x52c): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x54d): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x563): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6b7): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6c8): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x942): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x9dc): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa15): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa32): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xaa6): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xb22): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x27): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4e): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x120): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x15b): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x1f5): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x206): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x265): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x2c6): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x377): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x38f): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4a7): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4b4): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x53a): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x55f): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5a5): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5b6): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x63a): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x64b): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x6b2): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x713): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7a6): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7e7): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x84b): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x86c): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1b1): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1d0): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x20a): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x272): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x299): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x2ca): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x33d): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x360): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x39a): undefined reference to [email protected]' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x457): undefined reference to [email protected]' c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o): bad reloc address 0x24 in section .rdata' c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status

11:58:21 Build Finished (took 11s.567ms)

完成したC++プロジェクトを、正しくコンパイルした(フラグno-async)OpenSSLライブラリとリンクするだけで、古いバージョンのWindowsで動作させることができます。

私はこの問題に関して何か助けを得ることができます。

+0

あなたはC *と* C++をタグ付けしました。彼らは異なる言語です。答えが必要な言語にのみタグを付ける必要があります。あなたの質問で行く私はあなたが今度はあなたのためのCのタグを削除したので、C + +の答えが必要と仮定しています。 – Toby

答えて

1

ほとんどの場合、エラーログの未定義シンボルのすべてがWinsockからのものではない場合。 -lws2_32とリンクしてみてください。

+0

はい、そうでした:フラグ-lssl -lcrypto -lcrypt32 -lgdi32 -lws2_32とリンクすると、正常にリンクしました!しかし、私は再び(Windows XPの下で)私のアプリケーションをテストし、それはまだ動作しません... :( –