相关文章推荐
大气的梨子  ·  .NET ...·  1 月前    · 
有爱心的回锅肉  ·  一句话 | ...·  7 月前    · 
朝气蓬勃的李子  ·  java - Caused by: ...·  1 年前    · 
欢乐的甜瓜  ·  Control of oxidative ...·  1 年前    · 

如何交叉编译一个带有OpenSSL头文件的C++项目,用于windows x64系统

0 人关注

This is the beginning of the code.

#ifndef __DECENT_MC_NET_IO__
#define __DECENT_MC_NET_IO__
#include <iostream>
#include <string>
#include <cstdio>
#include <unistd.h>
#include <string.h>
#include <memory>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <thread>
#include <chrono>

我正试图用这个命令进行编译。

x86_64-w64-mingw32-g++  main.cpp -o bin/main.exe -std=c++20  -pthread -static-libgcc -static-libstdc++ -lcrypto -lssl

Output:

x86_64-w64-mingw32-g++  main.cpp -o bin/main.exe -std=c++20  -pthread -static-libgcc -static-libstdc++ -lcrypto -lssl
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lcrypto: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lssl: No such file or directory
collect2: error: ld returned 1 exit status

没有这些旗帜。

/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x4ae): undefined reference to `EC_GROUP_new_by_curve_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x4bc): undefined reference to `EC_KEY_new_by_curve_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x4f8): undefined reference to `EC_KEY_generate_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x507): undefined reference to `EC_KEY_get0_private_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x51e): undefined reference to `BN_bn2bin'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x52a): undefined reference to `EC_KEY_get0_public_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x55c): undefined reference to `EC_POINT_point2oct'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x5fb): undefined reference to `EC_POINT_point2oct'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x6ea): undefined reference to `EC_KEY_new_by_curve_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x6f8): undefined reference to `EC_GROUP_new_by_curve_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x708): undefined reference to `EC_POINT_new'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x736): undefined reference to `BN_bin2bn'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x771): undefined reference to `EC_POINT_oct2point'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x781): undefined reference to `EC_KEY_set_private_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x791): undefined reference to `EC_KEY_set_public_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x796): undefined reference to `EVP_PKEY_new'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x7b2): undefined reference to `EVP_PKEY_assign'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x878): undefined reference to `PEM_write_PrivateKey'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x8cd): undefined reference to `EVP_PKEY_new'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x909): undefined reference to `PEM_read_PrivateKey'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x92c): undefined reference to `EVP_PKEY_new'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x96a): undefined reference to `EC_KEY_new_by_curve_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x97a): undefined reference to `EC_KEY_generate_key'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x992): undefined reference to `EVP_PKEY_assign'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x9c9): undefined reference to `EVP_PKEY_free'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0x9eb): undefined reference to `X509_new'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa2e): undefined reference to `X509_get_serialNumber'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa3b): undefined reference to `ASN1_INTEGER_set'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa47): undefined reference to `X509_getm_notBefore'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa54): undefined reference to `X509_gmtime_adj'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa60): undefined reference to `X509_getm_notAfter'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa6d): undefined reference to `X509_gmtime_adj'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa7d): undefined reference to `X509_set_pubkey'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xa89): undefined reference to `X509_get_subject_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xac5): undefined reference to `X509_NAME_add_entry_by_txt'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xafd): undefined reference to `X509_NAME_add_entry_by_txt'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xb35): undefined reference to `X509_NAME_add_entry_by_txt'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xb45): undefined reference to `X509_set_issuer_name'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xb4a): undefined reference to `EVP_sha1'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xb60): undefined reference to `X509_sign'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xb97): undefined reference to `X509_free'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xc38): undefined reference to `PEM_write_PrivateKey'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xcda): undefined reference to `PEM_write_X509'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccLRRXO7.o:main.cpp:(.text+0xdbd): undefined reference to `EVP_PKEY_free'