Author Topic: Code:Bloks looks in a wrong directory for libraries  (Read 4474 times)

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Code:Bloks looks in a wrong directory for libraries
« on: October 23, 2020, 11:12:55 am »
Hi there,

I'm using Code:Blocks with a gtk library. I can compile some codes, and not others. I spent a while comparing the build log for those that I can compile with those that I remained unable to compile. Here is a copy of the build log for those that I failed to compile:

Code
-------------- Build: Release in event (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -o bin\Release\event.exe obj\Release\main.o  -s  -lgtk-win32-2.0 -lgobject-2.0 -lglib-2.0 "C:\Program Files (x86)\CodeBlocks\gtk\lib\pango-1.0.lib" "C:\Program Files (x86)\CodeBlocks\gtk\lib\gdk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gdk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gobject-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\pango-1.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\cairo.lib" -mwindows
mingw32-g++.exe: error: C:\Program Files (x86)\CodeBlocks\gtk\lib\pango-1.0.lib: No such file or directory
mingw32-g++.exe: error: C:\Program Files (x86)\CodeBlocks\gtk\lib\gdk-win32-2.0.lib: No such file or directory
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

The problem is simple, although I cannot solve it. For some unknown reason the compiler is looking for libraries in "C:\Program Files (x86)\CodeBlocks\gtk\lib\" and not in "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\". However, nowhere in my compiler/linker settings, I've indicated "C:\Program Files (x86)\CodeBlocks\gtk\lib\" as the place were libraries are. I've looked at:
  • Settings -> Compiler -> Linker settings.
  • Settings -> Compiler -> Search directories -> Compiler.
  • Settings -> Compiler -> Search directories -> Linker.

Where this "decision" for Code:Blocks to look for libraries into "C:\Program Files (x86)\CodeBlocks\gtk\lib\" is coming from?

Any help on this will be (more than) welcomed.

Thanks in advance & cheers, Eric.


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Code:Bloks looks in a wrong directory for libraries
« Reply #1 on: October 23, 2020, 11:34:13 am »
Look at this line after -lglib-2.0:

Code
mingw32-g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -L"C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib" -o bin\Release\event.exe obj\Release\main.o  -s  -lgtk-win32-2.0 -lgobject-2.0 -lglib-2.0 "C:\Program Files (x86)\CodeBlocks\gtk\lib\pango-1.0.lib" "C:\Program Files (x86)\CodeBlocks\gtk\lib\gdk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gtk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gdk-win32-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\gobject-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\glib-2.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\pango-1.0.lib" "C:\Program Files (x86)\CodeBlocks\MinGW\gtk\lib\cairo.lib" -mwindows

You have added those files to the project's linker build options, look at the release entry and at the root entry. The library search path (that after the -L) is duplicated, you need it only in one project entry.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Code:Bloks looks in a wrong directory for libraries
« Reply #2 on: October 23, 2020, 11:43:58 am »
Thanks,

However, I'm not sure I understand your answer.

More accurately, where, in the settings on the project, did I duplicate something? As I said, I've checked that again, in:
  • Settings -> Compiler -> Linker settings.
  • Settings -> Compiler -> Search directories -> Compiler.
  • Settings -> Compiler -> Search directories -> Linker.
And there is nothing duplicated here.

Actually, I guess I do not understand what you mean with "release entry" and "root entry". Could you please explain this a bit more?

Again, thanks for your time and patience!

Eric.


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Code:Bloks looks in a wrong directory for libraries
« Reply #3 on: October 23, 2020, 02:21:54 pm »
Usually you should not modify Settings -> Compiler -> Linker settings or the Search directories, all should be empty. It would be a good idea only if ALL your projects use the same search directories and libraries.

I'm talking about Project -> Build options. In the left side you have a tree, the root element (event?), the Release branch and (possibly) a Debug branch. All have controls similar to those in Settings -> Compiler, but these are project-specific.

When C::B builds your project it combines the settings in Settings -> Compiler with those in Project build options / event and Project build options / Release (or Debug, depending on target selection); Here is where you can get duplications or triplications. All the common search paths and libraries should go under the "event" settings and only those specific to Release should be in the Release settings.

Offline eric1708

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Code:Bloks looks in a wrong directory for libraries
« Reply #4 on: October 23, 2020, 02:32:10 pm »
Thanks Miguel,

One more, you saved me.

This was indeed the problem, and I can compile all my codes again.

I was not aware about project-specific configurations.

Thanks again for your help.

Cheers, Eric.