News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Lost functions in external header files

Started by spartarra, November 27, 2008, 12:38:27 PM

Previous topic - Next topic

spartarra

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]

Jenna

It's not enough to include the header-files, you also have to link against the appropriate library.


spartarra

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.

dje

Hi,

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

Dje

Jenna

Quote from: spartarra 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.

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.

spartarra

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.

MortenMacFly

Quote from: spartarra on November 27, 2008, 03:02:41 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

spartarra

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.


Jenna

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.