Author Topic: compiler error = ld.exe....cannot find -lcs50  (Read 7600 times)

Offline wanriz

  • Single posting newcomer
  • *
  • Posts: 3
compiler error = ld.exe....cannot find -lcs50
« on: February 18, 2014, 05:21:52 pm »
Hi, I'm new to both C language and Code::Blocks.

I'm getting error while trying to compile a file. The option I'm using to compile is as under:

    mingw32-gcc -ggdb3 -O0 -std=c99 -Wall -Werror <file_name> -lcs50 -lm -o <file_name>

However, I get error returned: ld.exe..........cannot find -lcs50.

I copied the cs50.h file in all directories where stdio.h was.

Pls. help.



Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #1 on: February 18, 2014, 05:34:01 pm »
Hi, I'm new to both C language and Code::Blocks.

I'm getting error while trying to compile a file. The option I'm using to compile is as under:

    mingw32-gcc -ggdb3 -O0 -std=c99 -Wall -Werror <file_name> -lcs50 -lm -o <file_name>

However, I get error returned: ld.exe..........cannot find -lcs50.

Till you learn what a compiler is and does copying file into the compiler folder is NOT something you should do!

I copied the cs50.h file in all directories where stdio.h was.

Please read this FAQ; I strongly suggest following the "For your project :" section of the FAQ.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline wanriz

  • Single posting newcomer
  • *
  • Posts: 3
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #2 on: February 18, 2014, 06:18:54 pm »
Hi Tim, and thanks for the tip.

I incorporated the directory as per the guide. but still get the same error. do I need to copy the header file to some where else or I'm not using the proper option to compile.

thanks & advance.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #3 on: February 18, 2014, 07:01:28 pm »
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Post the "build log" after doing a re-build.
And, Post the path to the library and the library filename.

Do you have an cs50.c or a cs50.a file?

Tim S.
« Last Edit: February 19, 2014, 01:50:17 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline wanriz

  • Single posting newcomer
  • *
  • Posts: 3
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #4 on: February 19, 2014, 05:20:34 pm »
library name: cs50.h

library path: C:\Program Files\CodeBlocks\MinGW\include

Build logs:
----------------
mingw32-gcc.exe -ggdb3 -O0 -std=c99 -Wall -Werror -IC:\Users\riz1\Dropbox -c C:\Users\riz1\Dropbox\CS50\pset2\initials.c -o C:\Users\riz1\Dropbox\CS50\pset2\initials.o
mingw32-g++.exe -LC:\Users\riz1\Dropbox -L"C:\Program Files\CodeBlocks\MinGW\bin" -L"C:\Program Files\CodeBlocks\MinGW\include" -L"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.7.1\include" -o C:\Users\riz1\Dropbox\CS50\pset2\initials.exe C:\Users\riz1\Dropbox\CS50\pset2\initials.o   
C:\Users\riz1\Dropbox\CS50\pset2\initials.o: In function `main':
C:/Users/riz1/Dropbox/CS50/pset2/initials.c:8: undefined reference to `GetString'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
1 error(s), 0 warning(s) (0 minute(s), 1 second(s))
 
-------------------------

Thanks for the help.


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #5 on: February 19, 2014, 07:19:18 pm »
You need to learn what a library is!

Files ending in .h are header files.

I suggest asking you question on a site that supports cs50 and your compiler!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: compiler error = ld.exe....cannot find -lcs50
« Reply #6 on: February 19, 2014, 07:31:48 pm »
i recommend reading the page where you downloaded the "library". There is a nice description how do do it...
and read also this:
http://wiki.codeblocks.org/index.php?title=Creating_a_new_project#Changing_file_composition