Subject: Newbie Problem with "missing symbols"

Newbie Problem with "missing symbols"

From: Philipp Kalder <philipp_at_kalder.info>
Date: Tue, 26 Jun 2012 20:07:27 +0200

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
Received on 2012-06-26