clang++ -Xlinker -v reports error: linker command failed with exit code 1

When running clang++ -Xlinker -v, to look to the search path for libraries I get:

@(#)PROGRAM:ld  PROJECT:ld64-409.12
BUILD 17:47:51 Sep 25 2018
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em arm64e arm64_32
Library search paths:
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Why do I get
Undefined symbols for architecture x86_64
and
 clang: error: linker command failed with exit code 1 (use -v to see invocation)
?
Last edited on
It seems you have not defined main.

If you don't want to link now, but link later, you can compile with -c.

You probably should be using something like XCode so the IDE can automatically do this for you.
Thank you for your reply. I understand command clang++ -Xlinker -v just gives directories where the compiler searches for the header files and libraries. I am not compiling any code.
Sorry I misunderstood you.

This is what you are looking for clang++ -print-search-dirs Note that -Xlinker just forwards the options to ld.exe.

On my machine -Xlinker -v doesn't tell me what the search paths are (msys2-clang).
Topic archived. No new replies allowed.