Author Topic: how to add new functions to library using code::blocks  (Read 8367 times)

Offline amit14

  • Single posting newcomer
  • *
  • Posts: 8
how to add new functions to library using code::blocks
« on: December 27, 2017, 08:15:38 pm »
how do I add new functions to the standard library in code:: blocks or create my own library

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: how to add new functions to library using code::blocks
« Reply #1 on: December 27, 2017, 09:22:05 pm »
Quote
how do I add new functions to the standard library in code:: blocks
codeblocks has no standard library, codeblocks is not a compiler nor a standard library. Codeblocks is only a IDE that can use a lot compilers. And this compilers can use a lot libraries...

Quote
create my own library
what is a library in your understanding? A shared library? A static library? Only a header file? What programming language are you using? In what programming languages this library should be accessible?
What operating system are you using? What compiler are you using?

Offline amit14

  • Single posting newcomer
  • *
  • Posts: 8
Re: how to add new functions to library using code::blocks
« Reply #2 on: December 28, 2017, 06:52:37 am »
I am using c language
I read that we can add functions to the standard library so that we don't need to define them in every program
like we can add function to calculate factorial of a number to the math.h file
can't that be done in code::blocks

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: how to add new functions to library using code::blocks
« Reply #3 on: December 28, 2017, 08:37:47 am »
If you have yet to learn the answer to these questions; then, you do not know enough to do it.

What operating system (OS) are you using?
What compiler are you using?

And, if your book or teacher told you to try to add functions to the "standard" library then you should assume the book or the teacher is wrong a lot of the time.

You could create a "user" library and add functions to it safely. But, till you learn what a compiler and OS is no one can help you on creating a library.

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 amit14

  • Single posting newcomer
  • *
  • Posts: 8
Re: how to add new functions to library using code::blocks
« Reply #4 on: December 28, 2017, 08:48:39 am »
I am using Windows 7 and code blocks for writing my programs
and yes that book said to create the user library and then to add functions to it but it also said to add the function for calculating factorial in the math.h header file

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: how to add new functions to library using code::blocks
« Reply #5 on: December 28, 2017, 08:55:17 am »
So, you still need to figure out your compiler name and and version.

Do you know how to create a multiple c file program?

Because, you could be confusing that with creating using a "user" library.

A beginner will normally learn to create multiple c file program; before trying to create a "user" library.

And, the first "user" library is normally a static "user" library or a header only library.

Post a build log; so, I can guess what compiler you are using.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.

« Last Edit: December 28, 2017, 11:14:43 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 amit14

  • Single posting newcomer
  • *
  • Posts: 8
Re: how to add new functions to library using code::blocks
« Reply #6 on: December 28, 2017, 06:21:18 pm »
It is GNU GCC compiler

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: how to add new functions to library using code::blocks
« Reply #7 on: December 28, 2017, 07:18:20 pm »
Do you know how to create a multiple c file program?
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 amit14

  • Single posting newcomer
  • *
  • Posts: 8
Re: how to add new functions to library using code::blocks
« Reply #8 on: December 31, 2017, 07:58:30 pm »
well, not still
till now I have learnt till strings and structure data types
I have one more question, how do I use the functions for creating boxes on the screen
well I read a program for it which contained a file named goto.c and has functions like gotorc( r,c) and so on
but when I compile it, it says goto.c file doesn't exist
I am using c language and GNU GCC compiler and I am making the program on console application
should I change the compiler I am using or should I change the project like using some other project like there are AVM project etc. any of them
please explain
« Last Edit: January 01, 2018, 12:28:44 pm by amit14 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: how to add new functions to library using code::blocks
« Reply #9 on: January 04, 2018, 02:50:23 pm »
Quote
but when I compile it, it says goto.c file doesn't exist
post a full build log. From the build log tab as described here:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
You have to add the goto.c file to your project so codeblocks can find it. Project->Add file

Quote
I have one more question, how do I use the functions for creating boxes on the screen
well I read a program for it which contained a file named goto.c and has functions like gotorc( r,c) and so on
i don't think that drawing boxes is easily possible on modern windows machines.

Quote
should I change the compiler I am using or should I change the project like using some other project like there are AVM project etc.
You are good to go with the gcc  it is quite standard compatible and ok fast. What is AVM? If you change the compiler as soon as you hit problems you will gonna run out of compilers quite fast. The compiler is never (or at least at your level) a problem, but always the user. And a other compiler won't fix this.
The problem with beginner like you is we don't know how to help you unless you learn the right wording. You talk about libraries but mean only additional c files. You talk about the standard library and you even don't know what the std library is... If we read your post we think over complicated and begin with complex concepts and this will intimidate you even more...
So to create a library like i think you mean (aka using multiple c files) you simply add the second c file to the project. Or even more simply you go to File->New->File..-> select source or header file->Go->Next->select "C"->Next->Press "..." and select the save folder for the file. It is convenient if the file is in the same folder as the project, select "All" targets->Finish
Now you can enter the code in this file. You will need a c and a h file to be able to move your function to the new source file. You define the function in the c file and declare the function in the header file. Then you have to include this header file in your main c file. But this is out of scope of this forum. We help you by doing this steps with codeblocks. If you have a compiling problem please post the build log as described in the top link.