User forums > Help
compiler error = ld.exe....cannot find -lcs50
wanriz:
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.
stahta01:
--- Quote from: wanriz 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.
--- End quote ---
Till you learn what a compiler is and does copying file into the compiler folder is NOT something you should do!
--- Quote from: wanriz on February 18, 2014, 05:21:52 pm ---I copied the cs50.h file in all directories where stdio.h was.
--- End quote ---
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.
wanriz:
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.
stahta01:
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.
wanriz:
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.
Navigation
[0] Message Index
[#] Next page
Go to full version