Fixed build on MSYS (Windows) 64-bit #22

Merged
merged 1 commit into from Oct 10, 2015

Conversation

Projects
None yet
4 participants
@donkeybonks
Contributor

donkeybonks commented Sep 24, 2014

@ForNeVeR

This comment has been minimized.

Show comment
Hide comment
@ForNeVeR

ForNeVeR Jul 26, 2015

@kvanberendonck, thank you for that request and sorry for the long delay with merging this.

Currently I'm trying to follow your blog post and build this with msys2.

At first, I had to pacman -S gcc (otherwise it won't build without sys/stat.h etc).

After that I'm still getting the wrong definition of libssh2_session_handshake in Foreign.hs:

foreign import ccall safe "Network\\SSH\\Client\\LibSSH2\\Foreign.chs.h libssh2_session_handshake"
  handshake_'_ :: ((Ptr ()) -> (CInt -> (IO CInt)))

(but it should say CULLong instead of CInt on a 64-bit Windows OS)

I think that it's due to c2hs not passing _WIN32 and WIN32 defines to libssh2.h. But if I try to pass them, it getting worse and start complaining about some absolutely unrelated header files such as /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/bmi2intrin.h.

I can fix that errors with some additional defines (such as #define __int128 int) although it comes to the ultimate error:

In file included from C:\Program Files\Haskell Platform\2014.2.0.0\lib/include/rts/Threads.h:19:0,
                from C:\Program Files\Haskell Platform\2014.2.0.0\lib/include/Rts.h:206,
                from T:\Temp\ghc21572_0\ghc21572_5.c:2:
e:\Programs\msys2\usr\include/sys/types.h:124:18: error: conflicting types for 'time_t'
c:\program files\haskell platform\2014.2.0.0\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/include/_mingw.h:488:20: note: previous declaration of 'time_t' was here

I'm obviously doing something wrong, but what exactly? Could we easily fix that?

(If I could build that, we'd merge your request and I'd prepare new build instructions for those brave souls willing to use libssh2 on Windows.)

@kvanberendonck, thank you for that request and sorry for the long delay with merging this.

Currently I'm trying to follow your blog post and build this with msys2.

At first, I had to pacman -S gcc (otherwise it won't build without sys/stat.h etc).

After that I'm still getting the wrong definition of libssh2_session_handshake in Foreign.hs:

foreign import ccall safe "Network\\SSH\\Client\\LibSSH2\\Foreign.chs.h libssh2_session_handshake"
  handshake_'_ :: ((Ptr ()) -> (CInt -> (IO CInt)))

(but it should say CULLong instead of CInt on a 64-bit Windows OS)

I think that it's due to c2hs not passing _WIN32 and WIN32 defines to libssh2.h. But if I try to pass them, it getting worse and start complaining about some absolutely unrelated header files such as /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/bmi2intrin.h.

I can fix that errors with some additional defines (such as #define __int128 int) although it comes to the ultimate error:

In file included from C:\Program Files\Haskell Platform\2014.2.0.0\lib/include/rts/Threads.h:19:0,
                from C:\Program Files\Haskell Platform\2014.2.0.0\lib/include/Rts.h:206,
                from T:\Temp\ghc21572_0\ghc21572_5.c:2:
e:\Programs\msys2\usr\include/sys/types.h:124:18: error: conflicting types for 'time_t'
c:\program files\haskell platform\2014.2.0.0\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/include/_mingw.h:488:20: note: previous declaration of 'time_t' was here

I'm obviously doing something wrong, but what exactly? Could we easily fix that?

(If I could build that, we'd merge your request and I'd prepare new build instructions for those brave souls willing to use libssh2 on Windows.)

@donkeybonks

This comment has been minimized.

Show comment
Hide comment
@donkeybonks

donkeybonks Jul 26, 2015

Contributor

Did you patch in the last snippet from #21 ?

The blog post assumes you perform some manual patching of libssh2-hs, and I had assumed that these would eventually get merged but they never did. Blog post was a very long time ago, may no longer be relevant.

Contributor

donkeybonks commented Jul 26, 2015

Did you patch in the last snippet from #21 ?

The blog post assumes you perform some manual patching of libssh2-hs, and I had assumed that these would eventually get merged but they never did. Blog post was a very long time ago, may no longer be relevant.

@ForNeVeR

This comment has been minimized.

Show comment
Hide comment
@ForNeVeR

ForNeVeR Jul 26, 2015

Yeah, I've used the patched version from your fork. Note that I had problems not with ssh2socket function you patched, but with handshake_'_ automatically generated by c2hs from libssh2_session_handshake.

Yeah, I've used the patched version from your fork. Note that I had problems not with ssh2socket function you patched, but with handshake_'_ automatically generated by c2hs from libssh2_session_handshake.

@donkeybonks

This comment has been minimized.

Show comment
Hide comment
@donkeybonks

donkeybonks Jul 26, 2015

Contributor

Looks like the issue may be able to be fixed in a very similar way to the original ssh2socket issue, but adapted for handshake_'_.

I actually got really frustrated and now dev from a mac, so I can't really provide support for this patch anymore, sorry.

Contributor

donkeybonks commented Jul 26, 2015

Looks like the issue may be able to be fixed in a very similar way to the original ssh2socket issue, but adapted for handshake_'_.

I actually got really frustrated and now dev from a mac, so I can't really provide support for this patch anymore, sorry.

@ForNeVeR

This comment has been minimized.

Show comment
Hide comment
@ForNeVeR

ForNeVeR Jul 26, 2015

Okay, thanks for elaboration anyway!

Okay, thanks for elaboration anyway!

@nitrix

This comment has been minimized.

Show comment
Hide comment
@nitrix

nitrix Oct 9, 2015

This patch solved the issue for me and I'd like to see it upstream. +1

nitrix commented Oct 9, 2015

This patch solved the issue for me and I'd like to see it upstream. +1

portnov added a commit that referenced this pull request Oct 10, 2015

Merge pull request #22 from kvanberendonck/master
Fixed build on MSYS (Windows) 64-bit

@portnov portnov merged commit 91dc0b9 into portnov:master Oct 10, 2015

@donkeybonks

This comment has been minimized.

Show comment
Hide comment
@donkeybonks

donkeybonks Oct 11, 2015

Contributor

The gift that keeps on giving

Just past the anniversary of the original patch :)

Contributor

donkeybonks commented Oct 11, 2015

The gift that keeps on giving

Just past the anniversary of the original patch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment