Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Linking GLFW libs to project(How to properly link lib files to my project)
Linking GLFW libs to project [message #1838333] Mon, 22 February 2021 13:36 Go to next message
Sequoia Tree is currently offline Sequoia TreeFriend
Messages: 28
Registered: August 2014
Junior Member
I've been trying to work with OpenGL but cannot get off the ground.

For years I've been using Eclipse, MinGW and Qt libraries for GUI project and have been doing okay on my 64 bit Win10 PC.

Now to step into OpenGL I have a tree of files called 'glfw-3.3.2.bin.WIN64' and have linking errors.

I started with this error :
undefined reference to `glfwInit'

After I added #define GLFW_DLL I have this error :
undefined reference to `__imp_glfwInit'

1. Who is the imp?
2. Can my Qt libraries come into conflict with the GLFW libs?
3. Am I dealing with *.lib files or *.a files or *.dll files?
4. Must I define the location of the glfw3.dll in

a. my Windows Path statement or
b. a link parameter -LD:/FolderLocation or
c. Eclipse project properties/C-C++ General/Paths and Symbols

or all three
or in yet another manner?

At the moment my code looks like this

#define GLFW_DLL

#include "GLFW64\glfw3.h"

int main(void) {

    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    return 0;
}
Re: Linking GLFW libs to project [message #1838343 is a reply to message #1838333] Mon, 22 February 2021 16:33 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Sounds like you already know how to tell Eclipse to build using an external library.
Just in case you need to know:

  • You need to tell the compiler where the include files can be found GCC -I (capital I) flag.
  • You need to tell the linker where the libraries can be found and which to use GCC -L and -l (small L) flags
  • Tell the Indexer where the include files can be found
    Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc

The above assumes you are using gcc.
You will need to know what the comparable options are if you are using something else.

If the library is dynamic, you usually need to provide the linker with the external names and how to reach them in the library.
In Windows this is called an Import Library.
This might help you understand: https://cygwin.com/cygwin-ug-net/dll.html

When running a program that needs a dynamic library (.dll in windows) you need to put it where the OS will look.
For Linux: add it's path to the LD_LIBRARY_PATH environement variable
For Windows read: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order

This site is for answering questions about using CDT itself.
The rest of your questions are specific to GLFW.
You may get answers here but, in general,
you will be better off if you ask at the GLFW community
https://www.glfw.org/community.html
or perhaps at stackoverflow.com

[Updated on: Mon, 22 February 2021 16:51]

Report message to a moderator

Re: Linking GLFW libs to project [message #1838344 is a reply to message #1838343] Mon, 22 February 2021 16:37 Go to previous message
Sequoia Tree is currently offline Sequoia TreeFriend
Messages: 28
Registered: August 2014
Junior Member
That should help.
Thanks.

And now it works. One letter was missing.

[Updated on: Mon, 22 February 2021 20:10]

Report message to a moderator

Previous Topic:ms not supported with X32 ABI
Next Topic:Opened CMake proj from FileSystem - but IDE picked java builder?
Goto Forum:
  


Current Time: Fri Apr 26 21:15:43 GMT 2024

Powered by FUDForum. Page generated in 0.03834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top