LINUX.ORG.RU

статическая линковка в ghc

 , ,


0

3

Мне нужно статично слинковать прожку с библиотеками из xlib. Как это можно сделать? При компиляции с флагом -optl-static плучаю пот такую простыню:

/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(CrGlCur.o): In function `open_library':
(.text+0x33): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xim_trans.o): In function `_XimXTransSocketUNIXConnect':
(.text+0xe04): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(ClDisplay.o): In function `XCloseDisplay':
(.text+0xbd): undefined reference to `xcb_disconnect'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XCreateMutex':
(.text+0x25): undefined reference to `pthread_mutex_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XDisplayLockWait':
(.text+0x58): undefined reference to `pthread_self'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XFreeMutex':
(.text+0x9e): undefined reference to `pthread_mutex_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XFreeDisplayLock':
(.text+0xe1): undefined reference to `pthread_mutex_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XFreeDisplayLock':
(.text+0x106): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XFreeDisplayLock':
(.text+0x12c): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XFreeDisplayLock':
(.text+0x15c): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XPopReader':
(.text+0x276): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XInitDisplayLock':
(.text+0x3f2): undefined reference to `pthread_mutex_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XInitDisplayLock':
(.text+0x40b): undefined reference to `pthread_cond_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XInitDisplayLock':
(.text+0x424): undefined reference to `pthread_cond_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XCreateCVL':
(.text+0x56a): undefined reference to `pthread_cond_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XLockDisplay':
(.text+0x634): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XUserLockDisplay':
(.text+0x708): undefined reference to `pthread_self'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XInternalLockDisplay':
(.text+0x73f): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `XInitThreads':
(.text+0x7f5): undefined reference to `pthread_mutex_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `XInitThreads':
(.text+0x814): undefined reference to `pthread_mutex_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_Xthread_self':
(.text+0x31): undefined reference to `pthread_self'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XConditionBroadcast':
(.text+0x5b1): undefined reference to `pthread_cond_broadcast'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XConditionSignal':
(.text+0x5c1): undefined reference to `pthread_cond_signal'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XConditionWait':
(.text+0x5d1): undefined reference to `pthread_cond_wait'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XUnlockDisplay':
(.text+0x5f1): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XUnlockMutex':
(.text+0x60b): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(locking.o): In function `_XLockMutex':
(.text+0x61b): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(OpenDis.o): In function `OutOfMemory':
(.text+0x466): undefined reference to `xcb_disconnect'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0x829): undefined reference to `xcb_get_setup'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(OpenDis.o): In function `XOpenDisplay':
(.text+0xd6e): undefined reference to `xcb_get_maximum_request_length'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x189): undefined reference to `xcb_parse_display'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x1f0): undefined reference to `xcb_connect_to_display_with_auth_info'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x20e): undefined reference to `xcb_get_file_descriptor'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x229): undefined reference to `xcb_generate_id'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x284): undefined reference to `pthread_cond_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x29d): undefined reference to `pthread_cond_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x2a5): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_disp.o): In function `_XConnectXCB':
(.text+0x2cc): undefined reference to `xcb_connect'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `require_socket.part.0':
(.text+0x594): undefined reference to `xcb_take_socket'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `poll_for_event':
(.text+0x64e): undefined reference to `xcb_poll_for_event'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `poll_for_response':
(.text+0x769): undefined reference to `xcb_poll_for_reply'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XSend':
(.text+0xb28): undefined reference to `xcb_writev'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XReadEvents':
(.text+0xcef): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XReadEvents':
(.text+0xd7b): undefined reference to `xcb_wait_for_event'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XEventsQueued':
(.text+0xe92): undefined reference to `xcb_connection_has_error'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XAllocIDs':
(.text+0xfbc): undefined reference to `xcb_generate_id'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libX11.a(xcb_io.o): In function `_XReply':
(.text+0x1136): undefined reference to `xcb_wait_for_reply'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `init_mparams':
(.text+0x217): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `init_mparams':
(.text+0x23c): undefined reference to `pthread_mutex_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `init_mparams':
(.text+0x252): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_malloc_stats':
(.text+0x36e): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_malloc_stats':
(.text+0x4e6): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_realloc':
(.text+0x2bce): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_realloc':
(.text+0x2e2d): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_memalign':
(.text+0x2fc9): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `internal_memalign':
(.text+0x31c9): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `ialloc':
(.text+0x3389): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `ialloc':
(.text+0x34c4): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmalloc':
(.text+0x34ff): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmalloc':
(.text+0x39e4): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlfree':
(.text+0x3a41): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlfree':
(.text+0x46b1): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmalloc_trim':
(.text+0x48aa): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmalloc_trim':
(.text+0x48dc): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmmap':
(.text+0x4ee5): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/libffi.a(closures.o): In function `dlmmap':
(.text+0x4f1b): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_create.o): In function `timer_create':
(.text+0xd1): undefined reference to `pthread_once'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_create.o): In function `timer_create':
(.text+0x124): undefined reference to `pthread_attr_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_create.o): In function `timer_create':
(.text+0x16a): undefined reference to `pthread_attr_setdetachstate'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_create.o): In function `timer_create':
(.text+0x1c9): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_create.o): In function `timer_create':
(.text+0x1e9): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_delete.o): In function `timer_delete':
(.text+0x50): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_delete.o): In function `timer_delete':
(.text+0x75): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `__start_helper_thread':
(.text+0x43): undefined reference to `pthread_attr_init'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `__start_helper_thread':
(.text+0x53): undefined reference to `pthread_attr_setstacksize'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `__start_helper_thread':
(.text+0xab): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `__start_helper_thread':
(.text+0xdb): undefined reference to `pthread_attr_destroy'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `__start_helper_thread':
(.text+0xf7): undefined reference to `pthread_atfork'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `timer_helper_thread':
(.text+0x18b): undefined reference to `pthread_exit'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `timer_helper_thread':
(.text+0x19e): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `timer_helper_thread':
(.text+0x1f0): undefined reference to `pthread_create'
/usr/lib/gcc/i486-linux-gnu/4.6/../../../i386-linux-gnu/librt.a(timer_routines.o): In function `timer_helper_thread':
(.text+0x1fc): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2.o): In function `uw_init_context_1':
(.text+0x1bba): undefined reference to `pthread_once'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_bases':
(.text+0x1764): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_bases':
(.text+0x177b): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_table_bases':
(.text+0x187e): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__register_frame_info_table_bases':
(.text+0x1895): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__deregister_frame_info_bases':
(.text+0x195c): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `__deregister_frame_info_bases':
(.text+0x19cf): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `_Unwind_Find_FDE':
(.text+0x1a8a): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/i486-linux-gnu/4.6/libgcc_eh.a(unwind-dw2-fde-glibc.o): In function `_Unwind_Find_FDE':
(.text+0x1ad9): undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
компилятор ghc 7.4.1

★★★★★

Ответ на: комментарий от Aswed

это как?

Не знаю. Как оно там в ghc. Как ты с xlib линкуешься так же и с ними.
// Чтобы что-то поправить удалять тему не обязательно — есть кнопка 'Правка'. Имх, лучше haskell и ghc отдельными тегами поставить.

Bad_ptr ★★★★ ()
Ответ на: комментарий от Aswed

ну, вот так получилось: ghc -O2 -optl-lxcb -optl-lXau -optl-lXdmcp -optl-static <сырцы>. Не помогло это :(

Потому что библиотеки надо ставить после сырцов. Выросло, блин, поколение.

red_eyed_peguin ()
Ответ на: комментарий от Aswed

Компилятор выводит тоже, что я постил в самом верху. Не изменился вывод.

слушай, генери ghc objective file (maybe -c option) и собирай все это дело обычным ld

Skolotovich ★★★ ()
Ответ на: комментарий от Skolotovich
main = putStrLn "hello world"
>> ld temp.o
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094
temp.o: In function `sfD_info':
(.text+0x1f): undefined reference to `stg_CAF_BLACKHOLE_info'
temp.o: In function `sfD_info':
(.text+0x2f): undefined reference to `newCAF'
temp.o: In function `sfD_info':
(.text+0x3d): undefined reference to `stg_bh_upd_frame_info'
temp.o: In function `sfD_info':
(.text+0x48): undefined reference to `ghczmprim_GHCziCString_unpackCStringzh_closure'
temp.o: In function `sfD_info':
(.text+0x87): undefined reference to `stg_CAF_BLACKHOLE_info'
temp.o: In function `sfD_info':
(.text+0x97): undefined reference to `newCAF'
temp.o: In function `sfD_info':
(.text+0xa5): undefined reference to `stg_bh_upd_frame_info'
temp.o: In function `sfD_info':
(.text+0xb0): undefined reference to `base_SystemziIO_putStrLn_closure'
temp.o: In function `sfD_info':
(.text+0xef): undefined reference to `stg_CAF_BLACKHOLE_info'
temp.o: In function `sfD_info':
(.text+0xff): undefined reference to `newCAF'
temp.o: In function `sfD_info':
(.text+0x10d): undefined reference to `stg_bh_upd_frame_info'
temp.o: In function `sfD_info':
(.text+0x118): undefined reference to `base_GHCziTopHandler_runMainIO_closure'
temp.o: In function `sfD_info':
(.text+0x57): undefined reference to `stg_ap_n_fast'
temp.o: In function `sfD_info':
(.text+0xbf): undefined reference to `stg_ap_p_fast'
temp.o: In function `sfD_info':
(.text+0x127): undefined reference to `stg_ap_p_fast'
temp.o: In function `sfD_srt':
(.data+0x0): undefined reference to `ghczmprim_GHCziCString_unpackCStringzh_closure'
temp.o: In function `Main_main_srt':
(.data+0x14): undefined reference to `base_SystemziIO_putStrLn_closure'
temp.o: In function `ZCMain_main_srt':
(.data+0x2c): undefined reference to `base_GHCziTopHandler_runMainIO_closure'

Пробовал добавить base

ld temp.o /usr/lib/ghc/base-4.5.0.0/HSbase-4.5.0.0.o
но тогда простыня из сообщений «%позиция%: undefined reference to `%функция%'» выводится несколько минут.

Aswed ★★★★★ ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.