run Makefile in a modified example app
Brought to you by:
skarg
Hello,
Can the samples in the "apps" directory be compiled individually? Or how would one go about creating a custom app? Am new to this project so not a lot of wisdom here...
When I glone the repo onto raspi pi linux it compiles fine with a make clean all
in the root directory of the clone project and I can run the readprop
example app just fine to get a sensor reading of a device on my test bench... but when I try to modify the code or even just run make clean
and then make
in that same app/readprop
directory i get these errors:
bbartling@benspi:~/bacnet-stack/apps/readprop $ make clean
rm -f core bacrp main.o /bacnet/basic/object/client/device-client.o /bacnet/basic/object/netport.o bacrp.map
bbartling@benspi:~/bacnet-stack/apps/readprop $ make
cc -c main.c -o main.o
main.c:38:10: fatal error: bacnet/bacdef.h: No such file or directory
38 | #include "bacnet/bacdef.h"
| ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:27: main.o] Error 1
Is this a linking error? Any tips appreciated am curious to work with some existing code to get used to the project if possible... Thanks!
Anonymous
The apps/ example projects rely on some defines in apps/Makefile and would need to 'start' there. You can see the example of this in the root Makefile:
-s means 'silent'
-C mean to run make from that folder
$@ is shorthand for the recipe name
The recipe for each of the apps/ is in the apps/Makefile after some common defines are configured.
Most of the example apps rely on the library build, which simply reduces the size of the executable and makes it easier for maintaining.
For a new apps/ project, just add a recipe into apps/Makefile to build it, and include another apps/project-name/Makefile that finishes the custom build.
Alternately, you can create your own Makefile and add only the C files you need with the defines that you need. Most of the microcontroller ports do this.
Ah okay thanks Steve I think I am figuring it out now! Taking a course in C on coursera helps a bit too : )
I ended up making a duplicate of the
app/readprop
and named itbensreadprop
.Where then in the project root directory Makefile I added:
.PHONY: bensreadprop bensreadprop: $(MAKE) -C apps bensreadprop
And in the
apps
directory Makefile I added.PHONY: bensreadprop bensreadprop: $(BACNET_LIB_TARGET) $(MAKE) -B -C bensreadprop
When then in the root directoy when I run a
make clean
and amake bensreadprop
it all appeared to compile well. I also had to add my app into theSUBDIRS
but I think I am good for the time being if these steps seems legit!Hi Steve,
Has anyone ever ran across a compile error
undefined symbol: bip_cleanup
Would there be a bip_cleanup.c file or something similar in the project directory I should be refencing?
Thanks!
For the example apps, the OS datalink is chosen in apps/Makefile and the files built for the specific datalink chosen in apps/lib/Makefile.
The datalink.h module uses C macros to redefine the datalink specific functions, most (all) of which are in ports/xyz folder for the specific OS/non-OS datalink. For example, BACDL_BIP:
In ports/linux/bip-init.c: