Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install/build Failed, clang: error: linker command failed with exit code 1 (use -v to see invocation) - macos #599

Closed
Xplo8E opened this issue May 20, 2024 · 5 comments

Comments

@Xplo8E
Copy link

Xplo8E commented May 20, 2024

with make

❯ make
[ "`readlink ext/frida`" = frida-macos-16.2.1 ] || \
		(cd ext && rm -f frida ; ln -fs frida-macos-16.2.1 frida)
rm -f src/_agent*
/Applications/Xcode.app/Contents/Developer/usr/bin/make src/r2frida-compile
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -g src/r2frida-compile.c -Iext/frida  \
		-I/usr/local/include/libr -L/usr/local/lib -lr_util -ldl ext/frida/libfrida-core.a -framework Foundation -lbsm -framework AppKit -lresolv \
		-DFRIDA_VERSION_STRING=\"16.2.1\" -DFRIDA_VERSION_MAJOR=16 -DR2FRIDA_VERSION_STRING=\"5.9.0\" -fPIC -Wall -Werror -g -I/usr/local/include/libr -I/usr/local/Cellar/capstone/5.0.1/include/capstone -I/usr/local/include/libr -DWANT_SESSION_DEBUGGER=1 -fPIC -g -L/usr/local/lib -L/usr/local/Cellar/capstone/5.0.1/lib -L/usr/local/lib -lr_core -lm -lcapstone -lr_config -ldl -lr_debug -ldl -lr_bin -ldl -lr_lang -ldl -lr_anal -ldl -lr_bp -ldl -lr_egg -ldl -lr_asm -ldl -lr_flag -ldl -lr_search -ldl -lr_syscall -ldl -lr_fs -ldl -lr_magic -ldl -lr_arch -ldl -lr_esil -ldl -lr_reg -ldl -lr_io -ldl -lr_socket -ldl -lr_cons -ldl -lr_crypto -ldl -lr_util -ldl -pthread -Iext/frida -o src/r2frida-compile
ld: warning: ignoring duplicate libraries: '-ldl', '-lr_util'
ld: library 'dl' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [src/r2frida-compile] Error 1
make: *** [all] Error 2

with r2pm -ci r2frida

~
❯ r2pm -ci r2frida
INFO: Cleaning r2frida
INFO: Using r2-5.9.1 and r2pm-5.9.1
INFO: Cleaning r2frida
fatal: detected dubious ownership in repository at '/Users/apple/.local/share/radare2/r2pm/git/r2frida'
To add an exception for this directory, call:

	git config --global --add safe.directory /Users/apple/.local/share/radare2/r2pm/git/r2frida
INFO: Starting install for r2frida
INFO: SCRIPT=<<EOF
INFO: 	unset CFLAGS
	unset LDFLAGS
	./configure || R2PM_FAIL "Install fail"
	if [ -n "${FRIDA_VERSION}" ]; then
		${MAKE} frida_version=${FRIDA_VERSION} || R2PM_FAIL "Build failed"
	else
		${MAKE} || R2PM_FAIL "Build failed"
	fi
	if [ "$GLOBAL" = 1 ]; then
		${R2PM_SUDO} ${MAKE} install || R2PM_FAIL "Install fail"
	else
		${MAKE} user-install R2_PLUGDIR="${R2PM_PLUGDIR}" || R2PM_FAIL "Install fail"
	fi
INFO: EOF
checking build system type... x86_64-unknown-darwin
checking host system type... x86_64-unknown-darwin
checking target system type... x86_64-unknown-darwin
checking for working directories... current
using prefix '/usr/local'
checking for pkg-config... /usr/local/bin/pkg-config
checking for c compiler... ./configure: line 360: test.c: Permission denied
no
cleaning temporally files... done
ERROR: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang cannot create executables
Install fail
[ "`readlink ext/frida`" = frida-macos-16.2.1 ] || \
		(cd ext && rm -f frida ; ln -fs frida-macos-16.2.1 frida)
rm -f src/_agent*
make src/r2frida-compile
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -g src/r2frida-compile.c -Iext/frida  \
		-I/usr/local/include/libr -L/usr/local/lib -lr_util -ldl ext/frida/libfrida-core.a -framework Foundation -lbsm -framework AppKit -lresolv \
		-DFRIDA_VERSION_STRING=\"16.2.1\" -DFRIDA_VERSION_MAJOR=16 -DR2FRIDA_VERSION_STRING=\"5.9.0\" -fPIC -Wall -Werror -g -I/usr/local/include/libr -I/usr/local/Cellar/capstone/5.0.1/include/capstone -I/usr/local/include/libr -DWANT_SESSION_DEBUGGER=1 -fPIC -g -L/usr/local/lib -L/usr/local/Cellar/capstone/5.0.1/lib -L/usr/local/lib -lr_core -lm -lcapstone -lr_config -ldl -lr_debug -ldl -lr_bin -ldl -lr_lang -ldl -lr_anal -ldl -lr_bp -ldl -lr_egg -ldl -lr_asm -ldl -lr_flag -ldl -lr_search -ldl -lr_syscall -ldl -lr_fs -ldl -lr_magic -ldl -lr_arch -ldl -lr_esil -ldl -lr_reg -ldl -lr_io -ldl -lr_socket -ldl -lr_cons -ldl -lr_crypto -ldl -lr_util -ldl -pthread -Iext/frida -o src/r2frida-compile
ld: warning: ignoring duplicate libraries: '-ldl', '-lr_util'
ld: library 'dl' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [src/r2frida-compile] Error 1
make: *** [all] Error 2
Build failed
mkdir -p /"/Users/apple/.local/share/radare2/plugins"
mkdir -p /"/Users/apple/.local/share/radare2/prefix/bin"
rm -f "//Users/apple/.local/share/radare2/plugins/io_frida.dylib"
cp -f io_frida.dylib* /"/Users/apple/.local/share/radare2/plugins"
cp: io_frida.dylib*: No such file or directory
make: *** [user-install] Error 1
Install fail

~
❯

I tried to install r2frida using both methods in my macos 14.4.1, getting these errors, radare2 up to date, frida up to date.

@trufae
Copy link
Member

trufae commented May 20, 2024

libdl is available via libSystem in the dyldcache on macOS, and it builds fine here. Is your xcode up to date? or maybe you have a different broken compiler installed from brew? Try this

1$ vim a.c
0$ gcc a.c -ldl
0$ cat a.c
int main(void){return 0;}
0$

@Xplo8E
Copy link
Author

Xplo8E commented May 20, 2024

$ gcc a.c -ldl
$ ./a.out
$ cat a.c
int main(void){return 0;}

it compiled fine.

@Xplo8E
Copy link
Author

Xplo8E commented May 20, 2024

$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang a.c -ldl
ld: library 'dl' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

but with clang

$ clang a.c -ldl

$ where clang
/usr/bin/clang

$ where gcc
/usr/bin/gcc

@Xplo8E
Copy link
Author

Xplo8E commented May 21, 2024

this issue was fixed with

export SDKROOT="`xcrun --show-sdk-path`"
Screenshot 2024-05-21 at 11 32 54 AM

@trufae
Copy link
Member

trufae commented May 21, 2024

Closing because it seems like an issue in your toolchain setup. using gcc/clang builds fine in my macOS.

Thanks for investigating and posting the solution to the issue, that may hopefully help other users if affected.

@trufae trufae closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants