-1

https://github.com/jdourlens/FirmataC I am trying to install this to use on Linux mint, but I don't know how to install it to use. I have downloaded the files and included the headers and source files in a "project" in codeblocks, but it doesn't compile, keeps going into more and more includes within the files to not be found. Personally, alot of github projects/folders for libraries I always find it incredibly hard to use or install it on both windows/linux. If its a generic and common way of installing these libraries, how do I do this?

Errors:

main.c:(.text+0x1b): undefined reference to `firmata_new'
/usr/bin/ld: main.c:(.text+0x2d): undefined reference to `firmata_pull'
/usr/bin/ld: main.c:(.text+0x51): undefined reference to `firmata_pinMode'
/usr/bin/ld: main.c:(.text+0x86): undefined reference to `firmata_digitalWrite'
/usr/bin/ld: main.c:(.text+0x9e): undefined reference to `firmata_digitalWrite'
404 TNF
  • 19
  • 6

1 Answers1

4

The FirmataC project comes with a Makefile, which allows you to build the library. To do so, clone the project and run make in the project directory. Then, you can link to this library when you compile by running gcc main.c -L <path-to-clone-dir> -I <path-to-clone-dir>/inclues -lfirmatac -o main where ` is the path to which you cloned the FirmataC project.

It is also good to note that many Makefiles (but not this one) will provide a make install command, which allows you to install the library on a system level. If you are using a library that allows it, running make install allows you to simply do gcc main.c -l<library-name> -o main.

bisen2
  • 486
  • 1
  • 4
  • 10
  • You may also want to mention `make install` which installs to a standardized include directory, after which the command-line `gcc main.c -lfirmatac -o main` becomes sufficient. – nanofarad Nov 28 '20 at 21:44
  • 1
    @nanofarad, this library actually doesn't provide an install target in their makefile, but I will definitely add that as a note for other libraries. – bisen2 Nov 28 '20 at 21:50
  • Thanks! That works. Just a side question, when running ```make install``` if it installs it on a system level, does that mean that in a ```new project``` in code::blocks, I don't have to do any includes or linker stuff, the ```#include``` will recognise ```firmatac.h``` – 404 TNF Nov 28 '20 at 22:11
  • 1
    I've never used code::blocks, but my guess is you would still need to add `-l` to the compiler flags. It is possible the IDE will do that automatically, but I am not sure about that. – bisen2 Nov 28 '20 at 22:19
  • Just a weird thing i've found. A small snipped of code posted works and then stops working after a few seconds. Its a simple "turn LED on an off every second". The program works for a few loops and then just stops working – 404 TNF Nov 28 '20 at 22:22