Author Topic: Codeblocks not locating glfw libs even after I pointing the path to it.  (Read 10377 times)

Offline colt

  • Single posting newcomer
  • *
  • Posts: 9
Hello, I tried to use the wizard to start a glfw project, and when I do it, it says at one point :

Quote
.......Please select the location of GLFW's location
Quote

When I click the "..." button, before actually taking me to select the place, it opens a Window to adjust variable settings. Following what I learned from a webpage (http://www.kerrywong.com/2008/07/12/codeblocks-settings-for-qt-development/) to set up QT support in another project, the "base" and "include" fields were adjusted to point to the dir /.../glfw-2.7.9/include/GL. There there is the "glfw.h" header file. The field "lib" were adjusted to point to /.../glfw-2.7.9/lib/x11. There there is the "libglfw.a" and "libglfw.so"

After adjusting it, codelblocks opened the small window to actually select glfw's location and then I told it to look for it in  /..../glfw-2.7.9.

When I do that, Codeblocks tells me this:
Quote
the path you entered seems valid, but this wizard can't locate the following GLFW's library file: glfw in it (also tried prepending lib and appending .a and .lib)

Isn't the problem is that he is only looking precisely for something called "glfw.a" or "glfw.lib" when should be looking for "libglfw.a" or "libglfw.so" ? If that's the case, how can I solve it? If it's not, what is the issue and how should I deal with it?

Thanks for your time.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #1 on: October 03, 2018, 11:58:10 pm »
Does the wizard concludes? Is the project generated?
If yes, then try to build it. If it fails post the build log here as described in this faq: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

The wizard is not the brightest and probably needs some updates...
Also giving your operating system would be nice

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #2 on: October 04, 2018, 12:46:23 am »
Ok, i did a quick test on windows, and there is a lot to change...
I try to explain them here step by step. Probably there will be an update to fix the wizard.

Windows 7 mingw
1) I downloaded this https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip
2) Compiled it with cmake and mingw compiler
3) Start codeblocks
4) File->New->Project
5) Right click on GLFW Project->Edit this script
Line 49:
Code
if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("GLFW"), _T("glfw3.h"), _T("GLFW's include"))) return false;
Line 55:
Code
if (!VerifyLibFile(dir_nomacro_lib, _T("glfw3"), _T("GLFW's"))) return false;
Line 95:
Code
    project.AddLinkLib(_T("glfw3"));
6) Save the file
7) File->New->Project->GFLW Project->Ok->Next
8) "Please select GLFWs location":
Quote
$(#glfw)
9) In step 2 i Installed the library to
Code
G:\glfw-3.2.1\install
So if you have to set the global variable:
so i set the "base" to
Code
G:\glfw-3.2.1\install
"include" to
Code
G:\glfw-3.2.1\install\include
and "lib" to
Code
G:\glfw-3.2.1\install\lib
10) Finish the wizard. It should complete

The created example code is outdated, so we have to create our own example:
11) From the gflw source folder copy the content of "G:\glfw-3.2.1\examples\simple.c" over the content of main.cpp of the project
12) I don't know exactly why, but we need glad:
I used the zip archive of this link http://glad.dav1d.de/#profile=compatibility&specification=gl&api=gl%3D4.6&api=gles1%3Dnone&api=gles2%3Dnone&api=glsc2%3Dnone&language=c&loader=on
13) Extract it in your project folder so you will have the folowing structure:
Code
project_folder/glad/inlcude/glad/glad.h
and
Code
project_folder/glad/src/glad/glad.c
14) Copy the file "G:\glfw-3.2.1\deps\linmath.h" to your project folder
15) Add the files to your project: Project->Add files: glad/src/glad.c, and linmath.h
16) Add the include folder search path to the project: Project->Build options->Select the project name on the left->Search directories->Compiler->Add->
Code
glad\include
17) Ok all

18) Project->Build
19) Project->Run
20 Enjoy a spinning triangle ;)




