Kanan
Kanan

Reputation: 142

Cannot find -l<library> in Code::Blocks Ubuntu

I'm trying to create a window using GLFW on Ubuntu. I downloaded GLFW through an apt-get command and added it in Build Options -> Linker Settings. However, when I try compiling the program it gives me an error saying

ld cannot find -lGLFW

I've searched the internet and I couldn't find what to do when this happens in Code::Blocks. What can I do to fix this problem?

I've read something like I need to add some options, but I don't know which ones and where exactly.

Note: I'm using GCC

Upvotes: 1

Views: 2476

Answers (3)

Mike Kinghan
Mike Kinghan

Reputation: 61337

The effect of your solution, adding glfw to the Link libraries in Global compiler settings is that libglfw will be added to the linkage of every project that your build with that compiler (presumably GCC).

This is quite unnecessary. Simply do the same thing in your project's Build options instead:-

  • From the Workspace tree-view, navigate: -> Build options -> {Debug|Release} -> Linker settings -> Link libraries

  • Enter glfw

  • OK out

  • Rebuild

Upvotes: 0

Kanan
Kanan

Reputation: 142

Okay, I fixed my problem.

This is so weird. Thanks to genpfault answer I found out that my libglfw.so file is in /usr/lib/x86_64-linux-gnu directory.

Everything worked after I deleted GLFW from the Build Options and added it to global compiler settings -> linker settings (I added glfw in link libraries) and in search directories -> Linker I added /usr/lib/x86_64-linux-gnu

Everything Compiled.

Upvotes: 0

genpfault
genpfault

Reputation: 52082

Use -lglfw.

Library names are case-sensitive. -lGLFW != -lgflw.

For instance:

  • On my Debian 9 system pkg-config --libs glfw3 gives me:

    -lglfw
    

    At:

    /usr/lib/x86_64-linux-gnu/libglfw.so
    
  • And pkg-config --libs gl gives:

    -lGL
    

    Corresponding to:

    /usr/lib/x86_64-linux-gnu/libGL.so
    

Upvotes: 2

Related Questions