Thread: LIBSSH2-DEV_C++ Integration issue [Linker error] undefined reference to `libssh2_

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    1

    Unhappy LIBSSH2-DEV_C++ Integration issue [Linker error] undefined reference to `libssh2_

    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.

    Code:
     
    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?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,035
    Read this thread it might help

    Winsock Problem

    Tim S.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker Error - Undefined Reference
    By DaNxTh3xMaNx in forum C Programming
    Replies: 3
    Last Post: 09-07-2011, 05:49 PM
  2. Linker Error/Undefined Reference
    By liljp617 in forum C Programming
    Replies: 2
    Last Post: 09-24-2008, 09:02 PM
  3. linker error undefined reference to
    By BJtoVisualcC++ in forum C++ Programming
    Replies: 3
    Last Post: 06-18-2007, 11:40 AM
  4. Linker Error (undefined reference)
    By Dae in forum C++ Programming
    Replies: 5
    Last Post: 07-15-2005, 03:50 PM
  5. Dev C++ linker error: undefined reference
    By josh_d in forum Windows Programming
    Replies: 11
    Last Post: 03-11-2004, 11:58 AM