I want to log some data to a file. I tried to use ofstream, but this encountered a segmentation fault. I did some research and saw WriteFile was perhaps a better way. However when I compile my C++ app the linker fails.

undefined reference to `WriteFile::~WriteFile()'

I have all the bela libraries included I believe (below). Am I missing something?

LDLIBS=-g -L/root/Bela/lib -lbela -lbelaextra -L../libs/Harmony -lHarmony -L../libs/Protocol -lHarmProt -L../libs/Logger -lLogger -pthread -L/root/Bela/libraries

    I assume you are not using the Bela Makefile? Why is that?

    PaulELong I have all the bela libraries included I believe (below). Am I missing something?

    -L/root/Bela/libraries is simply telling the linker to look into /root/Bela/libraries for libraries (as in: shared (.so) or static (.a) libraries) at link time. This doesn't tell it WHICH libraries to link in. You are already including bela and belaextra, however none of these includes WriteFile (see here for an explanation).

    What you need is the actual WriteFile.o object that should be in /root/Bela/libraries/WriteFile/WriteFile.o. If it's not there, you need to build it with make -f Makefile.libraries LIBRARY=WriteFile, then you can add it to your LDLIBS by turning the line above into:

    LDLIBS=/root/Bela/libraries/WriteFile/build/WriteFile.o -L/root/Bela/lib -lbela -lbelaextra -L../libs/Harmony -lHarmony -L../libs/Protocol -lHarmProt -L../libs/Logger -lLogger -pthread

    (notice I removed -g, as it is ignored by the linker, and so should be the -I flags in there).

    I built WriteFile.o and included it in my LDLIBS line. But now I get this error. I haven't done any research on it yet, but perhaps it's just another simple omission? (output below)

    I'm not using the bela makefile, and I'm not sure if I should or not. In my case I have a project which contains a folder for Bela and the Bela related functionallity. Then I have other folders for other components and devices that work together to accomplish my Harmonizer tool. The project is in git, which makes it easy to work on my development machine and sync back to the bela.

    g++ -g -o Harm ./scOSC.o ./OSCComm.o ./SynthDef.o ./Input.o ./DebugPrint.o ./Patch.o ./LiquidCrystal.o ./OSCRcvmsg.o ./NewController.o ./Harmonizer.o ./SerialComm.o ./GPioHarness.o ./Trigger.o ./HarmP1.o ./RemoteUX.o ./StateInfo.o ./PinControl.o ./Display.o -g -L/root/Bela/lib -lbela -lbelaextra -L../libs/Harmony -lHarmony -L../libs/Protocol -lHarmProt -L../libs/Logger -lLogger -pthread -L/root/Bela/libraries /root/Bela/libraries/WriteFile/build/WriteFile.o
    /usr/bin/ld: /root/Bela/lib/libbela.so: undefined reference to symbol 'rt_fprintf'
    //usr/xenomai/lib/libcobalt.so.2: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    makefile:10: recipe for target 'Harm' failed
    make: *** [Harm] Error 1

    you need to add -lcobalt -L/usr/xenomai/lib. This is needed because WriteFile.o directly uses rt_fprintf(), which is not provided by libbela (as the latter relies on libcobalt for it). What confuses me is that the error in your case seems to come from libbela.so:

    /usr/bin/ld: /root/Bela/lib/libbela.so: undefined reference to symbol 'rt_fprintf'

    but libbela should know where to find that symbol. If I ldd /root/Bela/lib/libbela.so I get:

    	linux-vdso.so.1 (0xbef98000)
    	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6f31000)
    	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0 (0xb6f1f000)
    	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6efb000)
    	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6ee5000)
    	libprussdrv.so => /usr/local/lib/libprussdrv.so (0xb6ed2000)
    	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6dc6000)
    	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d4e000)
    	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6d25000)
    	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c37000)
    	/lib/ld-linux-armhf.so.3 (0xb6f89000)

    so you see it already knows about using libcobalt.

    The proper fix to this would be to have a Bela_printf and Bela_fprintf functions in libbela that simply wrap rt_printf and rt_fprintf, but for now you should just be able to use the fix above.

    EDIT:
    Also, important: the order of the elements on the command line is important. Place all the .o files before the -l... libraries