Offline colt

  • Single posting newcomer
  • *
  • Posts: 9
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #3 on: October 06, 2018, 12:37:14 am »
Quote
Does the wizard concludes? Is the project generated?
If yes, then try to build it. If it fails post the build log here as described in this faq: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

The wizard is not the brightest and probably needs some updates...
Also giving your operating system would be nice

No, it did not conclude unfortunately.  When I clicked "next" it forced me to set the variables. After that it opens the selection window to select the GLFW's location. After doing that, it ends showing the small error window and it became paralyzed (neither the "next" button or the "..." button that selects the location answer anymore). At that point The "X" button on both windows also does not answer anymore. (I am referring to exit "x" on both the gl project window and on the codeblocks main window) forcing me to end codeblocks through command line.

I ask apologize for forgetting to mention the OS. Unfortunately it's not Windows, it's Linux, Ubuntu 10.04 with glfw 2.7.9.

Anyway I changed the 3 lines on the script file, then on the global variable setting, I set the "base" variable to /media/34GB/demos/glfw-2.7.9, the "include" variable to /media/34GB/demos/glfw-2.7.9/include/GL (where there is "glfw.h") and finally the "lib" variable to /media/34GB/demos/glfw-2.7.9/lib/X11 (where libglfw.a and libglfw.so are).

If I set the "include" variable to /media/34GB/demos/glfw-2.7.9/include/ and the "lib" variable to /media/34GB/demos/glfw-2.7.9/lib does not make any difference.

After all that, I received a 
Quote
The path you entered seems valid, but this wizard
can't locate the following GLFW's include file:
glfw3.h in it.
I changed it to "glfw.h on line 49 and problem persists (of course, now complaining about "glfw.h"

Have to change something on the other lines?

P.S: Glfw name  on the project wizard became red after the script modifications
« Last Edit: October 06, 2018, 12:43:38 am by colt »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #4 on: October 06, 2018, 12:49:43 am »
Quote
P.S: Glfw name  on the project wizard became red after the script modifications
this indicates that you have modified the script

Quote
I ask apologize for forgetting to mention the OS. Unfortunately it's not Windows, it's Linux, Ubuntu 10.04 with glfw 2.7.9.
I can not help with this at the moment...
But obviously you have to change the settings so they work with your installation... If the library is called glfw2 you have to change the line in the script accordingly. Changing to glfw3 when the library is called glfwAA does not work as you have found out. I do not know how the library is called on ubuntu...

I made a quick look in the script and there are no difference between windows and unix, so you simply have to change the lines i gave you above with the right names and it should work...

Offline colt

  • Single posting newcomer
  • *
  • Posts: 9
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #5 on: October 06, 2018, 04:09:13 pm »

I can not help with this at the moment...
But obviously you have to change the settings so they work with your installation... If the library is called glfw2 you have to change the line in the script accordingly. Changing to glfw3 when the library is called glfwAA does not work as you have found out. I do not know how the library is called on ubuntu...

I made a quick look in the script and there are no difference between windows and unix, so you simply have to change the lines i gave you above with the right names and it should work...

Well, It's not Ubuntu related, because I installed glfw from source.

Anyway, on line49 I have:

Code
 if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("GL"), _T("glfw.h"), _T("GLFW's include"))) return false;


I already have adjusted the second T() from "glfw3.h" to "glfw.h" but the other two T, I don't know to what they make reference to.

On line 55:

Code
if (!VerifyLibFile(dir_nomacro_lib, _T("glfw"), _T("GLFW's"))) return false;

Also don't know to what the two T() are referring to.

And finally on line 95
Code
project.AddLinkLib(_T("glfw"));

Don't know what this T is referring to either

The include dir has a subdir called "GL" where there is the header. The lib dir has a subdir called x11 where libglfw.a and libglfw.so are.

Any ideas of how to set them up?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #6 on: October 06, 2018, 05:37:50 pm »
Code
if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("GL"), _T("glfw.h"), _T("GLFW's include"))) return false;
This line searches in
Code
dir_nomacro_inc + wxFILE_SEP_PATH + _T("GL")
for the file
Code
glfw.h

Code
dir_nomacro_inc
is the path you enter in the dialog
Code
wxFILE_SEP_PATH
is the file path separator for your operating system
so if you enter the path
Code
 /media/34GB/demos/glfw-2.7.9/include/
the wizard will search for the file
Code
 /media/34GB/demos/glfw-2.7.9/include/GL/glfw.h

Code
if (!VerifyLibFile(dir_nomacro_lib, _T("glfw"), _T("GLFW's"))) return false;
The same for the library: This function search for the library
Code
glfw
in the library folder. This function is this:
Code
function SilentVerifyLibFile(dir, file)
{
    return (   IO.FileExists(dir + wxFILE_SEP_PATH + file)
            || IO.FileExists(dir + wxFILE_SEP_PATH + file + _T(".a"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + file + _T(".dll.a"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + file + _T(".lib"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file)
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file + _T(".a"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file + _T(".dll.a"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file + _T(".lib"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file + _T(".la"))
            || IO.FileExists(dir + wxFILE_SEP_PATH + _T("lib") + file + _T(".so")) );
}
so if the path is right it should find the library ,because it searches for
Code
libglfw.a
. Maybe you have to add the X11 folder to the library directory.

This line:
Code
project.AddLinkLib(_T("glfw"));
adds the library with the name glfw to the project. The compiler will search by default also for
Code
libglfw.a
. It adds automatically the lib and .a So you do not have to do it by yourself.

The easiest would be to abandon the wizard: Create a hello world c project and add the include directories in Project->Build options->Select your project name on the left->Search directories->Compiler->Add the folder where the include file can be found
The same for the library: Project->Build options->Select your project name on the left->Linker->Add library

Anyway it would be nice if you help to fix the wizard. Probably i will find some time the next week to try this on ubuntu. Where did you get the code from?

Offline colt

  • Single posting newcomer
  • *
  • Posts: 9
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #7 on: October 08, 2018, 11:37:49 pm »
I added the X11 dir to the lib path in the global variable window. Unfortunately it did not work. If there is anything I can do to help to fix it, I will do so. I will use the non wizard way as soon as I find time.

But I did not understand this:
Quote
Where did you get the code from?

? What code are you referring to?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #8 on: October 09, 2018, 09:45:34 am »
The glfw code

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #9 on: October 09, 2018, 01:42:41 pm »
Ok, here the steps i do:
1) Download https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip
2) extract it to /home/bluehazzard/programming/glfw
3) run cmake-gui
4) select source directory to /home/bluehazzard/programming/glfw
5) select output directory to /home/bluehazzard/programming/glfw/build
6) Set CMAKE_INSTALL_PREFIX to /home/bluehazzard/programming/glfw/install
7) Configure
8) make
9) make install
10) Start codeblocks
11) Fix the wizard with the code below
Code
////////////////////////////////////////////////////////////////////////////////
//
// GLFW project wizard
//
////////////////////////////////////////////////////////////////////////////////

// globals
GlfwPathDefault    <- _T("$(#glfw)");
GlfwPathDefaultInc <- _T("$(#glfw.include)");
GlfwPathDefaultLib <- _T("$(#glfw.lib)");
GlfwPath <- _T("");

function BeginWizard()
{
    local intro_msg = _T("Welcome to the new GLFW project wizard!\n\n" +
                         "This wizard will guide you to create a new project\n" +
                         "using the GLFW OpenGL extensions.\n\n" +
                         "When you 're ready to proceed, please click \"Next\"...");

    local glfwpath_descr = _T("Please select the location of GLFW on your computer.\n" +
                              "This is the top-level folder where GLFW was installed (unpacked).\n" +
                              "To help you, this folder must contain the subfolders\n" +
                              "\"include\" and \"lib\".");

    Wizard.AddInfoPage(_T("GlfwIntro"), intro_msg);
    Wizard.AddProjectPathPage();
    Wizard.AddGenericSelectPathPage(_T("GlfwPath"), glfwpath_descr, _T("Please select GLFW's location:"), GlfwPathDefault);
    Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
}

