Hello,

just an update. I tried the same on a Linux VM with a very similar result.
Though the error message is different. This is either a result of different gcc 
versions
or the linux box just hasn't had the /usr/local/lib or /usr/local/include 
folder in it's PATH.

configure on the linux Box showed:

configure: summary of build options:

  version:          1.4.2
  Host type:        x86_64-unknown-linux-gnu
  Install prefix:   /usr/local
  Compiler:         gcc
  Compiler flags:   -g -O2
  Library types:    Shared=yes, Static=yes
  Crypto library:   openssl: no (AES-CTR: N/A) libgcrypt: yes
  Debug build:      no
  Build examples:   yes
  Path to sshd:      (only for self-tests)
  libz compression: no

And the build with % gcc -v ssh2_agent.c -o testBuild

showed up as below. Here the arch is the same.

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 
4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs 
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-4.5 --enable-shared --enable-multiarch 
--with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id 
--with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu 
--without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/x86_64-linux-gnu 
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug 
--enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default 
--with-plugin-ld=ld.gold --enable-objc-gc --disable-werror --with-arch-32=i686 
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu 
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) 
COLLECT_GCC_OPTIONS='-v' '-o' 'testBuild' '-mtune=generic' '-march=x86-64'
 /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/cc1 -quiet -v 
