You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

M1 Mac下TextMate编译GSL库遇架构兼容问题,求通用解决方案

M1 Mac下TextMate中使用GSL库的编译兼容问题

环境与问题概述

使用M1 Mac(系统版本Ventura 13.0.1),希望在TextMate中结合GNU Scientific Library(GSL)开发,GSL安装路径为/usr/local/include/gsl。测试代码通过macOS终端、VS Code内置终端编译运行均正常,但使用TextMate的MakeFile Bundle编译时出现架构不兼容错误。

测试代码

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
  double x = 5.0;
  double y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}

原MakeFile配置

CC = gcc
EXEC = PROG
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)
CFLAGS = -g -Wall

LIBS = -lm -lgsl -lgslcblas -I/usr/local/include/gsl
RM = rm -rf


all : $(EXEC)

%.o : %.c 
    $(CC) -o $@ -c $<
    
$(EXEC) : $(OBJ)
    $(CC) $(CFLAGS) -o $@ $^ $(LIBS) && time ./$(EXEC) && make clean


.PHONY : clean

clean :
    rm -rf $(EXEC) && rm -rf *.o

TextMate编译错误信息

ld: warning: ignoring file /usr/local/lib/libgslcblas.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

...

Undefined symbols for architecture x86_64:

...

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [PROG] Error 1

尝试修复后的反向问题

曾尝试重新编译GSL库,指定架构为x86_64:

./configure CC="gcc -arch x86_64"
make
# 后续安装步骤

修改后TextMate可正常编译,但终端编译时出现反向架构不兼容错误:

ignoring file /usr/local/lib/libgsl.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
...
Undefined symbols for architecture arm64:
...
ld: symbol(s) not found for architecture arm64

需求

寻求可同时兼容TextMate(x86_64架构)和终端(arm64架构)的解决方案,可修改MakeFile或TextMate应用设置。


内容的提问来源于stack exchange,提问作者Corpitou

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 01:15:56