libcs50 icon indicating copy to clipboard operation
libcs50 copied to clipboard

Compile and use libcs50 on Windows

Open dEhiN opened this issue 5 years ago • 13 comments

Could you add steps in the Readme for compiling and using libcs50 on Windows? I'm running Windows 10 and using VS Code with the MinGW gcc compiler. I have Debian set up using WSL, so I know that I could follow the steps for compiling libcs50 using the WSL enviroment. But I'm pretty sure that would just allow me to use libcs50 in the WSL Debian enviroment. I also know that VS Code has a Remote-WSL extension, but do I really need to always go through a *nix environment just to utilize libcs50? Is there a way to compile and use libcs50 natively on Windows? Thanks.

dEhiN avatar Jan 18 '20 07:01 dEhiN

I'd like to use windows without the linux subsystem. I have some background in programming so i use visual studio to debug some C code. Visual studio has a lot of tools to debug a C program. I can view the assembler code that the compiler generates, the memory in realtime, stacktrace, variable inspector, inmediate commands (like an repl for c), the ability to set breakpoints...

Here is the debbuging session of a problem in cs50 that im trying to resolve, but i cant use cs50 lib, i have to fallback to stdlib functions:

image

Is there a way to get these tools in Cloud9 Ide or linux?

uselessscat avatar Sep 13 '20 02:09 uselessscat

@uselessscat , one way, I think, is to go into the settings for the project you made for your C program, and link the two files in the linking option somewhere. I remember I did something similar with an assembly library an year ago. Basically, all it would do is go through the files you linked and configure itself accordingly.

Rubix982 avatar Sep 15 '20 06:09 Rubix982

https://github.com/cs50/libcs50/issues/189#issuecomment-737173845

My full solution for VSCode on Windows. Step by step inside.

On Windows to run it is not easy, I figure it out till today.

In fact, compiling many files together is a must-master skill, however, that is advanced for beginners. And it is hard to be set in VSCode too. Documents and discussions are limited.

But when you step into the code world, you will generally understand something. Welcome to the world!

timeneverdie avatar Dec 02 '20 13:12 timeneverdie

hi ,i would like to work on this issue ca you suggest me ways to get started ?

mohitk30 avatar Mar 05 '21 15:03 mohitk30

Hi, @mohitk30 . Please look into topics for C/C++ such as,

I think it's better you use WSL at the moment, but if you would like to, then please take a look at the below topics,

  1. Linking
  2. Building with multiple *.c/cpp files
  3. Integrating with a Windows IDE or Text Editor, i.e., Notepad++, Visual Studio, Visual Studio Code ..., etc, to serve as a guide for new servers that happen to stumble upon this issue

In general, see what it takes to compile multiple sources and header files together in Windows, and how you can write or prepare a step-by-step guide for folks who might want to try it out as well.

Good luck!

Rubix982 avatar Mar 05 '21 17:03 Rubix982

  1. Download cs50.c and cs50.h from https://github.com/cs50/libcs50/tree/main/src
  2. Import both files to your compiler (eg. CodeBlock)
  3. Build a static library (libcs50.a) (It should be located in .\obj )
  4. Import cs50.h and libcs50.a to your new project.
  5. In the setting, link both the library and header files.
  6. You are good to go.

1 2 3

ugyen-chophel avatar Aug 27 '21 11:08 ugyen-chophel

Personally, I'll advise you to take @timeneverdie's solution.

I also made some modifications to it too.

MADEPADIO avatar Dec 05 '21 23:12 MADEPADIO

Personally, I'll advise you to take @timeneverdie's solution.

I also made some modifications to it too.

My reason for saying this is because as difficult as it may seem, every programming language must be able to function properly using the various terminals for the various OSs before IDEs are talked about.

Although you can go for what will be a lot more conducive

MADEPADIO avatar Dec 05 '21 23:12 MADEPADIO

hi, so, i have shared my solution in the link given below. It does NOT depend on any used IDE, so, can be used with any editor. See if it helps or not.

https://stackoverflow.com/a/70296780/8395964

goyalyashpal avatar Dec 13 '21 20:12 goyalyashpal

Hi, I just went through your solution and I was impressed plus I appreciate the fact that you also reached out to me.

Sadly, I haven't been written my own story of how I was able to fix mine but I'll email you as soon as I do. But to be clear, I have a working libcs50, and it works on PowerShell and cmd so far. Plus, it also works on Vscode and I must say, I dread going through the process again because it's only fun when you get it right. 😅 I promise to email you the link when I post the procedures I took and I'll also share your link for others that want to try.

On Mon, Dec 13, 2021 at 9:21 PM yashpalgoyal1304 @.***> wrote:

hi, so, i have shared my solution in the link given below. It does NOT depend on any used IDE, so, can be used with any editor. See if it helps or not.

https://stackoverflow.com/a/70296780/8395964

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cs50/libcs50/issues/193#issuecomment-992856890, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXYMFBY3KJE5MMLY7ER6ZDUQZIUJANCNFSM4KIRPJFQ .

MADEPADIO avatar Jan 03 '22 01:01 MADEPADIO

I forgot to add: Could you please add a new comment under your solution, explaining and narrating each step taken to solve this issue? Please do not take it the wrong way, I'm only requesting you simplify it for other readers.

Thank you.

On Mon, Jan 3, 2022 at 2:42 AM MADE PADIO @.***> wrote:

Hi, I just went through your solution and I was impressed plus I appreciate the fact that you also reached out to me.

Sadly, I haven't been written my own story of how I was able to fix mine but I'll email you as soon as I do. But to be clear, I have a working libcs50, and it works on PowerShell and cmd so far. Plus, it also works on Vscode and I must say, I dread going through the process again because it's only fun when you get it right. 😅 I promise to email you the link when I post the procedures I took and I'll also share your link for others that want to try.

On Mon, Dec 13, 2021 at 9:21 PM yashpalgoyal1304 @.***> wrote:

hi, so, i have shared my solution in the link given below. It does NOT depend on any used IDE, so, can be used with any editor. See if it helps or not.

https://stackoverflow.com/a/70296780/8395964

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cs50/libcs50/issues/193#issuecomment-992856890, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXYMFBY3KJE5MMLY7ER6ZDUQZIUJANCNFSM4KIRPJFQ .

MADEPADIO avatar Jan 03 '22 01:01 MADEPADIO

hi, thanks for appreciations

add a new comment under your solution, explaining and narrating each step taken to solve this issue

as much as i'd like to explain what each step means, bt i cant. as:

  1. the answer in its current state as of now is already so long as it is, and adding more verbosity will only add length to it and many will not read that then,
  2. most all the details i ommitted are given in the resources i linked, or the previous answers there

goyalyashpal avatar Jan 29 '22 19:01 goyalyashpal