0
votes

I'm trying to built a c program using gcc with option -Wl,-no-pie. It failed with output as following.

# gcc -Wl,-no-pie -o test test.cpp 
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

This is test.cpp content:

#include "stdio.h"

int main()
{
        printf("hello world");
        return 0;
}

Without the option -Wl,-no-pie, it works fine. When I change the option -Wl,-no-pie to -no-pie, it alse works fine.

gcc version: gcc (GCC) 10.2.0

system: centos 3.10.107 x86_64 GNU/Linux

Why this is happening with -Wl,-no-pie, and what's the difference between -Wl,-no-pie and -no-pie? what else I can try to solve this problem ?

1

1 Answers

0
votes

The reason was ld version too low (2.23). Updated to GNU ld version 2.27-41.base.tl2.1. It works