my goal ist to create an environment for cross-compiling static libssh-projects.
• cross-compilation: host: linux (ubuntu), target: windows 64bit, architectur x86
• static: no dynamic libraries needed during runtime nor compilationtime
• libssh1, no libssh2: I do need server support too.
To reach my goal I spent days (two weeks now) for theory and praxis, but I couldn’t get there. Before I list what I did so far, my questions:
Could u tell me, what I did wrong and what I need to do/change and of course why?
Could u write a (quick) mini HOW-TO for this purpose with all third library dependencies (libz, libssl form what I know) with standard directory configurations
What I did so far: Latest I set up a new VM with Ubuntu (untouched system). Then:
sudo apt-get install mingw-64
sudo apt-get install cmake
So mingw is located in /usr/bin /usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/lib
Dowloading tarballs for zlib, openssl and libssh and taring them in /home/affenarsch/Downloads then cd to zlib and:
sed -e s/"PREFIX ="/"PREFIX = x86_64-w64-mingw32-"/ -i win64/Makefile.gcc
SSl is located in /usr/local/ssl
Finally I created a directory for the libssh-build /home/affenarsch/Download/build and created a toolchainfile for cmake /home/affenarsch/Download/file.cmake with following content:
libssh is located in /usr/local/local/lib and /usr/local/include (in directory libssh: /usr/local/include/libssh actually ).
And i did the build once (no „old wood“ from builds before).
compiler/libtest:
set up sample code in main.c of my home-directory and tried to gcc:
It found all libs I try to link, but I got „undefined references“- errors. nm’ing libssh.a is showing undefined symbols for used functions like new_ssh()?!
I tried and read so much! Please help. What else do u need for problem solving? Or: Just some How-to cmdlines do it the right way?- And I diff the solution to my wrong way, to get the problem/mistake.
I am totally ok with an solution leaning on mxe.
Thank you very much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi yall,
my goal ist to create an environment for cross-compiling static libssh-projects.
• cross-compilation: host: linux (ubuntu), target: windows 64bit, architectur x86
• static: no dynamic libraries needed during runtime nor compilationtime
• libssh1, no libssh2: I do need server support too.
To reach my goal I spent days (two weeks now) for theory and praxis, but I couldn’t get there. Before I list what I did so far, my questions:
What I did so far: Latest I set up a new VM with Ubuntu (untouched system). Then:
sudo apt-get install mingw-64
sudo apt-get install cmake
So mingw is located in /usr/bin /usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/lib
Dowloading tarballs for zlib, openssl and libssh and taring them in /home/affenarsch/Downloads then cd to zlib and:
sed -e s/"PREFIX ="/"PREFIX = x86_64-w64-mingw32-"/ -i win64/Makefile.gcc
make -f win64/Makefile.gcc
#sudo BINARY_PATH=/usr/bin \
INCLUDE_PATH=/usr/x86_64-w64-mingw32/include \
LIBRARY_PATH=/ usr/x86_64-w64-mingw32/lib \
make -f win64/Makefile.gcc install
make install
zlib is in /usr/local/x86_64-w64-mingw32/include and /usr/local/x86_64-w64-mingw32/lib
in directory of openssl:
./Configure --cross-compile-prefix=x86_64-w64-mingw32- mingw64
make
make install
SSl is located in /usr/local/ssl
Finally I created a directory for the libssh-build /home/affenarsch/Download/build and created a toolchainfile for cmake /home/affenarsch/Download/file.cmake with following content:
set(CMAKE_SYSTEM_NAME Windows)
set(COMPILER_PREFIX "x86_64-w64-mingw32")
set(CMAKE_C_COMPILER /usr/bin/${COMPILER_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/${COMPILER_PREFIX}-g++)
set(CMAKE_RC_COMPILER /usr/bin/${COMPILER_PREFIX}-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/local/ssl /usr/local//${COMPILER_PREFIX})
Did some changes to the DefineOptions.cmake file of libssh:
option(WITH_GSSAPI "Build with GSSAPI support" ON)
option(WITH_ZLIB "Build with ZLIB support" ON)
option(WITH_SSH1 "Build with SSH1 support" ON)
option(WITH_SFTP "Build with SFTP support" ON)
option(WITH_SERVER "Build with SSH server support" ON)
option(WITH_STATIC_LIB "Build with a static library" ON)
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
option(WITH_PCAP "Compile with Pcap generation support" ON)
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
option(WITH_TESTING "Build with unit tests" OFF)
option(WITH_CLIENT_TESTING "Build with client tests; requires a running sshd" OFF)
option(WITH_BENCHMARKS "Build benchmarks tools" OFF)
option(WITH_EXAMPLES "Build examples" ON)
option(WITH_NACL "Build with libnacl (curve25519" ON)
if (WITH_ZLIB)
set(WITH_LIBZ ON)
else (WITH_ZLIB)
set(WITH_LIBZ OFF)
endif (WITH_ZLIB)
if(WITH_BENCHMARKS)
set(WITH_TESTING ON)
endif(WITH_BENCHMARKS)
if (WITH_TESTING)
set(WITH_STATIC_LIB ON)
endif (WITH_TESTING)
if (WITH_NACL)
set(WITH_NACL ON)
endif (WITH_NACL)
then, from /home/affenarsch/Downloads/build :
cmake /home/affenarsch/Downloads/libssh-0.7.2 -DCMAKE_TOOLCHAIN_FILE=/home/affenarsch/Downloads/file.cmake
make
sudo make install
libssh is located in /usr/local/local/lib and /usr/local/include (in directory libssh: /usr/local/include/libssh actually ).
And i did the build once (no „old wood“ from builds before).
compiler/libtest:
set up sample code in main.c of my home-directory and tried to gcc:
/usr/bin/x86_64-w64-mingw32-gcc -static main.c -I/usr/local/include -I/usr/local/x86_64-w64-mingw32/include -I/usr/x86_64-w64-mingw32/include -L/usr/local/lib -L/usr/local/x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/lib -lssh -lssl -lcrypto -lws2_32 -lz
It found all libs I try to link, but I got „undefined references“- errors. nm’ing libssh.a is showing undefined symbols for used functions like new_ssh()?!
I tried and read so much! Please help. What else do u need for problem solving? Or: Just some How-to cmdlines do it the right way?- And I diff the solution to my wrong way, to get the problem/mistake.
I am totally ok with an solution leaning on mxe.
Thank you very much.