C++ download?

  • I was just looking for some guidance from people who may have some experience around hard coding where an appropriate place to download or somehow get hold of C/C++ would be? I've invested in a raspberry pi and currently running pure data with the monome and getting further and further more inspired to taking on programmes such as the likes.....

    Thank you for reading

    Joel

  • i'm not certain if i understand what youre looking for

    but this may help: http://monome.org/community/discussion/comment/199166#Comment_199166

  • Chances are very good that you already have C and C++ compilers on your Raspberry Pi. Here's some output from mine, running Raspbian Wheezy:

    pi@raspberrypi ~ $ dpkg -s g++
    Package: g++
    Status: install ok installed
    Priority: optional
    Section: devel
    Installed-Size: 34
    Maintainer: Debian GCC Maintainers
    Architecture: armhf
    Source: gcc-defaults (1.120)
    Version: 4:4.6.3-8
    Provides: c++-compiler
    Depends: cpp (>= 4:4.6.3-8), gcc (>= 4:4.6.3-8), g++-4.6 (>= 4.4.7-1~), gcc-4.6 (>= 4.4.7-1~)
    Description: GNU C++ compiler
    This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
    .
    This is a dependency package providing the default GNU C++ compiler.
    pi@raspberrypi ~ $ dpkg -s gcc
    Package: gcc
    Status: install ok installed
    Priority: optional
    Section: devel
    Installed-Size: 41
    Maintainer: Debian GCC Maintainers
    Architecture: armhf
    Source: gcc-defaults (1.120)
    Version: 4:4.6.3-8
    Provides: c-compiler
    Depends: cpp (>= 4:4.6.3-8), gcc-4.6 (>= 4.4.7-1~)
    Recommends: libc6-dev | libc-dev
    Suggests: gcc-multilib, make, manpages-dev, autoconf, automake1.9, libtool, flex, bison, gdb, gcc-doc
    Conflicts: gcc-doc (<< 1:2.95.3)<br />Description: GNU C compiler
    This is the GNU C compiler, a fairly portable optimizing compiler for C.
    .
    This is a dependency package providing the default GNU C compiler.

  • thank you very much guys! :)

  • Take a look at JUCE. It has a lot of powerful classes that make it easier to start.

  • im glad you said that i just discovered that one this morning and was thinking it may be a good one to go for

  • if you are starting to learn c/c++, i would use the application / plugin wrappers from JUCE by all means, but try and avoid using its many more general conveniences like Containers and Tokenizers, etc? since they are basically extra language features that you don't usually have. (i'd say the same for any big near-standard cpp library, like boost.)

    since you are using pd making a plugin for that environment might be the best way to go? it would be pretty plain C and operating in a simple well-defined environment.

    any *nix should have gcc? try:


    echo "#include <stdio.h>"$'\n'"void main(void) { printf(\"hello\"); }" | gcc -o hello -xc - && ./hello

  • thank you for that...im still just getting my head round the basics of computer science beyond max msp and pure data so Ill be taking careful note of these comments :)

    Cheers!

  • @zebra:why avoid using other JUCE classes? If a project requires JUCE anyway because it uses the plugin wrappers, I see no point in avoiding its additional classes.
    The situation is different when you plan to re-use the code in other projects that must stay independent of JUCE, though.
    Sure, stdlib brings its own memory management stuff (like vectors) - and so does JUCE. In this case the stdlib classes are probably the better choice. But how about all the convenient GUI class of JUCE?

    I would love to hear your thoughts on this!

  • well, the OP was asking really the basics about learning C/C++ , and its my 2-cents opinion that juce, boost, and OF are very very useful indeed for different applications. (like: audio plugin + gui, numerical modeling, and machine vision / animation, respectively.) so yeah, i would use the crap out of those tools to accomplish those tasks... but... seems like a weird way to start learning the semantics, style, and features of C/C++ because each of these gigantic frameworks basically constitutes a language in its own right, with its own semantics, style, and features.

    you can open a terminal on basically any machine and instantly start building programs, so why not start there?

    i still think that Pd source might be a reasonable place to look too, for a pd user.
    http://puredata.info/docs/developer/GettingPdSource

    all just my opinion though!

  • @TheSlowGrowth i'd just point out that in many embedded environments, for example, you don't even have stdlib , vectors, etc., or they are too inefficient to use in e.g. audio callback code. at its core, C simply does not have high-level container classes or managed memory.

    much better (again, IMHO !) to get comfortable with pointers and allocation so you know what kind of crazy convolutions the JUCE classes actually have to perform to make things like ReferenceCountedObjectPtr, which effectively mimics the behavior of a garbage-collected environment and makes your language into a sort of C++/Java hybrid.

  • Yea, I understand your point. Sure, for learning the basics, it might be good to start wit a less "managed", less "easy" language style.

    I personally started learning C++ with JUCE. To be honest: It was a great choice. The source code of all those cool classes is so clean, easy to read, easy to understand! It helped me to learn a lot of design patterns which I would never have thought of without JUCE.

    I think in C++ the most important thing is structure. Stuff like listeners, singletons, multi threading (especially for audio apps which use multi threading almost by definition), all the locking and mutex-ing stuff required for multi threading, separating the gui from the core of your app, the beautiful possibilities of polymorphism, …, …, … JUCE helped me a lot to learn these things. Sure, it does not substitute a good book or a web tutorial - but it gives those real-world examples that help translate the theory into your world - which is (at least for me) always driven by the wish to create a cool application (in the first place) - and not by the wish to understand how a singleton works.

    Very important for me was to keep my motivation high - which is much easier when you have some quick results. A few clicks in the "Introjucer", a few lines of code and voila - a gui application is ready to compile.
    That's why I would really encourage @xuukiFauveboy to start there. It's a lot of fun!

    But, yea, that's maybe just my point of view. I definitively see your point. I guess it depends on how you like to learn and what you want to achieve. My approach has always been very "result oriented" where each design pattern i learned was just a necessity to realize some specific functionality.
    It might be completely different for others.

  • @xuukiFauveboy One more thing you should be aware of: C and C++ are distinct things. Even though they look quite similar in terms of syntax and code style (and even though they are indeed very close to each other - technically speaking) - they are very different to write code with.

    Maybe you already know this - but given you asked for a way to get hold of a "C/C++" compiler, I assume this could be interesting for you. Just in case, here are my thoughts on this:

    C is the earlier of both. It is a language with an extremely flexible syntax. Its easy to make errors just by typing mistakes. This somewhat makes the language a bit strange to get started with, because many things look similar but indeed do completely different things.
    C is mostly used when its all about efficiency. Really, I think this and the fact that there are soooo many compilers for soooo many platforms are the greatest benefits of C.
    With C you have to take care of the way you use memory and all that low level stuff. This sometimes is a bit annoying but on the other hand allows for some extremely efficient programming. Fast audio algorithms or mobile platforms like the aleph are a good example for that. I think Reaktor/Max core are both written in C as well (not 100% sure though).

    C++ brings the addition of being object oriented. This allows for some very flexible designs (polymorphism). C++ kind of "includes" everything that C can do, but its additions allow for a completely different style of coding and structuring.
    C++ could be described as a little "slower" than C, a little farer away from the hardware level, but much faster to write and much more efficient in terms of "lines of code vs. functionality".

    I just found this thread, where they discuss this topic a lot more (and probably a lot better that I do): http://programmers.stackexchange.com/questions/113295/when-to-use-c-over-c-and-c-over-c

  • +1 to above. There are lots of Python C / C++ wrappers depending on what you are doing as well. Python is sometimes more accessible but still a very powerful language.

  • i've been working my way through the C tutorials here

    http://c.learncodethehardway.org/book/

    and have been suprised to find that's it not the horrendous undertaking i was expecting. not sure how well this will translate into writing audio apps in the future though.

  • Ill be sure to give this ago though :)

  • Didn't want to start a new thread, soooo. Real small problem but it's killing me. I programmed a touchOSC implementation in python but now my team wants to change everything over to C, so I downloaded a few different C OSC libraries, and none of them will compile correctly. Not even their own examples. It keeps saying that it can't find the headers, so I even went to the extent of giving it a full direct path (i.e "/Users/Aaron/Desktop/SimpleReceiveTest/packet.h") inside the same folder and can't find it. What can I do? Thankssss.

  • gcc -I/path/to/headers example.c -o example

    Or use a makefile if provided. liblo is a good library with easy examples

  • Interesting you say that because liblo is the one giving the most simple but confusing error. Heres what I just did, but still didn't run.

    aaronchainsmbp3:examples Aaron$ gcc -l/Users/Aaron/Downloads/C_OSC_Libraries/liblo-0.28/lo example_client.c -o example
    example_client.c:21:10: fatal error: 'lo/lo.h' file not found
    #include "lo/lo.h"
    ^
    1 error generated.

    EDIT: README says this, "These examples will work without installing liblo. This is
    accomplished by a shell script. For example, `examples/client_example`
    is a shell script that runs the "real" program
    `examples/.libs/example_client`. Because of this indirection, you
    cannot run `example_client` with a debugger."

    But now I don't understand how to use the MakeFile.am and MakeFile.in to get said shell scripts

  • just type "make" in the examples dir, e.g.
    emb@pad ~/src/liblo-0.26/examples $ make

    as in most projects of any size, liblo has a number of c sources that need to be compiled into object code and then linked together into an executable.

    without a makefile, this process generally looks like:

    gcc -I/path/to/some/headers -I/path/to/more/headers source.c otherSource.c -o myapp -lsomelibrary -lsomeotherlibrary

    but usually one uses a makefile to automate this process somewhat.

    here is a basic introduction to compiling with makefiles and gcc
    http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/

  • btw, the flag for an include path is an uppercase 'i' , not a lowercase 'L'.

  • Thanks for the pro tips. My problem was probably the latter coment, I believe i typed an "l", make I should used another font terminal ha.