gpt4 book ai didi

c - Mac 上架构 x86_64 错误的 undefined symbol

转载 作者:太空宇宙 更新时间:2023-11-03 23:59:54 27 4
gpt4 key购买 nike

我正在尝试通过我的个人 Mac 笔记本电脑为学校开展一个项目,我通常在连接学校计算机时使用 Putty 连接到他们的网络。但是,我现在不在他们的网络上,需要处理这个项目。他们提供了 makefile 和 .h 文件,因此它们是正确的,并且所有内容都在他们的机器上编译,但是当我拉到我的 mac 上并尝试运行 makefile 时,我得到了这个错误:

gcc -o test -g main.o linked_list_functions.o unit_tests.o

Undefined symbols for architecture x86_64:
"_malloc_options", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test] Error 1

在 Windows 机器上工作,但不在我的机器上工作,所以我假设我没有下载任何东西。我通过自制软件更新了 GCC、GDB、gperf,但我仍然遇到这些错误。

编辑调用文件的源代码:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unit_tests.h"

extern char *malloc_options ; // Keep this line. Do not change it.

// Run the unit tests or as a "normal program".
// You can run this as a "normal program" if you want for a simple test of the $
int main( int argc, char *argv[] )
{
malloc_options = "CFGSU" ; // Keep this line. Do not chang$

test() ;

return 0 ;
}

最佳答案

它没有在 OSX 中实现。 (抱歉简短而无聊的回答)

FreeBSD 联机帮助页包括malloc_options 但在 OSX 中它不是。因此链接器正确地失败了,因为它找不到您试图从外部引用的符号。

OSX 概要 ->

SYNOPSIS
#include <stdlib.h>

void *
calloc(size_t count, size_t size);

void
free(void *ptr);

void *
malloc(size_t size);

void *
realloc(void *ptr, size_t size);

void *
reallocf(void *ptr, size_t size);

void *
valloc(size_t size);

FreeBSD 概要 ->

SYNOPSIS
#include <stdlib.h>

void *
malloc(size_t size);

void *
calloc(size_t number, size_t size);

void *
realloc(void *ptr, size_t size);

void *
reallocf(void *ptr, size_t size);

void
free(void *ptr);

char * malloc_options;

/一个

关于c - Mac 上架构 x86_64 错误的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49241610/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com