0

I am getting a error when trying to compile the first code in c from cs50

    #include <stdio.h>

    int main(void)
   {
     printf("hello, world\n");
   }

Error:

~/workspace/ $ clang hello.c

/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
~/workspace/ $ 

It looks like the libraries aren't connecting. The file is saved in the right folder as well. My only hint so far is that I am not connected to the cloud server properly.

My wifi is working and I also installed the update(update50).

any suggestions? Thanks.

7
  • Did you try to compile with make or clang? Exactly what is the command that you used to start the compile process? I am assuming that you are trying to compile hello.c. What is the directory that hello.c is in? Were you in the same directory when you tried to compile? – Cliff B Jul 29 '18 at 19:58
  • Usually, I see these errors because there's no main in the program. Are you sure that you don't have a typo in the code? – Cliff B Jul 29 '18 at 20:21
  • See the code above. I have no syntax errors and my main method is included. There is only one directory that has been made so far, the default workspace. I compiled using clang. I have also tried including the cs50 package and compiling with 'make' but I get the same error. – bluesky11 Jul 29 '18 at 20:25
  • Since you're online, if you would like to share your IDE with me (cliffb1), I can take a look at it. You can cancel sharing after we're done. Click the share button in the upper right corner of the IDE and let me know. – Cliff B Jul 29 '18 at 20:29
  • When I open the cs50 IDE tab in the IDE and open the web server page I see 'Cloud9 can't get you to your requested workspace.' i wonder if this has something to do with the error. – bluesky11 Jul 29 '18 at 20:29
1

Turned out to (possibly) be a glitch in the IDE. For whatever reason, the file didn't save, so there was no main function - in fact, no code at all.

Whatever the cause, it's fixed.

If this answers your question, please click on the check mark to accept so that this doesn't sit in the unanswered question pool forever. Let's keep up on forum maintenance. ;-)

1
  • NOTE TO ALL: When you save a file, make sure the red dot in the tab turns green to assure that your file is saved! – Cliff B Jul 29 '18 at 20:54
0

Try running the following commands in order: mkdir ~/workspace/pset1/hello cd ~/workspace/pset1/hello make hello ./hello

1
  • mkdir ~/workspace/pset1/hello cd mkdir: cannot create directory ‘/home/ubuntu/workspace/pset1/hello’: No such file or directory mkdir: cannot create directory ‘cd’: File exists – bluesky11 Jul 29 '18 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .