4

I am learning about compiler linker and loader and was trying to understand the working of linker and loader on my ubuntu 12.04 machine

I wrote 2 simple ".c" files as follows

test.c

#include<stdio.h>
int main(int argc, char **argv)
{
  printf("%d",test_fun(10));
}

test2.c

#include<stdio.h>
int test_fun(int a)
{
  return a*10;
}

Then I executed following commands

cc -c test.c

cc -c test2.c

ld test.o test2.o -o a.out -lc --entry main

Now in my current directory a.out file is generated. I can see the file when I type ls but when I try to run the file as

./a.out

I get error

bash: ./a.out: No such file or directory

What am I doing wrong? Please help me?

Danatela
  • 13,384
Null pointer
  • 2,607

0 Answers0