Makefile - 如何修复 libc 依赖性?
我想将 Tk 静态链接到我的代码中。由于依赖性,我遇到了麻烦。我对 Makefile 所做的修改是:
TK_LIBS_64 = \
-L/usr/X11R6/lib64 \
-lX11 \
-lXss \
-lXext \
-L/usr/X11R6/lib64 \
-lXft \
-lX11 \
-lfontconfig \
-lfreetype \
-lxmlparse \
-lexpat \
-L/usr/X11R6/lib64 \
-lXrender \
-lpthread \
-ldl \
-lpthread \
-lieee \
-lm
LIBS64 = \
-L$(TCL_ROOT)/lib/ -ltk8.5 \
$(TK_LIBS_64)
编译时出现以下错误:
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x7f): In function `__pthread_initialize_minimal':
: undefined reference to `__libc_setup_tls'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x86): In function `__pthread_initialize_minimal':
: undefined reference to `_dl_cpuclock_offset'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0xc0): In function `__pthread_initialize_minimal':
: undefined reference to `_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0xcb): In function `__pthread_initialize_minimal':
: undefined reference to `_h_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x289): In function `pthread_initialize':
: undefined reference to `_res'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x3cc): In function `pthread_initialize':
: undefined reference to `_dl_init_static_tls'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x947): In function `__pthread_reset_main_thread':
: undefined reference to `_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x955): In function `__pthread_reset_main_thread':
: undefined reference to `_h_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x963): In function `__pthread_reset_main_thread':
: undefined reference to `_res'
/usr/lib/../lib64/libpthread.a(ptw-write.o)(.text+0x1a): In function `write':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-write.o)(.text+0x72): In function `write':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-read.o)(.text+0x1a): In function `read':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-read.o)(.text+0x72): In function `read':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-close.o)(.text+0x1a): In function `close':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-close.o)(.text+0x5e): more undefined references to `__syscall_error' follow
/usr/lib/../lib64/libdl.a(dlopen.o)(.text+0x5): In function `dlopen':
: undefined reference to `__dlopen'
/usr/lib/../lib64/libdl.a(dlsym.o)(.text+0x5): In function `dlsym':
: undefined reference to `__dlsym'
/usr/lib/../lib64/libdl.a(dlerror.o)(.text+0x1): In function `dlerror':
: undefined reference to `__dlerror'
collect2: ld returned 1 exit status
*** Error code 1
dmake: Fatal error: Command failed for target
未定义的引用位于 libc.a 或 libc_p.a 中,将它们添加到依赖项中没有帮助。由于未定义的引用是系统调用,我想我在这里遗漏了一些基本的东西。如果有人能指出错误,我将不胜感激。
I want to statically link Tk into my code. I am running into trouble due to dependencies. The modification I made to my Makefile is:
TK_LIBS_64 = \
-L/usr/X11R6/lib64 \
-lX11 \
-lXss \
-lXext \
-L/usr/X11R6/lib64 \
-lXft \
-lX11 \
-lfontconfig \
-lfreetype \
-lxmlparse \
-lexpat \
-L/usr/X11R6/lib64 \
-lXrender \
-lpthread \
-ldl \
-lpthread \
-lieee \
-lm
LIBS64 = \
-L$(TCL_ROOT)/lib/ -ltk8.5 \
$(TK_LIBS_64)
I get the following error on compilation:
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x7f): In function `__pthread_initialize_minimal':
: undefined reference to `__libc_setup_tls'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x86): In function `__pthread_initialize_minimal':
: undefined reference to `_dl_cpuclock_offset'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0xc0): In function `__pthread_initialize_minimal':
: undefined reference to `_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0xcb): In function `__pthread_initialize_minimal':
: undefined reference to `_h_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x289): In function `pthread_initialize':
: undefined reference to `_res'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x3cc): In function `pthread_initialize':
: undefined reference to `_dl_init_static_tls'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x947): In function `__pthread_reset_main_thread':
: undefined reference to `_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x955): In function `__pthread_reset_main_thread':
: undefined reference to `_h_errno'
/usr/lib/../lib64/libpthread.a(pthread.o)(.text+0x963): In function `__pthread_reset_main_thread':
: undefined reference to `_res'
/usr/lib/../lib64/libpthread.a(ptw-write.o)(.text+0x1a): In function `write':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-write.o)(.text+0x72): In function `write':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-read.o)(.text+0x1a): In function `read':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-read.o)(.text+0x72): In function `read':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-close.o)(.text+0x1a): In function `close':
: undefined reference to `__syscall_error'
/usr/lib/../lib64/libpthread.a(ptw-close.o)(.text+0x5e): more undefined references to `__syscall_error' follow
/usr/lib/../lib64/libdl.a(dlopen.o)(.text+0x5): In function `dlopen':
: undefined reference to `__dlopen'
/usr/lib/../lib64/libdl.a(dlsym.o)(.text+0x5): In function `dlsym':
: undefined reference to `__dlsym'
/usr/lib/../lib64/libdl.a(dlerror.o)(.text+0x1): In function `dlerror':
: undefined reference to `__dlerror'
collect2: ld returned 1 exit status
*** Error code 1
dmake: Fatal error: Command failed for target
The undefined references are either in libc.a or libc_p.a and adding them to the dependencies does not help. Since the undefined references are system calls I think I am missing something basic here. I would be obliged if someone can point out the mistake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 -pthread 而不是 -lpthread
use -pthread instead of -lpthread