Makefile - 如何修复 libc 依赖性?

发布于 2024-10-25 17:52:34 字数 2936 浏览 0 评论 0原文

我想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾忌 2024-11-01 17:52:34

使用 -pthread 而不是 -lpthread

use -pthread instead of -lpthread

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文