Project

General

Profile

Actions

Bug #11507

closed

clang-40 can't compile a simple C or C++ program: clang: error: linker command failed with exit code 1

Added by Vedran Miletić over 2 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
OI-Userland
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
clang

Description

int main()
{
    return 0;
}

Trying to compile gives:

$ clang example.c
ld: fatal: file crtbegin.o: open failed: No such file or directory
ld: fatal: library -lgcc: not found
ld: fatal: file crtend.o: open failed: No such file or directory
ld: fatal: file processing errors. No output written to a.out
clang: error: linker command failed with exit code 1 (use -v to see invocation)

$ clang++ example.cpp
ld: fatal: file crtbegin.o: open failed: No such file or directory
ld: fatal: library -lgcc: not found
ld: fatal: file crtend.o: open failed: No such file or directory
ld: fatal: file processing errors. No output written to a.out
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After adding -L:

$ clang -L/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4 example.c
ld: fatal: file crtbegin.o: open failed: No such file or directory
ld: fatal: file crtend.o: open failed: No such file or directory
ld: fatal: file processing errors. No output written to a.out
clang: error: linker command failed with exit code 1 (use -v to see invocation)

$ clang++ -L/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4 example.cpp
ld: fatal: file crtbegin.o: open failed: No such file or directory
ld: fatal: file crtend.o: open failed: No such file or directory
ld: fatal: file processing errors. No output written to a.out
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Actions

Also available in: Atom PDF