Author Topic: Default search directory  (Read 7603 times)

Offline J_Will

  • Single posting newcomer
  • *
  • Posts: 6
Default search directory
« on: October 16, 2023, 12:55:19 pm »
Hello,
Many tutorials describing how to link a library to a project indicate that you must specify the compiler and linker paths in the build options.
However, I note that if we do not specify these access paths and the headers and lib.a are positioned in the include and lib directories of MinGW then the program is correctly built. The question is: Where these default access paths are specified in Code::blocks ?

Thanks.

Offline Grit Clef

  • Multiple posting newcomer
  • *
  • Posts: 61
  • Where there is a will, there is a way.
Re: Default search directory
« Reply #1 on: October 16, 2023, 01:00:06 pm »
Do you mean the default headers and libraries that MinGW can read automatically? If not, then you do need to specify their paths except that you have already specified them in the search paths.
-Windows 7, 32-bit
-CodeBlocks r13490, gcc 13.2.0, debug version

Offline J_Will

  • Single posting newcomer
  • *
  • Posts: 6
Re: Default search directory
« Reply #2 on: October 16, 2023, 01:11:35 pm »
For example, when I link GLEW (for opengl) to a project:
1) I copy all the header GL/*.h in C:\Program Files (x86)\CodeBlocks\MinGW\include
2) I copy libglew.a in C:\Program Files (x86)\CodeBlocks\MinGW\lib
3) I add glew in the liker settings of the project
4) I build the project and it works fine.

I don't have to add include and lib paths in the search directories of the project.
It seems that Code::block searches in these directories by default...
 

Offline Grit Clef

  • Multiple posting newcomer
  • *
  • Posts: 61
  • Where there is a will, there is a way.
Re: Default search directory
« Reply #3 on: October 16, 2023, 03:27:02 pm »
It's not finished by CodeBlocks, because you copied those files to MinGW's include and lib directory. The compiler will search those directory by default.
-Windows 7, 32-bit
-CodeBlocks r13490, gcc 13.2.0, debug version

Offline J_Will

  • Single posting newcomer
  • *
  • Posts: 6
Re: Default search directory
« Reply #4 on: October 16, 2023, 03:40:41 pm »
Ok thank you. Thi sis due to the compiler. That means many tutorials are wrong :)

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Default search directory
« Reply #5 on: October 16, 2023, 04:33:04 pm »
No, the tutorials are right, DO NOT copy any custom files into these default compiler directories unless you are looking for BIG trouble.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Default search directory
« Reply #6 on: October 16, 2023, 08:03:41 pm »
Ok thank you. Thi sis due to the compiler. That means many tutorials are wrong :)

The tutorials that tell you to copy files into the compiler toolchain locations are likely written by newbies or idiots, sometimes both.

Unless the directions are on how to create a compiler toolchain then copying files into the toolchain folders are almost always a bad idea!

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 J_Will

  • Single posting newcomer
  • *
  • Posts: 6
Re: Default search directory
« Reply #7 on: October 19, 2023, 03:31:18 pm »
Wow don't be so vindicative both of you :)

No trouble if you copy custom files into include and lib folders of the compiler. We just have to know where the compiler is looking for those files during compilation.
But you are right, it's not very clean to do like that.

In fact I noticed that Code::blocks is delivred with a very old version of GCC (GCC8.1 !!). And with this version of GCC, we need to precise the include and lib path in the search directory otherwise it doesn't work (so the tutorials are right). But with a more recent version of GCC (I use GCC10.3) it is not necessary.

Thank you for all your replies.