[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building library for Windows


Lunch in November?  Where are you located?  Talk on Skype 'clanmills' if you want to keep that private!

Robin
http://clanmills.com
Not sent from my iPhone

> On 5 Oct 2016, at 04:47, Servesh Singh <ssingh@xxxxxxxxxxxx> wrote:
> 
> Thanks Robin/Tilo.
> Installation of QT fixed all the problems and now I have libssh libraries ready for windows.
> 
> Regards,
> Servesh
> 
> 
> From: Robin Mills [mailto:robinwmills@xxxxxxxxx] On Behalf Of Robin Mills
> Sent: 01 October 2016 01:29
> To: libssh@xxxxxxxxxx
> Subject: Re: Building library for Windows
> 
> Serv:
> 
> This is the last email about this.  It’s 9pm on Friday.  It’s been a tough week.
> 
> getaddrinfo is part of the socket API.  It’s implemented in winsock on Windows.  https://msdn.microsoft.com/en-gb/library/windows/desktop/ms738520(v=vs.85).aspx
> 
> I think you’ll have to install a Windows SDK to have the necessary include files to reveal that API.
> 
> The quickest way to do that is probably to install the Qt 5.6 open source delivery.  It’s a big blob on stuff and includes GCC 4.9.2, parts of the MS Platform SDK and all sorts of other mysterious stuff.  If you go down that road, I can easily help you because we’re running the same tools.
> 
> I’ve just updated the Exiv2 build notes to explain how I set up everything.  svn://dev.exiv2.org/svn/trunk/README-CMAKE
> 
> A couple of other suggestions:
> 1) I think it’s very important to use CMAKE_C_COMPILER on the cmake command.
> 2) use $ make VERBOSE=1 to see the commands that are being executed by make
> 
> A good night’s sleep helps a lot.  You’ll fix this tomorrow.
> 
> Where are you in India?  Alison are having a trip to India in November.  Lunch?
> 
> Robin
> http://clanmills.com
> 
> On 30 Sep 2016, at 19:43, Servesh Singh <ssingh@xxxxxxxxxxxx> wrote:
> 
> Hi Robin,
> Thanks for all your help. I am sure I will be able to build it soon.
> You were correct  for Cmake. I did compile it from source code for MinGW and it passed without any problem.
> Now cmake is generating correct files i.e. SHELL is sh.exe and not cmd.exe.
> Libssh also got configured and generated. 
> Now I am getting problem with 'make':
> 
> I have not enabled static library building yet. Trying shared first. 
> 
> ssingh@IN-SSingh-LT /home/libssh-0.7.3/build
> $ make
> Scanning dependencies of target ssh_shared
> [  1%] Building C object src/CMakeFiles/ssh_shared.dir/agent.c.obj
> [  2%] Building C object src/CMakeFiles/ssh_shared.dir/auth.c.obj
> [  4%] Building C object src/CMakeFiles/ssh_shared.dir/base64.c.obj
> [  5%] Building C object src/CMakeFiles/ssh_shared.dir/bignum.c.obj
> [  7%] Building C object src/CMakeFiles/ssh_shared.dir/buffer.c.obj
> [  8%] Building C object src/CMakeFiles/ssh_shared.dir/callbacks.c.obj
> [ 10%] Building C object src/CMakeFiles/ssh_shared.dir/channels.c.obj
> [ 11%] Building C object src/CMakeFiles/ssh_shared.dir/client.c.obj
> [ 13%] Building C object src/CMakeFiles/ssh_shared.dir/config.c.obj
> [ 14%] Building C object src/CMakeFiles/ssh_shared.dir/connect.c.obj
> C:/MinGW/msys/1.0/home/libssh-0.7.3/src/connect.c:87:2: error: #error "Your system must have getaddrinfo()"
> #error "Your system must have getaddrinfo()"
>  ^
> make[2]: *** [src/CMakeFiles/ssh_shared.dir/connect.c.obj] Error 1
> make[1]: *** [src/CMakeFiles/ssh_shared.dir/all] Error 2
> make: *** [all] Error 2
> 
> ssingh@IN-SSingh-LT /home/libssh-0.7.3/build
> $
> 
> content of below file:
> 
> cat  ./src/CMakeFiles/ssh_shared.dir/includes_C.rsp  
> 
> -IC:/MinGW/msys/1.0/home/libssh-0.7.3/build/src 
> -IC:/MinGW/msys/1.0/home/libssh-0.7.3/src 
> -IC:/MinGW/msys/1.0/home/libssh-0.7.3/include 
> -IC:/MinGW/msys/1.0/home/libssh-0.7.3/build 
> -IC:/MinGW/msys/1.0/local/include 
> -IC:/MinGW/msys/1.0/mingw/include
> 
> 
> Regards,
> Servesh
> 
> 
> From: robin@xxxxxxxxxxxxx [mailto:robin@xxxxxxxxxxxxx] 
> Sent: 30 September 2016 17:58
> To: libssh@xxxxxxxxxx
> Subject: Re: Building library for Windows
> 
> I know what’s wrong with this.  I’ve built the DLL (shared library).  When I explain, you should be able to build the static library.
> 
> [ 94%] Building C object examples/CMakeFiles/exec.dir/exec.c.obj
> [ 95%] Building C object examples/CMakeFiles/exec.dir/authentication.c.obj
> [ 97%] Building C object examples/CMakeFiles/exec.dir/knownhosts.c.obj
> [ 98%] Building C object examples/CMakeFiles/exec.dir/connect_ssh.c.obj
> [100%] Linking C executable exec.exe
> [100%] Built target exec
> 573 -32- /home/rmills/gnu/libssh/libssh-0.7.3/build> find . -name "*.a" -exec ls -alt {} \;
> -rw-r--r-- 1 rmills Administrators 11750 Sep 30 12:42 ./examples/CMakeFiles/exec.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 11012 Sep 30 12:42 ./examples/CMakeFiles/libsshpp.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 5990 Sep 30 12:42 ./examples/CMakeFiles/libsshpp_noexcept.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 11792 Sep 30 12:42 ./examples/CMakeFiles/senddata.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 651698 Sep 30 12:42 ./src/CMakeFiles/ssh_shared.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 241366 Sep 30 12:42 ./src/libssh.dll.a  <— GOOD
> -rw-r--r-- 1 rmills Administrators 2122 Sep 30 12:42 ./src/threads/CMakeFiles/ssh_threads_shared.dir/objects.a
> -rw-r--r-- 1 rmills Administrators 1538 Sep 30 12:42 ./src/threads/libssh_threads.dll.a  <— GOOD
> 574 -32- /home/rmills/gnu/libssh/libssh-0.7.3/build> find . -name "*.dll" -exec ls -alt {} \;
> -rwxr-xr-x 1 rmills Administrators 2291514 Sep 30 12:42 ./src/libssh.dll <— GOOD
> -rwxr-xr-x 1 rmills Administrators 41701 Sep 30 12:42 ./src/threads/libssh_threads.dll  <— GOOD
> 
> CMake is generating the following wrong response files:
> 
> 575 -32- /home/rmills/gnu/libssh/libssh-0.7.3/build> find . -name "*.rsp" -exec ls -alt {} \;
> -rw-r--r-- 1 rmills Administrators 425 Sep 30 12:41 ./examples/CMakeFiles/exec.dir/includes_C.rsp  <— WRONG
> -rw-r--r-- 1 rmills Administrators 187 Sep 30 12:36 ./examples/CMakeFiles/exec.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 148 Sep 30 12:36 ./examples/CMakeFiles/exec.dir/objects1.rsp
> -rw-r--r-- 1 rmills Administrators 264 Sep 30 12:36 ./examples/CMakeFiles/libsshpp.dir/includes_CXX.rsp  <— WRONG   
> -rw-r--r-- 1 rmills Administrators 187 Sep 30 12:36 ./examples/CMakeFiles/libsshpp.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 42 Sep 30 12:36 ./examples/CMakeFiles/libsshpp.dir/objects1.rsp
> -rw-r--r-- 1 rmills Administrators 264 Sep 30 12:36 ./examples/CMakeFiles/libsshpp_noexcept.dir/includes_CXX.rsp <— WRONG
> -rw-r--r-- 1 rmills Administrators 187 Sep 30 12:36 ./examples/CMakeFiles/libsshpp_noexcept.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 60 Sep 30 12:36 ./examples/CMakeFiles/libsshpp_noexcept.dir/objects1.rsp
> -rw-r--r-- 1 rmills Administrators 425 Sep 30 12:41 ./examples/CMakeFiles/senddata.dir/includes_C.rsp  <— WRONG
> -rw-r--r-- 1 rmills Administrators 187 Sep 30 12:36 ./examples/CMakeFiles/senddata.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 168 Sep 30 12:36 ./examples/CMakeFiles/senddata.dir/objects1.rsp
> -rw-r--r-- 1 rmills Administrators 425 Sep 30 12:41 ./src/CMakeFiles/ssh_shared.dir/includes_C.rsp  <— WRONG
> -rw-r--r-- 1 rmills Administrators 166 Sep 30 12:36 ./src/CMakeFiles/ssh_shared.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 2137 Sep 30 12:36 ./src/CMakeFiles/ssh_shared.dir/objects1.rsp
> -rw-r--r-- 1 rmills Administrators 425 Sep 30 12:40 ./src/threads/CMakeFiles/ssh_threads_shared.dir/includes_C.rsp  <— WRONG
> -rw-r--r-- 1 rmills Administrators 182 Sep 30 12:36 ./src/threads/CMakeFiles/ssh_threads_shared.dir/linklibs.rsp
> -rw-r--r-- 1 rmills Administrators 49 Sep 30 12:36 ./src/threads/CMakeFiles/ssh_threads_shared.dir/objects1.rsp
> 576 -32- /home/rmills/gnu/libssh/libssh-0.7.3/build>
> 
> The correct code (in each of the wrong files) on my system (to use the Qt 5.6 provided compiler is): 
> 
> -IC:/MinGW/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/build/src/threads
> -IC:/MinGW/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/src/threads
> -IC:/MinGW/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/include
> -IC:/MinGW/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/build
> -IC:/MinGW/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3
> -IC:/Qt/Qt5.6.0/Tools/mingw492_32/i686-w64-mingw32/include
> -IC:/MinGW/msys/1.0/local/include 
> 
> I had to generate the build files with this command:
> cmake .. -G "Unix Makefiles" -DCMAKE_C_COMPILER=$(which gcc) -DCMAKE_CXX_COMPILER=$(which g++)
> 
> I had to build and install openssl with the commands (in the openssl delivery)
> ./config --prefix=/usr/local
> make
> make install
> 
> To build the static library, you’ll have to edit CMakeLists.txt.  You may well find that the linker response files are not correct for static libraries.
> 
> ////////////  Here are notes I made along the way to solving this ////////////////////////
> 
> I tried to build libssh this morning on MinGW/64.  The experience was the same as MinGW/32.
> 
> 1) I had to edit sdkddkver.h to build CMake
> 
> 2) I had to bootstrap into —prefix=/usr/local (why is bootstrap not called configure?)
> 
> 3) I had to use CMake with this command: cmake .. -G "Unix Makefiles" -DCMAKE_C_COMPILER=$(which gcc) -DCMAKE_CXX_COMPILER=$(which g++)
> 
> 4) Here’s what happens when I run make
> c:/MinGW64/msys/1.0/bin/cmake.exe -E cmake_progress_report C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/build/CMakeFiles 12
> [  1%] Building C object src/CMakeFiles/ssh_shared.dir/auth.c.obj
> cd C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/build/src && c:/TDM-GCC-64/bin/gcc.exe  -DLIBSSH_EXPORTS @CMakeFiles/ssh_shared.dir/includes_C.rsp   -o CMakeFiles/ssh_shared.dir/auth.c.obj   -c C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/src/auth.c
> In file included from c:/MinGW64/msys/1.0/include/sys/unistd.h:9:0,
>                  from c:/MinGW64/msys/1.0/include/unistd.h:6,
>                  from C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/include/libssh/libssh.h:59,
>                  from C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/include/libssh/priv.h:138,
>                  from C:/MinGW64/msys/1.0/home/rmills/gnu/libssh/libssh-0.7.3/src/auth.c:34:
> c:/MinGW64/msys/1.0/include/sys/types.h:71:18: error: conflicting types for 'time_t'
>  typedef _TIME_T_ time_t;
> 
> 5) Exiv2 does not build with CMake either.  Dies a terrible death instantly down inside a stack of system include files involving pthread.
> 
> 6) My notes about CMake are here:
> svn://dev.exiv2.org/svn/trunk/contrib/buildserver/dailyCMake.sh
> 
> Some Exiv2 users love CMake.  I do not.  It works well on Linux/MacOS-X/Cygwin.  It doesn’t seem to work on MinGW.  It’s an obstructive monster with Visual Studio.  Of the 5 platforms we support on Exiv2, MinGW is the one I like least.  However we build and test Exiv2 on all 5 platform on every commit.  We build and test all 5 platforms and 6 editions of Visual Studio in 32 and 64 bits every night.
> 
> One of the challenges of using a build system such as CMake is to fix the build when CMake make mistakes.  Because there is an abstract layer (CMakeLists.txt) between the code and the compiler, when things go wrong you have to crawl through the generated magic.  This is not fun.  The Linux World’s attitude “It must be the fault of Windows, because it works on Linux” is very unhelpful.  You’re unlikely to get any sympathy on an opensource Forum.  It’s your lucky day to have met a helpful open-source contributor who is not Windows hostile.
> 
> I’m very pleased to have worked on this.   I still haven’t got Exiv2 to build using CMake on MinGW/32.  However, I’m confident that I’ll fix that over the weekend.
> 
> Robin 
> http://clanmills.com
> 

References:
RE: Building library for WindowsServesh Singh <ssingh@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org