Author Topic: Where to put Source Code Files and Header Files in Code::Blocks?  (Read 6296 times)

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
I'm a little confused on something.
If I am including some  files into my C++ project that I want to statically link to my project and I have a Header file .h and a Source Code file .cpp then from what I understand from another post I found on another forum I can navigate to the header file via:
Project > Build Options > Search Directories > .... Then the directory containing the header file is placed under 'Linker' and from what I understand the lib file directory is placed under 'Compiler' .  Is the .lib file the same as a .cpp file containing the source code or is it something else.  If it is something else where does the .cpp file go?   

Thanks

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: Where to put Source Code Files and Header Files in Code::Blocks?
« Reply #1 on: October 05, 2012, 11:24:09 pm »
hmmm,

The headerfile holds the declaration, so it goes into the compiler praeprocessor path. The sourcefile holds the definition, so it has to compile to an object file and this object file can be collected into a library and this library goes into the linker path.


Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Where to put Source Code Files and Header Files in Code::Blocks?
« Reply #2 on: October 06, 2012, 03:27:16 am »
Good simple answer.  Excellent explanation too.
Thanks very much.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Where to put Source Code Files and Header Files in Code::Blocks?
« Reply #3 on: October 06, 2012, 07:17:33 am »
Is the .lib file the same as a .cpp file containing the source code or is it something else.  If it is something else where does the .cpp file go?   
No. Source file are text based files, libs are binary files. Source code usually has an extension like *.cpp, *.h while a static lib usually (!) has *.lib or *.a.

Contact the author of that lib to provide you with the required files or (only in case the *.cpp file is the source code of that lib) compile it yourself before linking to it.

Note that you really should better ask the author of the lib rather that the authors off Code::Blocks what to do. We cannot provide support for things we don't know.
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