User forums > Using Code::Blocks

Codeblocks not locating glfw libs even after I pointing the path to it.

<< < (2/3) > >>

colt:

--- Quote from: BlueHazzard on October 06, 2018, 12:49:43 am ---
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...

--- End quote ---

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;
--- End code ---


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;
--- End code ---

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

And finally on line 95

--- Code: ---project.AddLinkLib(_T("glfw"));
--- End code ---

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?

BlueHazzard:

--- Code: ---if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("GL"), _T("glfw.h"), _T("GLFW's include"))) return false;
--- End code ---
This line searches in

--- Code: ---dir_nomacro_inc + wxFILE_SEP_PATH + _T("GL")
--- End code ---
for the file
--- Code: ---glfw.h
--- End code ---


--- Code: ---dir_nomacro_inc
--- End code ---
is the path you enter in the dialog

--- Code: ---wxFILE_SEP_PATH
--- End code ---
is the file path separator for your operating system
so if you enter the path

--- Code: --- /media/34GB/demos/glfw-2.7.9/include/
--- End code ---
the wizard will search for the file

--- Code: --- /media/34GB/demos/glfw-2.7.9/include/GL/glfw.h
--- End code ---


--- Code: ---if (!VerifyLibFile(dir_nomacro_lib, _T("glfw"), _T("GLFW's"))) return false;
--- End code ---
The same for the library: This function search for the library
--- Code: ---glfw
--- End code ---
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")) );
}
--- End code ---
so if the path is right it should find the library ,because it searches for
--- Code: ---libglfw.a
--- End code ---
. Maybe you have to add the X11 folder to the library directory.

This line:

--- Code: ---project.AddLinkLib(_T("glfw"));
--- End code ---
adds the library with the name glfw to the project. The compiler will search by default also for
--- Code: ---libglfw.a
--- End code ---
. 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?

colt:
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?
--- End quote ---

? What code are you referring to?

BlueHazzard:
The glfw code

BlueHazzard:
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;
}

--- End code ---

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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version