eclipse / paho.mqtt.rust

paho.mqtt.rust
Other
517 stars 102 forks source link

Building on windows with msys and gnu toolchain fails #60

Open AidaPaul opened 4 years ago

AidaPaul commented 4 years ago

Sadly my attepts to get it up and running with gnu toolchain + msys on windows yielded no luck.

toolchain: stable-x86_64-pc-windows-gnu

cargo build:

cargo :    Compiling paho-mqtt-sys v0.2.1 (F:\Amazon Drive\Rust Projects\paho.mqtt.rust\paho-mqtt-sys)
At line:1 char:1
+ cargo build *>> straight.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (   Compiling pa...\paho-mqtt-sys):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

error
: failed to run custom build command for `paho-mqtt-sys v0.2.1 (F:\Amazon Drive\Rust Projects\paho.mqtt.rust\paho-mqtt-sys)`

Caused by:
  process didn't exit successfully: `F:\Amazon Drive\Rust Projects\paho.mqtt.rust\target\debug\build\paho-mqtt-sys-a66e7b96c7cd6b9b\build-script-build` (exit code: 101)
--- stdout
debug:Running the bundled build for Paho C
cargo:rerun-if-changed=build.rs
running: "cmake" "F:\\Amazon Drive\\Rust Projects\\paho.mqtt.rust\\paho-mqtt-sys\\paho.mqtt.c/" "-G" "MinGW Makefiles" "-DPAHO_BUILD_STATIC=on" "-DPAHO_ENABLE_TESTING=off" "-DPAHO_WITH_SSL=on" "-DCMAKE_INSTALL_PREFIX=F:\\Amazon Drive\\Rust 
Projects\\paho.mqtt.rust\\target\\debug\\build\\paho-mqtt-sys-a3caf73975c6fe62\\out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_BUILD_TYPE=Debug"
-- CMake version: 3.16.0
-- CMake system name: Windows
-- Timestamp is 2019-12-30T00:52:46Z
-- OpenSSL hints: C:/OpenSSL-Win64
-- OpenSSL headers found at C:/OpenSSL-Win64/include
-- OpenSSL library found at C:/OpenSSL-Win64/lib/libssl.lib
-- OpenSSL Crypto library found at C:/OpenSSL-Win64/lib/libcrypto.lib
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Amazon Drive/Rust Projects/paho.mqtt.rust/target/debug/build/paho-mqtt-sys-a3caf73975c6fe62/out/build
running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[ 51%] Built target common_obj
[ 66%] Built target common_ssl_obj
Scanning dependencies of target paho-mqtt3a
Scanning dependencies of target paho-mqtt3c
Scanning dependencies of target paho-mqtt3c-static
Scanning dependencies of target paho-mqtt3cs
Scanning dependencies of target paho-mqtt3as
Scanning dependencies of target paho-mqtt3a-static
Scanning dependencies of target paho-mqtt3cs-static
Scanning dependencies of target paho-mqtt3as-static
[ 72%] Building C object src/CMakeFiles/paho-mqtt3a.dir/MQTTAsync.c.obj
[ 74%] Building C object src/CMakeFiles/paho-mqtt3c-static.dir/MQTTClient.c.obj
[ 74%] Building C object src/CMakeFiles/paho-mqtt3c.dir/MQTTClient.c.obj
[ 74%] Building C object src/CMakeFiles/paho-mqtt3cs.dir/MQTTClient.c.obj
[ 75%] Building C object src/CMakeFiles/paho-mqtt3as.dir/MQTTAsync.c.obj
[ 75%] Building C object src/CMakeFiles/paho-mqtt3a-static.dir/MQTTAsync.c.obj
[ 78%] Building C object src/CMakeFiles/paho-mqtt3as-static.dir/MQTTAsync.c.obj
[ 78%] Building C object src/CMakeFiles/paho-mqtt3cs-static.dir/MQTTClient.c.obj
[ 80%] Linking C shared library libpaho-mqtt3c.dll
[ 81%] Linking C static library libpaho-mqtt3c-static.a
[ 83%] Linking C static library libpaho-mqtt3cs-static.a
[ 84%] Linking C shared library libpaho-mqtt3a.dll
[ 86%] Linking C shared library libpaho-mqtt3cs.dll
[ 87%] Linking C static library libpaho-mqtt3a-static.a
[ 89%] Linking C static library libpaho-mqtt3as-static.a
[ 90%] Linking C shared library libpaho-mqtt3as.dll
[ 90%] Built target paho-mqtt3c-static
[ 92%] Built target paho-mqtt3cs-static
[ 92%] Built target paho-mqtt3a-static
[ 93%] Built target paho-mqtt3as-static

--- stderr
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/
msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_UuidCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3c.dir\build.make:130: src/libpaho-mqtt3c.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:172: src/CMakeFiles/paho-mqtt3c.dir/all] Error 2
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_UuidCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3a.dir\build.make:130: src/libpaho-mqtt3a.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:226: src/CMakeFiles/paho-mqtt3a.dir/all] Error 2
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3cs.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3cs.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3cs.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3cs.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_Uui
dCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3cs.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3cs.dir\build.make:148: src/libpaho-mqtt3cs.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:280: src/CMakeFiles/paho-mqtt3cs.dir/all] Error 2
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3as.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3as.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3as.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3as.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_UuidCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3as.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3as.dir\build.make:148: src/libpaho-mqtt3as.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:361: src/CMakeFiles/paho-mqtt3as.dir/all] Error 2
mingw32-make.exe: *** [Makefile:151: all] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', C:\Users\pucie\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.42\src\lib.rs:861:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

