C Programer  - 讨论区

标题:使用JUCE Library构建高性能C++应用程序

2014年01月26日 星期日 16:53

JUCE是一套功能丰富,跨平台的C++ Library,作者自己的介绍如下:

The JUCE Library

JUCE (Jules' Utility Class Extensions) is an all-encompassing C++ class library for developing cross-platform software.

It contains pretty much everything you're likely to need to create most applications, and is particularly well-suited for building highly-customised GUIs, and for handling graphics and sound.

I'm proud to have received a lot of praise over the years for the quality of the codebase, so would encourage you to dig into the code and have a look for yourself - hopefully you'll like what you see!

将JUCE集成到现有项目的方式有些特别:

Adding JUCE to your app is very simple – there's no need to pre-compile any libraries or worry about dependencies, as each juce module can be incorporated into a project by simply adding a single header and cpp file to your app.

To further simplify the process of building across multiple platforms, the Introjucer is a tool which automatically generates all the compiler-specific project files you need to build your project on a range of OSes. Just use the Introjucer's IDE to define the structure of your project, and it'll take care of the hassle involved in generating projects for Xcode, Visual Studio, etc, and keeping all these targets in sync with each other.

根据我的初步实践,我认为JUCE的API非常容易使用,只需要看头文件即可。简单的示例代码如下:

 

#include "../JuceLibraryCode/JuceHeader.h"
#include <iostream>

using namespace std;
using namespace juce;

int main (int argc, char* argv[])
{

    String s("Hello");
    s = s + ", World";
    cout << s << endl;

    IPAddress ip=IPAddress::local();
    cout << ip.toString() <<endl;

    Array<IPAddress> ips;
    IPAddress::findAllAddresses(ips);
    for(auto ip : ips ){
        cout <<ip.toString() <<endl;
    }

    Array<MACAddress> macs;
    MACAddress::findAllAddresses(macs);
    for(auto mac : macs) {
        cout << mac.toString() <<endl;
    }
    String filepath=
        "C:/windows/system32/drivers/etc/hosts";
    File f(filepath);
    if(f.exists()){
        MD5 m(f);
        cout << m.toHexString() << endl;
    }
    return 0;
}

注意事项:

我在Windows 7 X64环境中使用CodeBlocks编译Introjucer时,默认的工程文件会出现编译错误,需要增加 -march=i686 或者更高的选项(我使用的是 -march=pentium4)。

参考资料:

http://www.juce.com/about-juce

http://www.juce.com/features

 

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号