Code::Blocks Forums
User forums => Help => Topic started by: 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.
I copied the cs50.h file in all directories where stdio.h was.
Pls. help.
-
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 (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.
-
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.
-
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (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.
-
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.
-
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.
-
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