Closed michelson closed 3 years ago
Hello, it looks like you don't have /usr/bin/c++
? Which is expected to be present by your local CMake install (in /usr/local/Cellar/cmake
).
it seems it's installed , in terminal I do:
$> /usr/bin/c++
clang: error: no input files
Interesting...
What is the content of /Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel/CMakeFiles/CMakeError.log
? And also maybe CMakeOutput.log
?
Also on SO they mention some Xcode tricks that might solve the issue (I am not familiar with Mac OS X and Xcode sadly).
thanks @lerouxrgd , I think that solved the xcode issue, but now I've some openssl issues I think this is the error log: https://gist.github.com/michelson/e250c8f6d6cb70633315643533ba0569
If I check the directory of openssl ls /usr/local/opt/openssl/include/openssl
I can see the missing openssl/evp.h
also I've exported
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
Actually I think the correct workaround is documented here in the original libdatachannel
repository.
But I am not checking the env variable OPENSSL_ROOT_DIR
for now so I need to add this for it to work. I'll add it soon.
yeah, I've added this two lines on the build.rs
config.define( "OPENSSL_ROOT_DIR", "/usr/local/opt/openssl");
config.define( "OPENSSL_INCLUDE_DIR", "/usr/local/opt/openssl/lib");
thanks for the help
Cool, I'll add the code to handle that cleanly in build.rs soon then. Thanks for your investigations.
@lerouxrgd , sorry if the last comment was misleading., with the code above (defining the vars) it fails with the errors I've sent earlier
Oh sad ...
Just to be sure, the complete file path is /usr/local/opt/openssl/include/openssl/evp.h
?
Besides, out of curiosity does cargo build --features static
works ? I think it should as it will skip libsrtp
and build and bundle openssl from scratch. This is not the solution to the problem but I'd be curious to check whether this works or not on Mac OS.
it does not work:
➜ datachannel-rs git:(master) ✗ cargo build --features static
Compiling datachannel-sys v0.10.4 (/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys)
error: failed to run custom build command for `datachannel-sys v0.10.4 (/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys)`
Caused by:
process didn't exit successfully: `/Users/michelson/Documents/rust/datachannel-rs/target/debug/build/datachannel-sys-5a57f80a8663ac04/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel" "-DNO_WEBSOCKET=ON" "-DNO_EXAMPLES=ON" "-DNO_MEDIA=ON" "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" "-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/lib" "-DCMAKE_INSTALL_PREFIX=/Users/michelson/Documents/rust/datachannel-rs/target/debug/build/datachannel-sys-09f51823d3f372ed/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
-- have_sa_len
-- have_sin_len
-- have_sin6_len
-- HAVE_SCONN_LEN
-- Compiler flags (CMAKE_C_FLAGS): -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -std=c99 -pedantic -Wall -Wextra -Wfloat-equal -Wshadow -Wpointer-arith -Wunreachable-code -Winit-self -Wno-unused-function -Wno-unused-parameter -Wno-unreachable-code -Wstrict-prototypes -Werror
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel
running: "cmake" "--build" "." "--target" "datachannel-static" "--config" "Debug" "--"
--- stderr
CMake Deprecation Warning at deps/plog/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Error: could not load cache
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1
build script failed, must exit now', /Users/michelson/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It could be because of a mix with previous non static build maybe, what if you run a cargo clean
beforehand ?
it fails too 😭
... -- Build files have been written to: /Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel ...
Maybe some files must be cleaned up there too (and cargo clean
doesn't do it as it's not directly under its target).
Anyway this was just out of curiosity.
Maybe you can try to add config.define("NO_MEDIA", "ON");
even when the build is not static, this should skip libsrtp
which is not used anyway.
Also, do you manage to build libdatachannel
with CMake as per its build instruction ?
It can help narrow down the issue (Mac OS build config, or CMake usage from Rust)
Hi @lerouxrgd
the cloned libdatachannel is compiling ok , here is the log:
➜ libdatachannel git:(abec5fc) ✗ cmake -B "$BUILD_DIR" -DUSE_GNUTLS=0 -DUSE_NICE=0 -G Xcode
CMake Deprecation Warning at deps/plog/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- have_sa_len
-- have_sin_len
-- have_sin6_len
-- HAVE_SCONN_LEN
-- Compiler flags (CMAKE_C_FLAGS): -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -std=c99 -pedantic -Wall -Wextra -Wfloat-equal -Wshadow -Wpointer-arith -Wunreachable-code -Winit-self -Wno-unused-function -Wno-unused-parameter -Wno-unreachable-code -Wstrict-prototypes -Werror
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel
➜ libdatachannel git:(abec5fc) ✗
This just prepares the build files. Also I don't think that you need -G Xcode
as you are just compiling the sources and not using it through an Xcode project here.
Then, you still need to:
cd $BUILD_DIR
make -j2
when I do the cd $BUILD_DIR
the make -j2
does not work
➜ libdatachannel git:(abec5fc) ✗ cd build2
➜ build2 git:(abec5fc) ✗ make -j2
make: *** No targets specified and no makefile found. Stop.
if I do the make -j2
on the root folder, then it compiles, but with errors
error: unknown warning option '-Werror=format-truncation' [-Werror,-Wunknown-warning-option]error:
unknown warning option '-Werror=format-truncation' [-Werror,-Wunknown-warning-option]
make[2]: *** [libusrsctp_la-user_environment.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [libusrsctp_la-user_mbuf.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [libusrsctp.a] Error 2
I've tried both, with and without -G Xcode
Running make
at the root will use the regular Makefile
(which is not the one generated by CMake
) and will work only for Linux (as stated in the README.md).
In your case, from the root of libdatachannel
you should do:
rm -rf build
cmake -B build -DUSE_GNUTLS=0 -DUSE_NICE=0
cd build
make -j2
Hi @lerouxrgd , thanks for the help.
I did the steps you said, but I got the following on : [ 76%] Linking CXX shared library libdatachannel.dylib
ld: cannot link directly with dylib/framework, your binary is not an allowed client of /usr/lib/libcrypto.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libdatachannel.0.10.4.dylib] Error 1
make[1]: *** [CMakeFiles/datachannel.dir/all] Error 2
make: *** [all] Error 2
the entire log is at: https://gist.github.com/michelson/097b176bfd2fe360a8afcfb6dd5d21d7
It looks like it tries to link against /usr/lib/libcrypto.dylib
(which is required by OpenSSL).
And it seems that Apple is not allowing you to link against your system's libcrypto... More details here.
Is your OpenSSL install in /usr/local/Cellar/openssl\@1.1/1.1.1/
? Do you see a libcrypto.dylib
somewhere there ?
Actually looking at the libdatachannel
CI for Mac OS, it looks like these two variables are required:
OPENSSL_ROOT_DIR: /usr/local/opt/openssl
OPENSSL_LIBRARIES: /usr/local/opt/openssl/lib
So maybe you can try:
cmake -B build \
-DUSE_GNUTLS=0 -DUSE_NICE=0 \
-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl\@1.1/1.1.1/ \
-DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl\@1.1/1.1.1/lib
Hi @lerouxrgd
the compilation works! ,
cmake -B build \
-DUSE_GNUTLS=0 -DUSE_NICE=0 \
-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl\@1.1/1.1.1i/ \
-DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl\@1.1/1.1.1i/lib \
-WARNINGS_AS_ERRORS=1 -DENABLE_LOCAL_ADDRESS_TRANSLATION=1
now, trying the setup on the rust side, after a cargo clean
, I got:
Compiling datachannel-sys v0.10.4 (/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys)
error: failed to run custom build command for `datachannel-sys v0.10.4 (/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys)`
Caused by:
process didn't exit successfully: `/Users/michelson/Documents/rust/datachannel-rs/target/debug/build/datachannel-sys-5a57f80a8663ac04/build-script-build` (exit code: 101)
--- stdout
running: "cmake" "/Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel" "-DNO_WEBSOCKET=ON" "-DNO_EXAMPLES=ON" "-DNO_MEDIA=ON" "-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl@1.1/1.1.1i" "-DOPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl@1.1/1.1.1i/lib" "-DCMAKE_INSTALL_PREFIX=/Users/michelson/Documents/rust/datachannel-rs/target/debug/build/datachannel-sys-09f51823d3f372ed/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
-- have_sa_len
-- have_sin_len
-- have_sin6_len
-- HAVE_SCONN_LEN
-- Compiler flags (CMAKE_C_FLAGS): -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -std=c99 -pedantic -Wall -Wextra -Wfloat-equal -Wshadow -Wpointer-arith -Wunreachable-code -Winit-self -Wno-unused-function -Wno-unused-parameter -Wno-unreachable-code -Wstrict-prototypes -Werror
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/michelson/Documents/rust/datachannel-rs/datachannel-sys/libdatachannel
running: "cmake" "--build" "." "--target" "datachannel-static" "--config" "Debug" "--"
--- stderr
CMake Deprecation Warning at deps/plog/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Error: could not load cache
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1
build script failed, must exit now', /Users/michelson/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Cool, making progress !
So what you have to add to build.rs
to test quickly is:
config.define("OPENSSL_ROOT_DIR", "/usr/local/Cellar/openssl@1.1/1.1.1i");
config.define("OPENSSL_LIBRARIES", "/usr/local/Cellar/openssl@1.1/1.1.1i/lib");
Was this parameter -DENABLE_LOCAL_ADDRESS_TRANSLATION=1
necessary ?
If it was, then you also need to add:
config.define("ENABLE_LOCAL_ADDRESS_TRANSLATION", "1");
As for the Error: could not load cache
I think the best is to just delete the repo you cloned and try again from a fresh install instead, that will be simpler.
After a fresh cloning don't forget to run git submodule update --init
.
The parameter ENABLE_LOCAL_ADDRESS_TRANSLATION=1
is just a mitigation to help connecting locally when running tests on the CI, because for some obscure reason the program can't connect to itself using the LAN address. It shouldn't be necessary here.
yay! after the fresh install and with the vars on static, it does compile!
for further reference:
config.define("OPENSSL_ROOT_DIR", "/usr/local/Cellar/openssl@1.1/1.1.1i/");
config.define("OPENSSL_LIBRARIES", "/usr/local/Cellar/openssl@1.1/1.1.1i/lib");
config.define( "WARNINGS_AS_ERRORS", "1");
config.define( "DENABLE_LOCAL_ADDRESS_TRANSLATION", "1");
I guess the following vars are not strictly required
config.define( "WARNINGS_AS_ERRORS", "1");
config.define( "DENABLE_LOCAL_ADDRESS_TRANSLATION", "1");
Yes they are not required here.
So I will add support for OPENSSL_ROOT_DIR
and OPENSSL_LIBRARIES
env variable so that compilation on Mac OS can be clean.
Can you retry with a fresh clone and build as follows:
export OPENSSL_ROOT_DIR=/usr/local/Cellar/openssl@1.1/1.1.1i/
export OPENSSL_LIBRARIES=/usr/local/Cellar/openssl@1.1/1.1.1i/lib
cargo build
hi @lerouxrgd , it compiles perfect on a fresh clone with those exports 👍
This has been released in 0.3.0
Hello , I just want to give this a try, but I got some issues on compilation on my mac. https://gist.github.com/michelson/e96f3ca308914998906ace2cc5211a2c