小编Pon*_*röm的帖子

在mac上,默认情况下,g ++(clang)无法搜索/ usr/local/include和/ usr/local/lib

我在Mac上,我曾经homebrew安装过gmp.

Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx
In file included from main.cpp:2:
./gcjlib.hpp:4:10: fatal error: 'gmpxx.h' file not found
#include <gmpxx.h>
         ^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

所以我明确告诉g++要使用/usr/local/include

Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx -I/usr/local/include
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

所以我明确告诉g++要使用/usr/local/lib

Kyumins-iMac:gcjlib math4tots$ g++ main.cpp -lgmp -lgmpxx -I/usr/local/include -L/usr/local/lib
Kyumins-iMac:gcjlib math4tots$ ./a.out 
sum is -4444
absolute value …
Run Code Online (Sandbox Code Playgroud)

macos xcode gcc clang

41
推荐指数
3
解决办法
2万
查看次数

标签 统计

clang ×1

gcc ×1

macos ×1

xcode ×1