0

I am working on an assignment for my System Programming course which is a course using the linux terminal and C language. I own a mac and already require a windows VM for my other courses so I have no room for the linux machine and my professor said that my mac machine would work fine as it has the linux terminal.

We have to create a makefile file that will compile and link the c project together and create a .bin file, which is the basis of programming C in a linux environment, but I am getting errors with my makefile.

I believe it has to do with the difference between Linux and MacOS but I am not sure.

My makefile is as follows:

./bin/cryptoMagic: ./obj/main.o
cc ./obj/main.o -o ./bin/cryptoMagic

./obj/main.o: ./src/main.c ./inc/prototypes.h
cc ./src/main.c -c -o ./obj/main.o

When I run the make utility in the terminal I get this error message:

kyles-MacBook-Pro:~ KyleJensen$ cd Documents/School/First\     Year/Semester2/SystemProgramming/Assignments/Assign01/
kyles-MacBook-Pro:Assign01 KyleJensen$ make
cc ./obj/main.o -o ./bin/cryptoMagic
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)
make: *** [bin/cryptoMagic] Error 1
4
  • It does not look like a Linux/Mac issue. At least you need to recompile main.c first. Review the documentation for cc. Commented Jan 6, 2016 at 17:10
  • 1
    Have you got bin, obj, inc and src subdirectories? Does your main.c contain a main(int argc,char*argv[]) function? Can you add -I inc to tell the compiler where your include files are? Commented Jan 6, 2016 at 17:13
  • smell like there is no 'main' entry point in main.c - can we see it please Commented Jan 6, 2016 at 17:15
  • Wow I'm retarted. Thanks for pointing out my silly mistake I hadn't written anything in the C file LOL. Commented Jan 6, 2016 at 17:17

1 Answer 1

1

Silly me. I didn't have a valid main function in my C file. Watch out for this one in the future kids!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.