Author Topic: Lost functions in external header files  (Read 5843 times)

Offline spartarra

  • Single posting newcomer
  • *
  • Posts: 6
Lost functions in external header files
« on: November 27, 2008, 12:38:27 pm »
Good morning everyone,

Problem: Configuration of Code::Blocks 8.02 when it has to find functions from other files.

Situation: When I try to compile the attached .c code telling the compiler to look in the include file directory, the compiler says : undefined reference to '<function>'. This function has been included in the include part.

So there has to be a way of telling the compiler to tell him to look not only if the files exist, to check the functions.

Thanks in advance,

Spartarra

[attachment deleted by admin]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Lost functions in external header files
« Reply #1 on: November 27, 2008, 12:58:30 pm »
It's not enough to include the header-files, you also have to link against the appropriate library.


Offline spartarra

  • Single posting newcomer
  • *
  • Posts: 6
Re: Lost functions in external header files
« Reply #2 on: November 27, 2008, 02:33:42 pm »
Project - Build options...
I select top level (debug and release at the same time)- Search directories and in Compiler and Linker boxes I add the directory.
It is not still working.

Offline dje

  • Lives here!
  • ****
  • Posts: 682
Re: Lost functions in external header files
« Reply #3 on: November 27, 2008, 02:44:56 pm »
Hi,

You have set where to search for libs.
Now you have to specify libs you are using on the linker tab.

Dje

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Lost functions in external header files
« Reply #4 on: November 27, 2008, 02:52:32 pm »
Project - Build options...
I select top level (debug and release at the same time)- Search directories and in Compiler and Linker boxes I add the directory.
It is not still working.

Which directory ?
The directory with the header files ?

If you want to use external functions, you need either the source files or a compiled library.
Header files are not enough.

Please have in mind, that this forum is for C::B related questions only, not a forum to teach the basics of programming.

Offline spartarra

  • Single posting newcomer
  • *
  • Posts: 6
Re: Lost functions in external header files
« Reply #5 on: November 27, 2008, 03:02:41 pm »
Errors have changed.
Now looks like the .c is linked with the .h files (so the previous error of not finding .h is over), but when the .h want to comunicate with each other the don't see each other.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Lost functions in external header files
« Reply #6 on: November 27, 2008, 04:47:07 pm »
Now looks like the .c is linked with the .h files
[...]
but when the .h want to comunicate with each other the don't see each other.
Oh well... Header files are not linked and they do not communicate with each other. What is actually your problem? I don't understand a single word from what you say. Probably you don't understand the functionality of a compiler/linker and/or include file/library?

If so, than (sorry for that) but this is extremely out of scope of this forum. We discuss here about Code::Blocks, not general programming. Please rephrase what issues you have with Code::Blocks.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline spartarra

  • Single posting newcomer
  • *
  • Posts: 6
Re: Lost functions in external header files
« Reply #7 on: November 27, 2008, 05:01:26 pm »
How do you say to Code::Blocks:  Find all the needed functions in the header files (this ones have been indicated by the Project - Build options... - Search directories).

Thanks in advance.

PS: If you feel that this is not a doubt of Code::Block don't answer the post; I'll try to find the answer in another place.


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Lost functions in external header files
« Reply #8 on: November 27, 2008, 05:22:21 pm »
In most cases there are no functions inside header-files, only declarations of them.

Splitting declarations and implementations is widely used in many programming languages.

If you don't know the difference, you should read a good C/C++ tutorial.

And if there will still be problems (  :!: that are really related to C::B and not to your lack of knowledge of basic programming  :!: ) feel free to ask again.