And cargo build --no-default-features --features "bundled" for good measure:

cargo :    Compiling paho-mqtt-sys v0.2.1 (F:\Amazon Drive\Rust Projects\paho.mqtt.rust\paho-mqtt-sys)
At line:1 char:1
+ cargo build --no-default-features --features "bundled" *>> bundled.lo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (   Compiling pa...\paho-mqtt-sys):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

error
: failed to run custom build command for `paho-mqtt-sys v0.2.1 (F:\Amazon Drive\Rust Projects\paho.mqtt.rust\paho-mqtt-sys)`

Caused by:
  process didn't exit successfully: `F:\Amazon Drive\Rust Projects\paho.mqtt.rust\target\debug\build\paho-mqtt-sys-6f98144069b30247\build-script-build` (exit code: 101)
--- stdout
debug:Running the bundled build for Paho C
cargo:rerun-if-changed=build.rs
running: "cmake" "F:\\Amazon Drive\\Rust Projects\\paho.mqtt.rust\\paho-mqtt-sys\\paho.mqtt.c/" "-G" "MinGW Makefiles" "-DPAHO_BUILD_STATIC=on" "-DPAHO_ENABLE_TESTING=off" "-DPAHO_WITH_SSL=off" "-DCMAKE_INSTALL_PREFIX=F:\\Amazon Drive\\Rust 
Projects\\paho.mqtt.rust\\target\\debug\\build\\paho-mqtt-sys-1dbbcdc09b96172e\\out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_BUILD_TYPE=Debug"
-- CMake version: 3.16.0
-- CMake system name: Windows
-- Timestamp is 2019-12-30T00:52:27Z
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Amazon Drive/Rust Projects/paho.mqtt.rust/target/debug/build/paho-mqtt-sys-1dbbcdc09b96172e/out/build
running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[ 68%] Built target common_obj
Scanning dependencies of target paho-mqtt3c
Scanning dependencies of target paho-mqtt3c-static
Scanning dependencies of target paho-mqtt3a
Scanning dependencies of target paho-mqtt3a-static
[ 71%] Building C object src/CMakeFiles/paho-mqtt3c.dir/MQTTClient.c.obj
[ 75%] Building C object src/CMakeFiles/paho-mqtt3c-static.dir/MQTTClient.c.obj
[ 78%] Building C object src/CMakeFiles/paho-mqtt3a-static.dir/MQTTAsync.c.obj
[ 81%] Building C object src/CMakeFiles/paho-mqtt3a.dir/MQTTAsync.c.obj
[ 84%] Linking C shared library libpaho-mqtt3c.dll
[ 87%] Linking C static library libpaho-mqtt3c-static.a
[ 90%] Linking C shared library libpaho-mqtt3a.dll
[ 93%] Linking C static library libpaho-mqtt3a-static.a
[ 93%] Built target paho-mqtt3c-static
[ 93%] Built target paho-mqtt3a-static

--- stderr
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_UuidCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3c.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3c.dir\build.make:130: src/libpaho-mqtt3c.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:187: src/CMakeFiles/paho-mqtt3c.dir/all] Error 2
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-
mqtt3a.dir/objects.a(Base64.c.obj): in function `Base64_decode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:27: undefined reference to `__imp_CryptStringToBinaryA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(Base64.c.obj): in function `Base64_encode':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/Base64.c:36: undefined reference to `__imp_CryptBinaryToStringA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_buildFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:232: undefined reference to `htonll'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_connect':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:334: undefined reference to `__imp_UuidCreate'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\paho-mqtt3a.dir/objects.a(WebSocket.c.obj): in function `WebSocket_receiveFrame':
F:/Amazon Drive/Rust Projects/paho.mqtt.rust/paho-mqtt-sys/paho.mqtt.c/src/WebSocket.c:926: undefined reference to `ntohll'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [src\CMakeFiles\paho-mqtt3a.dir\build.make:130: src/libpaho-mqtt3a.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:214: src/CMakeFiles/paho-mqtt3a.dir/all] Error 2
mingw32-make.exe: *** [Makefile:151: all] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', C:\Users\pucie\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.42\src\lib.rs:861:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

This is separate from #45 as that issue tries to build with MSVC toolchain. Any help would be greatly appreciated!

rucoder commented 3 years ago

I managed to make it working with mingw64 from msys2. The main problem is that it is incorrect to make decisions only checking
#if (defined(_WIN32) || defined(_WIN64)) we also need to check #if defined (_MSC_VER) or defined(__MINGW32__) || defined(__MINGW64__). Also build.rs should check not only for target OS but also check the toolchain

fn find_link_lib<P>(install_path: P) -> Option<(PathBuf, &'static str)>
where
    P: AsRef<Path>,
{
    let install_path = install_path.as_ref();
    let lib_dirs = &["lib", "lib64"];

    let lib_base = link_lib_base();

    let lib_file = if cfg!(windows) {
        if cfg!(gnu) {
            format!("lib{}.a", lib_base)
        } else {
            format!("{}.lib", lib_base)
        }
    } else {
        format!("lib{}.a", lib_base)
    };