Нечто странное происходит.
У меня есть статическая библиотека в Си, скомпилированная с использованием CMake.
Я ссылаюсь на создание исполняемого штрафа в Ubuntu, но в Snow Leopard я получаю неопределенную ошибку символа при попыткесделайте это:
per-ms006:mbuild douglasl$ make
Linking C executable Sample
Undefined symbols:
"_na_Gfx_Impl", referenced from:
_na_impl_render in libdesktop.a(impl.c.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [Sample] Error 1
make[1]: *** [CMakeFiles/Sample.dir/all] Error 2
make: *** [all] Error 2
Это загадочно для меня, потому что nm в статической библиотеке показывает:
... (куча вещей опущена) ...
libdesktop.a(impl.c.o):
0000000000003a30 s EH_frame1
0000000000003990 s LC0
00000000000039a0 s LC1
00000000000039ac s LC2
00000000000039d0 s LC3
00000000000039f0 s LC4
00000000000039fc s LC5
0000000000003a0c s LC6
0000000000003a1b s LC7
0000000000003a2a s LC8
U _SDL_PollEvent
U _free
U _malloc
U _na_Gfx_Impl <----------- Symbol is there.
0000000000000209 T _na_impl_api
0000000000003b38 S _na_impl_api.eh
U _na_impl_assets_create
U _na_impl_events_create
U _na_impl_events_destroy
U _na_impl_gfx_create
U _na_impl_gfx_destroy
0000000000000124 T _na_impl_init
0000000000003aa8 S _na_impl_init.eh
0000000000000021 T _na_impl_log
0000000000003a78 S _na_impl_log.eh
0000000000000159 T _na_impl_poll
0000000000003ad8 S _na_impl_poll.eh
00000000000002d0 T _na_impl_release
0000000000003b68 S _na_impl_release.eh
000000000000018e T _na_impl_render
0000000000003b08 S _na_impl_render.eh
U _na_impl_shared_assets_destroy
U _na_impl_shared_error
0000000000000000 T _na_impl_version
0000000000003a48 S _na_impl_version.eh
U _printf
U _putchar
U _vprintf
na_Gfx_Impl ничем не примечателен, это просто структура;и, просто повторюсь, этот код прекрасно компилируется в моей системе Ubuntu.
Я недостаточно знаю о ссылках на библиотеку osx, чтобы понять, что здесь не так, но ... это всего лишь фрагмент кода c;конечно, я делаю что-то не так, а не что-то странное с OSX.
помогите!:)
Редактировать:
Для справки, структура определена:
/** Implementation struct. */
struct na_Gfx_Impl {
/** Parent. */
struct na_Gfx *gfx;
/** SDL surface for rendering. */
SDL_Surface *screen;
/** Handler for sprites. */
struct na_utils_SetHandler *key;
/** Set of texture values. */
GLfloat *texture;
/** Set of vextex values. */
GLfloat *vertex;
};
и используется:
/** Render implementation. */
int na_impl_render(struct na_Api *api) {
struct na_Gfx_Impl *impl = (struct na_Gfx_Impl *) (api->gfx->impl);
...
Однако я сделаю выводдолжно быть плохо облажался.Нет никаких причин (насколько я понимаю), чтобы символ struct появлялся в статической lib.