ssh2_agent.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase ssh2_agent.c -mtune=generic 
-march=x86-64 -auxbase ssh2_agent -version -fstack-protector -o /tmp/ccK5e7V7.s
GNU C (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 
3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory 
"/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/include
 /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 
3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9755ab75799195519479ef699703b13b
COLLECT_GCC_OPTIONS='-v' '-o' 'testBuild' '-mtune=generic' '-march=x86-64'
 as -V -Qy --64 -o /tmp/cc412T5h.o /tmp/ccK5e7V7.s
GNU assembler version 2.21.0 (x86_64-linux-gnu) using BFD version (GNU Binutils 
for Ubuntu) 2.21.0.20110327
COMPILER_PATH=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/:/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../:/lib/:/usr/lib/:/usr/lib/x86_64-linux-gnu/
COLLECT_GCC_OPTIONS='-v' '-o' 'testBuild' '-mtune=generic' '-march=x86-64'
 /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/collect2 --build-id 
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker 
/lib64/ld-linux-x86-64.so.2 -z relro -o testBuild 
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crt1.o 
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crti.o 
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtbegin.o 
-L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 
-L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../.. 
-L/usr/lib/x86_64-linux-gnu /tmp/cc412T5h.o -lgcc --as-needed -lgcc_s 
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed 
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtend.o 
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crtn.o
/tmp/cc412T5h.o: In function `main':
ssh2_agent.c:(.text+0x8f): undefined reference to `libssh2_init'
ssh2_agent.c:(.text+0x185): undefined reference to `libssh2_session_init_ex'
ssh2_agent.c:(.text+0x19a): undefined reference to `libssh2_session_handshake'
ssh2_agent.c:(.text+0x1dd): undefined reference to `libssh2_hostkey_hash'
ssh2_agent.c:(.text+0x25a): undefined reference to `libssh2_userauth_list'
ssh2_agent.c:(.text+0x2c2): undefined reference to `libssh2_agent_init'
ssh2_agent.c:(.text+0x309): undefined reference to `libssh2_agent_connect'
ssh2_agent.c:(.text+0x349): undefined reference to 
`libssh2_agent_list_identities'
ssh2_agent.c:(.text+0x394): undefined reference to `libssh2_agent_get_identity'
ssh2_agent.c:(.text+0x3f1): undefined reference to `libssh2_agent_userauth'
ssh2_agent.c:(.text+0x4aa): undefined reference to `libssh2_channel_open_ex'
ssh2_agent.c:(.text+0x4ff): undefined reference to `libssh2_channel_setenv_ex'
ssh2_agent.c:(.text+0x53d): undefined reference to 
`libssh2_channel_request_pty_ex'
ssh2_agent.c:(.text+0x588): undefined reference to 
`libssh2_channel_process_startup'
ssh2_agent.c:(.text+0x5c5): undefined reference to `libssh2_channel_free'
ssh2_agent.c:(.text+0x5d9): undefined reference to `libssh2_agent_disconnect'
ssh2_agent.c:(.text+0x5e5): undefined reference to `libssh2_agent_free'
ssh2_agent.c:(.text+0x607): undefined reference to 
`libssh2_session_disconnect_ex'
ssh2_agent.c:(.text+0x613): undefined reference to `libssh2_session_free'
ssh2_agent.c:(.text+0x632): undefined reference to `libssh2_exit'
collect2: ld returned 1 exit status





On Jun 26, 2012, at 8:07 PM, Philipp Kalder wrote:

> Hello there,
> 
> I'm just starting out getting deeper into a "curly bracket" Language. So I'm 
> a fairly
> unexperienced in debugging gcc/linker messages. Sadly this is what I get 
> trying to
> compile even an libssh2 sample.
> 
> I'm mostly coding in Python, from small scripts up to more complex, Object 
> Oriented
> stuff. For the smaller scripts I wrote a convenience wrapper around the 
> python lib
> Paramiko which is a library around ssh and the likes. Being able to execute 
> commands
> via ssh and parse the results is at the core of the most scripts I write. So 
> I thought this
> to be a good starting point for learning C/ Objective-C. Asking the Interwebs 
> I found
> libssh2 to be the proper library for this. However, after grabbing the latest 
> tar-ball and compiling
> it with the three-step:
> 
> ./configure
> (Here the summary of configure)
> configure: summary of build options:
> 
>  version:          1.4.2
>  Host type:        x86_64-apple-darwin11.4.0
>  Install prefix:   /usr/local
>  Compiler:         gcc
>  Compiler flags:    -DLIBSSH2_DARWIN
>  Library types:    Shared=yes, Static=yes
>  Crypto library:   openssl: yes (AES-CTR: no) libgcrypt: no
>  Debug build:      no
>  Build examples:   yes
>  Path to sshd:     /usr/sbin/sshd (only for self-tests)
>  libz compression: yes
> 
> make
> 
> make install
> 
> I find myself stuck with a linker error that I just cannot solve. I "googled" 
> a lot and found others with
> similar, yet not the same problem. And most of the time the answer/solution 
> was a bit too much for
> me. Yet I have a suspicion that the solution is much simpler than I expect. 
> As it seems for to be a
> problem with the arch of the host. My Mac is a x86_64 machine and configure 
> figured that one out
> all right. But after I assembled a test programm, that was not complete but 
> at a point where I could
> try to build it, I got errors. So I decided to try and build an example that 
> was provided (and already build)
> with the tar-ball. But I get the same errors:
> 
> Undefined symbols for architecture x86_64:
>  "_libssh2_init", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_session_init_ex", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_session_handshake", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_hostkey_hash", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_userauth_list", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_init", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_connect", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_list_identities", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_get_identity", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_userauth", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_channel_open_ex", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_channel_setenv_ex", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_channel_request_pty_ex", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_channel_process_startup", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_channel_free", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_disconnect", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_agent_free", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_session_disconnect_ex", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_session_free", referenced from:
>      _main in cc6PUHa5.o
>  "_libssh2_exit", referenced from:
>      _main in cc6PUHa5.o
> ld: symbol(s) not found for architecture x86_64
> collect2: ld returned 1 exit status
> 
> ---
> 
> I tried running gcc with verbosity on which yielded, on top of the above 
> output:
> 
> Using built-in specs.
> Target: i686-apple-darwin11
> Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure 
> --disable-checking --enable-werror 
> --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 
> --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ 
> --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ 
> --with-slibdir=/usr/lib --build=i686-apple-darwin11 
> --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local
>  --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 
> --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
> Thread model: posix
> gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
> /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1 -quiet -v 
> -imultilib x86_64 -iprefix 
> /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/ -D__DYNAMIC__ 
> ssh2_agent.c -fPIC -quiet -dumpbase ssh2_agent.c -mmacosx-version-min=10.7.4 
> -m64 -mtune=core2 -auxbase ssh2_agent -version -o 
> /var/folders/bj/kx0hd0fd405cspwp6g9tvh5w0000gn/T//ccRkCGdH.s
> ignoring nonexistent directory 
> "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
> ignoring nonexistent directory 
> "/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include
> /usr/local/include
> /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include
> /usr/include
> /System/Library/Frameworks (framework directory)
> /Library/Frameworks (framework directory)
> End of search list.
> GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00) 
> (i686-apple-darwin11)
>       compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM 
> build 2336.9.00).
> GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072
> Compiler executable checksum: ee05ffc2102727aa16c85f6ae97aa56c
> /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/as -arch 
> x86_64 -force_cpusubtype_ALL -o 
> /var/folders/bj/kx0hd0fd405cspwp6g9tvh5w0000gn/T//ccZFQXlh.o 
> /var/folders/bj/kx0hd0fd405cspwp6g9tvh5w0000gn/T//ccRkCGdH.s
> /usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/collect2 
> -dynamic -arch x86_64 -macosx_version_min 10.7.4 -weak_reference_mismatches 
> non-weak -o testBuild -lcrt1.10.6.o 
> -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64 
> -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/x86_64
>  -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1 
> -L/usr/llvm-gcc-4.2/bin/../lib/gcc 
> -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1
>  -L/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../.. 
> -L/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../..
>  /var/folders/bj/kx0hd0fd405cspwp6g9tvh5w0000gn/T//ccZFQXlh.o -lSystem -lgcc 
> -lSystem
> 
> 
> ---
> 
> So what got my attention was that gcc said:
> Target: i686-apple-darwin11
> 
> Where as configure said:
> Host type:        x86_64-apple-darwin11.4.0
> 
> And I tried building the lib with
> 
> ./configure --build=i686_64-apple-darwin11
> 
> which finished successfully but gcc yields the same results.
> 
> So after a very long text I'm still stuck with:
> ld: symbol(s) not found for architecture x86_64
> 
> Another hint, Xcode yields also something about the linker.
> Unfortunately I'm writing this email on another mac as where I encountered 
> the problem first.
> ATM I'm unable to make Xcode on this machine find libssh2.h. But that is a 
> problem to ignore.
> 
> So the question of the day, does anybody know what's wrong here? Wht do I 
> need to change
> to be able to even build the samples provided?
> 
> Best Regards,
> Philipp
> 
> 
> 
> 
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
> 


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

Reply via email to