I went through all the install instructions for your getting started on the Raspberry Pi. However it did not work. It only showed the usage text at the start of the code.

I had to use ./general-print 1 'bar' to get it to work. Maybe you should change the instructions?

However, I then went on to try and compile these examples and it fails each time on the :-
#include <Trill.h>
line, with file not found error.

Does anyone know either how to install the library correctly, or how to set up Geany so that it knows where it is.

    Grumpy_Mike I had to use ./general-print 1 'bar' to get it to work. Maybe you should change the instructions?

    Thanks, fixing that. Luckily, the provided instructions were showing the help, so you were not too far from getting it done.

    Grumpy_Mike However, I then went on to try and compile these examples and it fails each time on the :-

    What are the steps you are doing to get that error? What are you trying to build? Examples build fine for me, and you must have managed to build them, too, as you managed to run one!

      Thanks for the reply

      giuliomoro you must have managed to build them, too, as you managed to run one!

      No the one I ran was compiled as a result of the make process when installing the library.
      What I did to try to compile it was to open the Geany editor and set the document type to C++. Then I loaded in the general-print.cpp file from the examples/general-print folder and chose the compile option from the Build menu. This came up with a file not found on the first line which is an #include <Trill.h>.
      I unzipped the Trill-Linux-master in the Downloads folder, and that is where the general-print.cpp was. But I also copied the general-print folder and the library files to other places, but the result was the same.

      I interpreted this as meaning either the libraries have not been put in the correct place, or that I need to tell Geany where to look for your libraries.

      As this is my first time using Geany I tried a Hello World example where I had to pull in external libraries and that worked fine. Although I have hardly used C much on the Pi before, I have been programming the Arduino for about 12 years.

        Grumpy_Mike No the one I ran was compiled as a result of the make process when installing the library.

        That is: you managed to build it.

        Grumpy_Mike eany editor and set the document type to C++. Then I loaded in the general-print.cpp file from the examples/general-print folder and chose the compile option from the Build menu.

        Right, so you have an issue with the build system provided by the Geany editor.

        Grumpy_Mike I interpreted this as meaning either the libraries have not been put in the correct place,

        When you download the repo, the files are within the Trill-Linux folder. None of these files is installed in a special place on your system. A program using this library needs to:

        1. have the Trill-Linux/lib folder included among the folders to search for .h headers
        2. build the Trill-Linux/lib/Trill.cpp file as part of the program

        The provided Trill-Linux/examples/Makefile does just that for all the folders in Trill-Linux/examples, so one easy way to add a new program is to create another subfolder in there, e.g.: Trill-Linux/examples/myproject, with one or more .cpp files in there, e.g.: Trill-Linux/examples/myproject/myproject.cpp and then run make again. This will build your new project.

        The alternative, which is the more generic approach, is to somehow instruct your build systems to perform steps 1. and 2. above. I am not familiar with Geany, so I will try to give generic instructions.
        Step 1. is normally accomplished by passing to the compiler the option -I/path/to/Trill-Linux/lib.
        Step 2. is a bit more complicated. If the building system does compiling and linking in one stage, it would be sufficient to add /path/to/Trill-Linux/lib/Trill.cpp to the build line. Otherwise, you may have to add that file as a dependency. Again, I don't know Geany and I don't know if it is capable of handling multi-file programs.

        You can always build your program from the command line (or instruct Geany to do so if possible) by running

        g++ /path/to/your/file.cpp /path/to/Trill-Linux/lib/Trill.cpp -I /path/to?Trill-Linux/lib -o /path/to/binaryoutputfile

        Grumpy_Mike As this is my first time using Geany I tried a Hello World example where I had to pull in external libraries and that worked fine

        what process did you use to "pull in external libraries"? That may give some insights on how to do the above. However, if it was using shared libraries, the process would be somewhat different here.

          Thanks for that.

          giuliomoro what process did you use to "pull in external libraries"?

          Just simply use a statement #include <library_I want> just like the #include <Trill.h> in your code. So the other libraries must be in the "right place". I have spent time looking for this place on the web but this is not common knowledge, or at least easily found on a search engine.

          However, I have managed to get it to compile with a few changes. First off I added the file I2C.h to the editor window. Then I added the Trill.h, Trill.cpp and I2C.h into the same folder as the general-print.cpp file.
          Next I had to make the first two lines of your general-print.cpp file look like this
          #include "Trill.h"
          #include "Trill.cpp"
          Then I has to change the second line of the Trill.h file to read
          #include "I2C.h"
          Finally I had to change the Set Build Commands so the Execute Command read "./e%" 1 'bar'
          When I compiled this I got a whole host of warnings about mixed signedness where your code had mixed up signed and unsigned ints in logical comparisons.
          There was also two warnings about mixing polymorphic types.

          Anyway it builds no if anyone else is having the same problem. Perhaps not the neatest solution, but it functions.
          Thanks again for your input.

            Grumpy_Mike When I compiled this I got a whole host of warnings about mixed signedness where your code had mixed up signed and unsigned ints in logical comparisons.

            it may be that the compiler you are using is more pedantic than the one I've been using. I will make an effort to clean it up.

            Grumpy_Mike ust simply use a statement #include <library_I want>

            If the header file you include is in the right place (typically /usr/include/ and /usr/local/include), then this would work (step 1 above). However, this is only sufficient if the library is header-only (i.e.: the whole content of the library is contained in the header file), otherwise you'd have to specify that the library needs to be linked in (the equivalent of step 2 above for pre-compiled shared or static libraries). For instance, one would #include <sndfile.h> and then tell the linker to use the pre-compiled shared library libsndfile with -lsndfile. However, Trill is not bundled as a shared or static library, hence the procedure is slightly different. It's also possible your editor does some non-standard second-guessing magic to automatically do that for you, I don't know this. Anyhow, it seems that you have found a valid workflow, so that's good.

            Grumpy_Mike Finally I had to change the Set Build Commands so the Execute Command read "./e%" 1 'bar'

            As a side note, as you now mention there is a way to set the build commands, you could probably use this feature to do what I specified in the previous posts as points 1 and 2.

            giuliomoro changed the title to Trill with Geany editor on the Raspberry Pi .