Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while running on Apple silicon #324

Open
forestpurnell opened this issue Mar 27, 2024 · 10 comments
Open

Issue while running on Apple silicon #324

forestpurnell opened this issue Mar 27, 2024 · 10 comments

Comments

@forestpurnell
Copy link

Hello, after an error-free compile and install, the first time I try to compile a program with the libcs50 headers, I get this error:

cc     runoff.c   -o runoff
Undefined symbols for architecture arm64:
  "_get_int", referenced from:
      _main in runoff-d112e1.o
  "_get_string", referenced from:
      _main in runoff-d112e1.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [runoff] Error 1

Is there some reason this wouldn't be able to run on an arm64 mac?

@T1To48
Copy link

T1To48 commented May 1, 2024

so simple i ran into this issue with my M2

just run the command like this
cc runoff.c -lcs50 -o runoff
because you need to link the cs50 library with the c compiler

@sufyazi
Copy link

sufyazi commented May 7, 2024

Hi I faced the same problem. Can you elaborate what runoff.c is from and what is this doing explicitly?

@sufyazi
Copy link

sufyazi commented May 7, 2024

Hi I faced the same problem. Can you elaborate what runoff.c is from and what is this doing explicitly?

Never mind, I figured it out. I just need to specify the source code file I am trying to make and the output, so in my case, it's mario.c and mario for the -o flag.

I wonder if this links the library to the compiler for all future invocations or just once and I would have to do this for every other source code files I have.

@T1To48
Copy link

T1To48 commented May 7, 2024

no it didnt link, each time i should run the command with -lcs50,
but i think if u want it to be linked permenantly something should be added to the .zshrc or .bashrc
depends on the CLI you are using..

@T1To48
Copy link

T1To48 commented May 7, 2024

Hi I faced the same problem. Can you elaborate what runoff.c is from and what is this doing explicitly?

Never mind, I figured it out. I just need to specify the source code file I am trying to make and the output, so in my case, it's mario.c and mario for the -o flag.

I wonder if this links the library to the compiler for all future invocations or just once and I would have to do this for every other source code files I have.

am at mario at the moment too!
which version R u submitting the less OR more?

@sufyazi
Copy link

sufyazi commented May 7, 2024

Hi I faced the same problem. Can you elaborate what runoff.c is from and what is this doing explicitly?

Never mind, I figured it out. I just need to specify the source code file I am trying to make and the output, so in my case, it's mario.c and mario for the -o flag.
I wonder if this links the library to the compiler for all future invocations or just once and I would have to do this for every other source code files I have.

am at mario at the moment too! which version R u submitting the less OR more?

I am still following through the Section part of Week 1, so I am not aware of or familiar with what 'less OR more' problem you are talking about, sorry.

I tried modifying my zshrc dotfile though based on the README but nothing happened; my compiler doesn't see the custom library. I had to copy and paste the .dylib file to my working directory for my code to compile.

@T1To48
Copy link

T1To48 commented May 7, 2024

try adding this :

export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH

to the .zshrc and remove what you have previously added.

@T1To48
Copy link

T1To48 commented May 7, 2024

Assuming u have installed the libcs50 in its default location and didnt use custome install location for the cs50 library

@diegovskytl
Copy link

diegovskytl commented May 11, 2024

@T1To48 @sufyazi @forestpurnell
did any change to the environment variables helped with that issue?
It seems that the default version for Make in MacOS is 3.18, a bit old. I wonder if that is part of the issue.
Edit: It seems it should not be an issue; should be solved by modifying environment.

@T1To48
Copy link

T1To48 commented May 11, 2024

@diegovskytl
mine works perfectly fine, but i dont run commands with make
i use :

cc filename.c -lcs50 -o filename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants