如何修复Code :: Blocks向导以查找GTK + 3.0,而不是2.0? [英] How to fix the Code::Blocks wizard to look for GTK+ 3.0 and not 2.0?

查看:94
本文介绍了如何修复Code :: Blocks向导以查找GTK + 3.0,而不是2.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我开始用C编程以来,我一直在使用Code :: Blocks,在Windows下尝试了每个存在的C编译器
之后,我发现Code :: Blocks最容易使用,因为我不必我花了整整一年的时间学习如何使用该程序,然后才能开始在其中用XD编写 hello world应用程序……

I have been using Code::Blocks since I started programming in C, after trying every C compiler in existence under windows I found Code::Blocks the most easiest to work with because I wouldn't have to spend an entire year learning how to use the program before I could start writing 'hello world' apps in it XD......

无论如何,我都安装了GTK + 3.0,设置环境变量并运行cmd提示命令,如设置教程告诉我...。我什至从cmd提示中运行gtk-demo文件...。当我运行Code :: Blocks 13.10 gtk +时向导不断告诉我似乎已安装GTK +,但在进行一些挖掘后找不到gtk.h,我意识到它正在寻找gtk-2.0文件夹而不是gtk-3.0文件夹...

Anyway I installed GTK+ 3.0 and setup the environmental variables and ran the cmd prompt commands as the setup tutorial told me to.... I even ran the gtk-demo file from the cmd prompt....When I went to run through the Code::Blocks 13.10 gtk+ wizard it kept telling me that GTK+ seemed to be installed but that it couldn't find gtk.h after doing some digging I realized it was looking for the gtk-2.0 folder and not the gtk-3.0 folder...

另一个论坛上的某个人似乎已通过将向导脚本中的2.0更改为3.0来超越了这一部分,但声称一旦他尝试编译它,它将给他带来更多错误

Someone on another forum seemed to have gotten past that part by changing the 2.0's to 3.0's in the wizard script but claimed it gave him more errors once he would try to compile it.

推荐答案

好的,我知道了.....我去了命令控制台并运行了该命令以获取所有版本信息:pkg-config --cflags gtk + -3.0

Alright people, I figured it out.....I went to command console and ran this command to get all the versions info: pkg-config --cflags gtk+-3.0

这样做,我得到了以下信息:-mms-bitfields -IC:/GTK3/include/gtk-3.0 -IC:/ GTK3 / include / cairo -IC :/GTK3/include/pango-1.0 -IC:/GTK3/include/atk-1.0 -IC:/ GTK3 / include / cairo -IC:/ GTK3 / include / pixman-1 -IC:/ GTK3 / include -IC: / GTK3 / include / freetype2 -IC:/ GTK3 / include -IC:/ GTK3 / include / libpng15 -IC:/GTK3/include/gdk-pixbuf-2.0 -IC:/ GTK3 / include / libpng15 -IC:/ GTK3 / include / glib-2.0 -IC:/GTK3/lib/glib-2.0/include

By doing that I got the following information: -mms-bitfields -IC:/GTK3/include/gtk-3.0 -IC:/GTK3/include/cairo -IC:/GTK3/include/pango-1.0 -IC:/GTK3/include/atk-1.0 -IC:/GTK3/include/cairo -IC:/GTK3/include/pixman-1 -IC:/GTK3/include -IC:/GTK3/include/freetype2 -IC:/GTK3/include -IC:/GTK3/include/libpng15 -IC:/GTK3/include/gdk-pixbuf-2.0 -IC:/GTK3/include/libpng15 -IC:/GTK3/include/glib-2.0 -IC:/GTK3/lib/glib-2.0/include

我进入了Code :: Blocks,然后进入File-> New->项目:然后右键单击GTK +项目图标,然后选择编辑此脚本,我浏览了文件并更改了文件以匹配上述信息中的版本

I went into Code::Blocks and I went to File->New->Project: I then right clicked the GTK+ project icon and selected 'edit this script' I went through the file and changed the files to match the versions in the above information

    ////////////////////////////////////////////////////////////////////////////////
    //
    // GTK project wizard
    //
    ////////////////////////////////////////////////////////////////////////////////

    // globals
    GtkPathDefault    <- _T("$(#gtk)");
    GtkPathDefaultInc <- _T("$(#gtk.include)");
    GtkPathDefaultLib <- _T("$(#gtk.lib)");
    GtkPath <- _T("");
    // GtkVersion <- 1; // 0 - GTK+, 1 - GTK+-2.0

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

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

        Wizard.AddInfoPage(_T("GtkIntro"), intro_msg);
        Wizard.AddProjectPathPage();
        if (PLATFORM == PLATFORM_MSW)
        {
            Wizard.AddGenericSelectPathPage(_T("GtkPath"), gtkpath_msg, _T("GTK's location:"),         GtkPathDefault);
        }
        /*else
        {
            Wizard.AddGenericSingleChoiceListPage(_T("GtkVersionPage"), _T("Please select the         GTK+ version you want to use."), _T("GTK+ 1.x;GTK+ 2.x"), GtkVersion); // select GTK+         version
        }*/
        Wizard.AddCompilerPage(_T(""), _T("gcc*"), true, true);
    }

    ////////////////////////////////////////////////////////////////////////////////
    // Gtk's path page
    ////////////////////////////////////////////////////////////////////////////////

    function OnLeave_GtkPath(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, GtkPathDefault,         GtkPathDefaultInc);
            if (dir_nomacro_inc.IsEmpty())
                return false;
            if (!VerifyFile(dir_nomacro_inc + wxFILE_SEP_PATH + _T("gtk-3.0") + wxFILE_SEP_PATH         +_T("gtk"), _T("gtk.h"), _T("GTK's include")))
                return false;

            // verify library dependencies
            local dir_nomacro_lib = GetCompilerLibDir(dir, GtkPathDefault, GtkPathDefaultLib);
            if (dir_nomacro_lib.IsEmpty())
                return false;
            if (!VerifyLibFile(dir_nomacro_lib, _T("gtk-win32-3.0"), _T("GTK's")))
                return false;


            GtkPath = dir; // Remember the original selection.

            local is_macro = _T("");

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

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

    ////////////////////////////////////////////////////////////////////////////////
    // Gtk's version page (For *nix users)
    ////////////////////////////////////////////////////////////////////////////////

    function OnLeave_GtkVersionPage(fwd)
    {
        if (fwd)
        {
            GtkVersion = Wizard.GetListboxSelection(_T("GenericChoiceList"));
        }
        return true;
    }

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

    // setup the already created project
    function SetupProject(project)
    {
        if (PLATFORM == PLATFORM_MSW)
        {
            project.AddIncludeDir(GtkPathDefaultInc);
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gtk-3.0"));
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("cairo"));
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk"));
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("glib-2.0"));
            // Notice GtkPathDefault*Lib* at some positions. This is correct as of 2.8.20
            project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("glib-2.0") +         wxFILE_SEP_PATH + _T("include"));
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("pango-1.0"));
            project.AddIncludeDir(GtkPathDefaultLib + wxFILE_SEP_PATH + _T("gtk-3.0")  +         wxFILE_SEP_PATH + _T("include"));
            project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("atk-1.0"));
            if ( IO.DirectoryExists(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-2.0"))         )
                project.AddIncludeDir(GtkPathDefaultInc + wxFILE_SEP_PATH + _T("gdk-pixbuf-        2.0"));

            project.AddLibDir(GtkPathDefaultLib);

            // add link libraries
            project.AddLinkLib(_T("gtk-win32-3.0"));
            project.AddLinkLib(_T("gobject-2.0"));
            project.AddLinkLib(_T("glib-2.0"));

            // Notice: there are more libs required as the app gets more complex, e.g.:
            // pangocairo-1.0.lib, pangocairo-1.0.lib, libatk-1.0.dll.a,
            // gdk_pixbuf-2.0.lib, gdk-win32-2.0.lib,  pango-1.0.lib,
            // gmodule-2.0.lib,    gthread-2.0.lib,    cairo.lib,
            // pangoft2-1.0.lib    (...)

            project.AddCompilerOption(_T("-mms-bitfields"));
        }
        else
        {
            /*if (GtkVersion == 1)
            {*/
            project.AddCompilerOption(_T("`pkg-config gtk+-3.0 --cflags`"));
            project.AddLinkerOption(_T("`pkg-config gtk+-3.0 --libs`"));
            /*}
            else
            {
                project.AddCompilerOption(_T("`pkg-config gtk+ --cflags`"));
                project.AddLinkerOption(_T("`pkg-config gtk+ --libs`"));
            }*/
        }

        // 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);
            // 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);
            // enable optimizations for target
            OptimizationsOn(target, Wizard.GetCompilerID());
        }

        return true;
    }

如果您要设置Code :: Blocks使其无法打开GTK + GUI后面的一个win32控制台窗口,转到Project-> Properties-> Build target,然后在 Selected build target options下选择Type:下拉列表并选择GUI应用程序,它可能已选择了Console Application

If you want to setup Code::Blocks so that it doesn't open a win32 console window behind your GTK+ GUI goto Project->Properties->Build targets and then under "Selected build target options" select the Type: dropdown list and select GUI application, it will probably have Console Application selected

编辑:来找出答案,检查上面的脚本后,我意识到您不必经历所有麻烦即可删除控制台,您所需要做的就是选择下拉菜单工具栏上运行右侧的菜单,然后将其从调试切换到Release XD

Come to find out, upon inspection of the script above I realized the you don't have to go through all that trouble to remove the console, all you need to do is select the dropdown menu to the right of 'run' on the toolbar and switch it from Debug to Release XD

这篇关于如何修复Code :: Blocks向导以查找GTK + 3.0,而不是2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