////////////////////////////////////////////////////////////////////////////////
// GLFW's path page
////////////////////////////////////////////////////////////////////////////////

function OnLeave_GlfwPath(fwd)
{
    if (fwd)
    {
        local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
        local dir_nomacro = VerifyDirectory(dir);

        if (dir_nomacro.IsEmpty())
            return false;

        // verify include dependencies
        local dir_nomacro_inc = GetCompilerIncludeDir(dir, GlfwPathDefault, GlfwPathDefaultInc);
        if (dir_nomacro_inc.IsEmpty())
            return false;
        if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("GLFW"), _T("glfw3.h"), _T("GLFW's include"))) return false;

        // verify library dependencies
        local dir_nomacro_lib = GetCompilerLibDir(dir, GlfwPathDefault, GlfwPathDefaultLib);
        if (dir_nomacro_lib.IsEmpty())
            return false;
        if (!VerifyLibFile(dir_nomacro_lib, _T("glfw3"), _T("GLFW's"))) return false;


        GlfwPath = dir; // Remember the original selection.

        local is_macro = _T("");

        // try to resolve the include directory as macro
        is_macro = GetCompilerIncludeMacro(dir, GlfwPathDefault, GlfwPathDefaultInc);
        if (is_macro.IsEmpty())
        {
            // not possible -> use the real inc path we had computed instead
            GlfwPathDefaultInc = dir_nomacro_inc;
        }

        // try to resolve the library directory as macro
        is_macro = GetCompilerLibMacro(dir, GlfwPathDefault, GlfwPathDefaultLib);
        if (is_macro.IsEmpty())
        {
            // not possible -> use the real lib path we had computed instead
            GlfwPathDefaultLib = dir_nomacro_lib;
        }
    }
    return true;
}

// return the files this project contains
function GetFilesDir()
{
    return _T("glfw/files");
}

// setup the already created project
function SetupProject(project)
{
    // set project options
    project.AddIncludeDir(GlfwPathDefaultInc);
    project.AddLibDir(GlfwPathDefaultLib);

    // add link libraries
    project.AddLinkLib(_T("glfw3"));
    if (PLATFORM == PLATFORM_MSW)
    {
        project.AddLinkLib(_T("opengl32"));
        project.AddLinkLib(_T("glu32"));
        project.AddLinkLib(_T("gdi32"));
    }
    else
    {
        project.AddLinkLib(_T("GL"));
        project.AddLinkLib(_T("GLU"));
        project.AddLinkLib(_T("pthread"));
        project.AddLinkLib(_T("Xxf86vm"));
    }

    // enable compiler warnings (project-wide)
    WarningsOn(project, Wizard.GetCompilerID());

    // Debug
    local target = project.GetBuildTarget(Wizard.GetDebugName());
    if (!IsNull(target))
    {
        target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
        target.SetWorkingDir(GlfwPath + _T("/bin"));
        // enable generation of debugging symbols for target
        DebugSymbolsOn(target, Wizard.GetCompilerID());
    }

    // Release
    target = project.GetBuildTarget(Wizard.GetReleaseName());
    if (!IsNull(target))
    {
        target.SetTargetType(ttExecutable); // ttExecutable: no console
        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
        target.SetWorkingDir(GlfwPath + _T("/bin"));
        // enable optimizations for target
        OptimizationsOn(target, Wizard.GetCompilerID());
    }

    return true;
}

12) Create new project with the wizard
13) Set the search path for glfw to /home/bluehazzard/programming/glfw/install
14) The wizard should finish without problems
15) Make the changes as described above

Offline colt

  • Single posting newcomer
  • *
  • Posts: 9
Re: Codeblocks not locating glfw libs even after I pointing the path to it.
« Reply #10 on: October 09, 2018, 10:54:06 pm »
Unfortunately glfw 3.2 requires a newer version of cmake than I have available. And the older glfw 2.7.9 does not use cmake. So I ended not using the wizard.