Can't build under windows-x86
justnoxx opened this issue · 13 comments
Hello!
I have following issue.
I've built all required libraries for net::ssh2 compilation(openssl, zlib, libssh2), but can't build Net::SSH2 itself.
My OS is windows server 2003 x86.
When makefile were generated, I've impossible to make with following error(dmake):
C:\build\Net-SSH2-0.56>dmake
dmake: makefile: line 436: Error: -- A non AUGMAKE meta target must not be mixed with AUGMAKE meta targets, offending target [SSH2.obj]
nmake:
C:\build\Net-SSH2-0.56>nmake -f Makefile
Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
Makefile(967) : fatal error U1086: inference rule cannot have dependents
Stop.
I will look at this and update the windows build instructions.
Can you tell me please, which version of Perl are you using, which version of mingw and msys etc.
I have 2 perls,
Older one, 5.8.8, and newer one: 5.22.0(strawberry)
I've tried to build that with vcpp, because on my older perl(5.8.8) this module was built without mingw, so, I trying to understand, how it was built.
Okay, I've switched to dmake for my perls and tried to do all things from the beginning, on older tag v057_03. With no luck, but right now errors are following:
link -out:blib\arch\auto\Net\SSH2\SSH2.dll -dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:"C:/EC\perl\lib\CORE" -machine:x86 SSH2.obj "C:\EC\perl\lib\CORE\perl58.lib" "C:\VC98\LIB\oldnames.lib" "C:\VC98\LIB\kernel32.lib" "C:\VC98\LIB\user32.lib" "C:\VC98\LIB\gdi32.lib" "C:\VC98\LIB\winspool.lib" "C:\VC98\LIB\comdlg32.lib" "C:\VC98\LIB\advapi32.lib" "C:\VC98\LIB\shell32.lib" "C:\VC98\LIB\ole32.lib" "C:\VC98\LIB\oleaut32.lib" "C:\VC98\LIB\netapi32.lib" "C:\VC98\LIB\uuid.lib" "C:\VC98\LIB\ws2_32.lib" "C:\VC98\LIB\mpr.lib" "C:\VC98\LIB\winmm.lib" "C:\VC98\LIB\version.lib" "C:\VC98\LIB\odbc32.lib" "C:\VC98\LIB\odbccp32.lib" "C:\VC98\LIB\msvcrt.lib" -def:SSH2.def
Creating library blib\arch\auto\Net\SSH2\SSH2.lib and object blib\arch\auto\Net\SSH2\SSH2.exp
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_init_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_trace
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_block_directions
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_set_timeout
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_set_blocking
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_banner_set
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_last_error
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_method_pref
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_methods
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_flag
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_callback_set
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_startup
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_disconnect_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_hostkey_hash
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_hostkey
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_list
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_authenticated
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_password_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_userauth
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_get_identity
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_list_identities
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_connect
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_agent_init
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_get_blocking
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_publickey_fromfile_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_publickey_frommemory
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_hostbased_fromfile_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_userauth_keyboard_interactive_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_keepalive_config
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_keepalive_send
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_open_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_scp_recv
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_scp_send_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_direct_tcpip_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_forward_listen_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_init
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_poll
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_init
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_init
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_setenv_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_get_exit_signal
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_set_blocking
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_eof
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_send_eof
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_close
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_wait_closed
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_get_exit_status
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_request_pty_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_request_pty_size_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_process_startup
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_handle_extended_data
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_read_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_write_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_receive_window_adjust2
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_window_write_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_window_read_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_flush_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_forward_cancel
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_channel_forward_accept
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_shutdown
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_last_error
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_open_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_unlink_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_rename_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_mkdir_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_rmdir_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_stat_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_symlink_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_close_handle
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_read
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_write
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_fstat_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_seek
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_tell
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_sftp_readdir_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_shutdown
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_add_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_remove_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_list_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_publickey_list_fetch
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_free
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_readfile
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_writefile
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_addc
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_checkp
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_readline
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_knownhost_writeline
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_set_dynlock_destroy_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_set_dynlock_lock_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_set_dynlock_create_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_get_dynlock_destroy_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_get_dynlock_lock_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_get_dynlock_create_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_set_locking_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_num_locks
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_THREADID_get_callback
SSH2.obj : error LNK2001: unresolved external symbol _CRYPTO_get_locking_callback
blib\arch\auto\Net\SSH2\SSH2.dll : fatal error LNK1120: 101 unresolved externals
What's wrong?
Thanks.
/Dmitriy
Did you edit the Makefile.PL to add the paths to the libssh2 and openssl that you compiled?
In provided guide present a section with paths to these libraries:
my $extra_libs = 'c:/build_minGW/zlib/lib/libz.a c:/build_minGW/openssl-1.0.1p/lib/libssl.a c:/build_minGW/openssl-1.0.1p/lib/libcrypto.a ';
I've added this one to check:
$extra_libs .= 'c:/build_minGW/libssh2-1.6.0/src/.libs/libssh2.a';
Also, I was able to achieve the same error as I have without mingw, only with visual c++.
Looks like guide contains some wrong/outdated information.
For example, I was not able to build libssh like that:
./buildconf
./configure --with-openssl --with-libz \
--with-libssl-prefix=/c/Users/rkitover/src/openssl-1.0.1c \
--with-libz-prefix=/c/Users/rkitover/src/zlib-1.2.7 \
--disable-examples-build
make -j3
But like that it works fine:
./configure --with-openssl --with-libz \
--with-libssl-prefix=C:/build_minGW/openssl-1.0.1p \
--with-libz-prefix=C:/build_minGW/zlib \
--disable-examples-build
So after you added the libraries, were you able to build the module?
No, I was not able to build module.
When I got these errors:
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_init_ex
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_trace
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_block_directions
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_set_timeout
SSH2.obj : error LNK2001: unresolved external symbol _libssh2_session_set_blocking
$extra_lib was replaced and:
my $extra_libs = 'c:/build_minGW/zlib/lib/libz.a c:/build_minGW/openssl-1.0.1p/lib/libssl.a c:/build_minGW/openssl-1.0.1p/lib/libcrypto.a ';
After your suggestion I tried to add path to libssh2.a to this list, errors the same.
I'm having issues too. I'm on Windows 7 64-bit, using ActivePerl 5.16.1604. I installed mingw64 from mingw-w64.org using the msys2 package (but also installed via ppm install MinGW64
just so I could try both).
I tried two approaches:
- I tried using msys2's ported pacman to install mingw-w64-x86_64-libssh2, mingw-w64-x86_64-openssl & mingw-w64-x86_64-zlib.
- I tried building openssl, zlib & libssh2 from source (I was able to build all 3)
I got the same results no matter what code I used. Given that msys2 makes it easy to install 64-bit mingw static libs, that might be a good approach to suggest once the build is working.
If I try to run the dmake provided by ActivePerl, I get a similar result as justnoxx, except my dmake output ends like this (and all the lines are prefaced with SSH2.o:SSH2.c:(text+0xXXXXX):
)
SSH2.o:SSH2.c:(.text+0x14d5e): undefined reference to `CRYPTO_set_dynlock_destroy_callback'
c:/perl64/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/ld.exe: SSH2.o: bad reloc address 0x20 in section `.data'
c:/perl64/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2: ld returned 1 exit status
dmake.exe: Error code 129, while making 'blib\arch\auto\Net\SSH2\SSH2.dll'
If I try to build using the msys2-installed dmake, I get this output:
C:\msys64\mingw64\bin\gcc.exe -c -Itmp/include -I. -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DHASATTRIBUTE -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"0.58\" -DXS_VERSION=\"0.58\" "-IC:\Perl64\lib\CORE" -DLIBSSH2_WIN32 SSH2.c
In file included from C:\Perl64\lib\CORE/win32thread.h:4:0,
from C:\Perl64\lib\CORE/perl.h:2834,
from SSH2.xs:8:
C:\Perl64\lib\CORE/win32.h:297:13: error: conflicting types for 'mkstemp'
extern int mkstemp(const char *path);
^
In file included from C:\Perl64\lib\CORE/perl.h:681:0,
from SSH2.xs:8:
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:381:15: note: previous declaration of 'mkstemp' was here
int __cdecl mkstemp(char *template_name);
^
dmake.exe: Error code 129, while making 'SSH2.o'
Unfortunately for me, using the sisyphusion.tk-provided Net-SSH2 is not an option, for one because it is my understanding it is built with dynamic libs (which breaks PerlApp, the ultimate destination for my code) and also because it is built against libssh2 1.4.3, which does not provide support for the auth_publickey_frommemory
method, and our coding guidelines frown upon writing out crypto certificates from the app to the filesystem.
Any suggestions? I followed all of your suggestions from this thread...I also followed your suggestions from Building XS Modules for 64bit ActivePerl on Windows for building with MinGW.
I'm willing to try using VS but the thought of building openssl, libssh2 and zlib using VS seems even more daunting than using mingw
I haven't done this in a few years, when I wrote BUILDING.WIN32 all of those instructions worked of course, but I guess things changed.
I like your idea of using the packaged mingw libs in msys2.
I am going to add some code to Makefile.PL to automate all of this and get it to work.
Please give me a few days at least.
@justnoxx, @wallacewinfrey, @rkitover and everybody interested in getting Net::SSH2 to be easy installable on Windows:
Over the last weeks I have been working on a set of Alien packages to get all Net::SSH2 dependencies installed automatically both in Linux/Unix and Windows Active Perl and Strawberry Perl (see Alien::Libssh2, Alien::OpenSSL, Alien::Libgcrypt, Alien::Libgpg_error and also the module-build branch on this repo).
It is still a work in progress. Currently I am stuck with an issue on Windows where Libssh2 links against ws2_32 but then, Net::SSH2 can not find it at runtime. My knowledge of Windows is rather limited so I would really appreciate help from more skilled people in order to move it forward.
For faster communication I can also be found in #native at irc.perl.org
@salva I don't have any issues with zlib, openssl or libssh2. Looks like my problem is not in the missing dependencies.
Thanks.
Any update on this ?
@wallacewinfrey @salva @rkitover
I was able to build Net::SSH2 under windows 10 minutes ago. Now I verifying it. If everything will be ok, I'll prepare pull request with updated guide and fixed makefile.
Thanks.