在OS X下编译libmms

时间:2011-11-25 23:32:06

标签: c macos static-libraries mms

我在使用C语言中的一些非常基本的静态库链接时遇到了问题。该库是libMMS 0.6.2,程序就像我能做到的那样简单。 libmms.a和test.c位于同一文件夹中,头文件位于./libmms下。编译器是OS X Lion下的llvm-gcc-4.2。

编译libmms:

CFLAGS="-march=x86_64" ./configure
make

test.c的:

#include <stdio.h>
#include "libmms/mms.h"

int main(void)
{
    mms_t *mms = mms_connect(NULL, NULL, "mms://some.url.com", 128*1024);
    return 0;
}

编译程序:

gcc -o test test.c libmms.a

给了我一长串未定义的符号

Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
      _string_utf16 in libmms.a(mms.o)
  "_libiconv_open", referenced from:
      _mms_connect in libmms.a(mms.o)
  "_libiconv_close", referenced from:
      _mms_connect in libmms.a(mms.o)
  "_g_strdup", referenced from:
      _split_user_passwd in libmms.a(uri.o)
      _gnet_uri_new in libmms.a(uri.o)
      _gnet_uri_new_fields in libmms.a(uri.o)
      _gnet_uri_new_fields_all in libmms.a(uri.o)
      _gnet_uri_clone in libmms.a(uri.o)
      _gnet_uri_set_scheme in libmms.a(uri.o)
      _gnet_uri_set_userinfo in libmms.a(uri.o)
      ...
  "_g_free", referenced from:
      _split_user_passwd in libmms.a(uri.o)
      _gnet_uri_new in libmms.a(uri.o)
      _gnet_uri_delete in libmms.a(uri.o)
      _field_escape in libmms.a(uri.o)
      _gnet_uri_set_scheme in libmms.a(uri.o)
      _gnet_uri_set_userinfo in libmms.a(uri.o)
      _gnet_uri_set_hostname in libmms.a(uri.o)
      ...
  "_g_return_if_fail_warning", referenced from:
      _gnet_uri_new in libmms.a(uri.o)
      _gnet_uri_clone in libmms.a(uri.o)
      _gnet_uri_equal in libmms.a(uri.o)
      _gnet_uri_hash in libmms.a(uri.o)
      _gnet_uri_escape in libmms.a(uri.o)
      _gnet_uri_unescape in libmms.a(uri.o)
      _gnet_uri_get_string in libmms.a(uri.o)
      ...
  "_g_malloc0_n", referenced from:
      _gnet_uri_new in libmms.a(uri.o)
      _gnet_uri_new_fields in libmms.a(uri.o)
      _gnet_uri_new_fields_all in libmms.a(uri.o)
      _gnet_uri_clone in libmms.a(uri.o)
  "_g_strndup", referenced from:
      _gnet_uri_new in libmms.a(uri.o)
  "_g_str_hash", referenced from:
      _gnet_uri_hash in libmms.a(uri.o)
  "_g_malloc", referenced from:
      _field_escape in libmms.a(uri.o)
  "_g_string_sized_new", referenced from:
      _gnet_uri_get_string in libmms.a(uri.o)
  "_g_string_append_printf", referenced from:
      _gnet_uri_get_string in libmms.a(uri.o)
  "_g_string_append", referenced from:
      _gnet_uri_get_string in libmms.a(uri.o)
  "_g_string_free", referenced from:
      _gnet_uri_get_string in libmms.a(uri.o)
  "_g_string_insert_c", referenced from:
      _g_string_append_c_inline in libmms.a(uri.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

我在这里错过了一些简单的东西吗?

1 个答案:

答案 0 :(得分:0)

似乎libmms取决于libiconvglib,因此您也需要将这些链接起来。