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?

2
  • 3
    Short answer? Try using gcc -v to compile something. Long answer, read this. Mar 19, 2014 at 5:13
  • 4
    @ElliottFrisch, you can make an answer from your comment. Just explain why not use cc and ld.
    – Danatela
    Mar 19, 2014 at 5:18

0

You must log in to answer this question.

Browse other questions tagged .