Discussion:
LIBSSH2-DEV C++ Integration issue [Linker error] undefined reference to `libssh2_
AL-AMEEN MUTHALIF
14 years ago
Permalink
 

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 `***@20'

  [Linker error]
undefined reference to `***@8'

  [Linker error]
undefined reference to `libssh2_init'

  .

  .

  .

  .

  .

  [Linker error]
undefined reference to `libssh2_session_free'

  [Linker error]
undefined reference to `***@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
`***@20'

ssh2_exec.o(.text+0x18d):ssh2_exec.c: undefined reference to
`***@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
`***@4'

ssh2_exec.o(.text+0x244):ssh2_exec.c: undefined reference to
`***@12'

ssh2_exec.o(.text+0x25c):ssh2_exec.c: undefined reference to
`***@4'

ssh2_exec.o(.text+0x283):ssh2_exec.c: undefined reference to
`***@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
`***@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?

 

 



 
Ivan Pechorin
14 years ago
Permalink
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 `libssh2_init'****
It looks like you didn't specify any libraries to link against.
LIBS = -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib"
Try adding the necessary libraries ("-lssh2 -lws2_32") to the end of LIBS:

LIBS = -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib" -lssh2 -lws2_32

P.S. I didn't use gcc on Win32, so I'm not sure what's the proper way of
linking against the WinSock2 (ws2_32.dll) here.
Peter Stuge
14 years ago
Permalink
Post by Ivan Pechorin
LIBS = -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib"
LIBS = -L"C:/Dev-Cpp/lib" -L"C:/MyApps/libssh2-1.2.5/lib" -lssh2 -lws2_32
P.S. I didn't use gcc on Win32, so I'm not sure what's the proper way of
linking against the WinSock2 (ws2_32.dll) here.
Exactly as you write.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Loading...