Guys,

I’m trying to integrate libssh2 libraries(windows version libssh2-1.2.5) with Dev-C++( v4.9.9.2). The OS is Windows XP SP3. I’m facing the following error when I compile the test file ssh2_exec.c (built in example) file.

Compiler Output:
---------------------
  [Linker error] undefined reference to `libssh2_session_block_directions'
  [Linker error] undefined reference to `select@20'
  [Linker error] undefined reference to `WSAStartup@8'
  [Linker error] undefined reference to `libssh2_init'
  .
  .
  .
  .
  .
  [Linker error] undefined reference to `libssh2_session_free'
  [Linker error] undefined reference to `closesocket@4'
  [Linker error] undefined reference to `libssh2_exit'
  ld returned 1 exit status
C:\MyApps\libssh2\Makefile.win [Build Error]  [cmdSSH.exe] Error 1
C:\MyApps\libssh2\Makefile.win [Build Error]  [cmdSSH.exe] Error 1


Complier Log.
-----------------
Compiler: Default compiler
Building Makefile: "C:\MyApps\libssh2\Makefile.win"
Executing  make clean
rm -f ssh2_exec.o  cmdSSH.exe 
gcc.exe -c ssh2_exec.c -o ssh2_exec.o -I"C:/Dev-Cpp/include"  -I"C:/MyApps/libssh2-1.2.5/include"     
gcc.exe ssh2_exec.o  -o "cmdSSH.exe" -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib"    
ssh2_exec.o(.text+0xa1):ssh2_exec.c: undefined reference to `libssh2_session_block_directions'
ssh2_exec.o(.text+0x10a):ssh2_exec.c: undefined reference to `select@20'
ssh2_exec.o(.text+0x18d):ssh2_exec.c: undefined reference to `WSAStartup@8'
ssh2_exec.o(.text+0x1e0):ssh2_exec.c: undefined reference to `libssh2_init'
ssh2_exec.o(.text+0x222):ssh2_exec.c: undefined reference to `inet_addr@4'
ssh2_exec.o(.text+0x244):ssh2_exec.c: undefined reference to `socket@12'
ssh2_exec.o(.text+0x25c):ssh2_exec.c: undefined reference to `htons@4'
ssh2_exec.o(.text+0x283):ssh2_exec.c: undefined reference to `connect@12'
ssh2_exec.o(.text+0x2d5):ssh2_exec.c: undefined reference to `libssh2_session_init_ex'
ssh2_exec.o(.text+0x300):ssh2_exec.c: undefined reference to `libssh2_session_set_blocking'
ssh2_exec.o(.text+0x312):ssh2_exec.c: undefined reference to `libssh2_session_startup'
ssh2_exec.o(.text+0x35c):ssh2_exec.c: undefined reference to `libssh2_knownhost_init'
ssh2_exec.o(.text+0x38f):ssh2_exec.c: undefined reference to `libssh2_knownhost_readfile'
ssh2_exec.o(.text+0x3aa):ssh2_exec.c: undefined reference to `libssh2_knownhost_writefile'
ssh2_exec.o(.text+0x3c3):ssh2_exec.c: undefined reference to `libssh2_session_hostkey'
ssh2_exec.o(.text+0x402):ssh2_exec.c: undefined reference to `libssh2_knownhost_check'
ssh2_exec.o(.text+0x474):ssh2_exec.c: undefined reference to `libssh2_knownhost_free'
ssh2_exec.o(.text+0x4bf):ssh2_exec.c: undefined reference to `libssh2_userauth_password_ex'
ssh2_exec.o(.text+0x52b):ssh2_exec.c: undefined reference to `libssh2_userauth_publickey_fromfile_ex'
ssh2_exec.o(.text+0x594):ssh2_exec.c: undefined reference to `libssh2_channel_open_ex' ssh2_exec.o(.text+0x5c0):ssh2_exec.c: undefined reference to `libssh2_session_last_error'
ssh2_exec.o(.text+0x634):ssh2_exec.c: undefined reference to `libssh2_channel_process_startup'
ssh2_exec.o(.text+0x6a0):ssh2_exec.c: undefined reference to `libssh2_channel_read_ex'
ssh2_exec.o(.text+0x799):ssh2_exec.c: undefined reference to `libssh2_channel_close'
ssh2_exec.o(.text+0x7c7):ssh2_exec.c: undefined reference to `libssh2_channel_get_exit_status'
ssh2_exec.o(.text+0x804):ssh2_exec.c: undefined reference to `libssh2_channel_get_exit_signal'
ssh2_exec.o(.text+0x844):ssh2_exec.c: undefined reference to `libssh2_channel_free'
ssh2_exec.o(.text+0x86e):ssh2_exec.c: undefined reference to `libssh2_session_disconnect_ex'
ssh2_exec.o(.text+0x879):ssh2_exec.c: undefined reference to `libssh2_session_free'
ssh2_exec.o(.text+0x884):ssh2_exec.c: undefined reference to `closesocket@4'
ssh2_exec.o(.text+0x8a4):ssh2_exec.c: undefined reference to `libssh2_exit'
collect2: ld returned 1 exit status 
make.exe: *** [cmdSSH.exe] Error 1 
Execution terminated
Make File:
# Project: cmdSSH
# Makefile created by Dev-C++ 4.9.9.2

CPP  = g++.exe
CC   = gcc.exe
WINDRES = windres.exe
RES  = 
OBJ  = ssh2_exec.o $(RES)
LINKOBJ  = ssh2_exec.o $(RES)
LIBS =  -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib"   
INCS =  -I"C:/Dev-Cpp/include"  -I"C:/MyApps/libssh2-1.2.5/include" 
CXXINCS =  -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/MyApps/libssh2-1.2.5/include" 
BIN  = cmdSSH.exe
CXXFLAGS = $(CXXINCS)  
CFLAGS = $(INCS)   
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before cmdSSH.exe all-after


clean: clean-custom
    ${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
    $(CC) $(LINKOBJ) -o "cmdSSH.exe" $(LIBS)

ssh2_exec.o: ssh2_exec.c
    $(CC) -c ssh2_exec.c -o ssh2_exec.o $(CFLAGS)

Can someone help me to resolve the issue? :(

Well, I don't see that you are actually linking the library. Add the linker directive "-l ssh2" to your LIBS variable. That's a lower-case 'ell'. The upper-case directives are for directories to search for the actual libraries to link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.