0

https://www.element14.com/community/thread/37836/l/reverse-engineered-sensorso-with-source

https://github.com/larsch/rpi-mems-sensor

Hello Everyone :)

I have a raspberry V1 and a NXP senseboard, I attached all the links above. I want to code in C for the synergy with QT. I follow these instructions and have successfully created libmemmsensor.a file.

I am now running into trouble on how to compile and run the code with the linking involved!

I tried:

gcc -o test1.exe mma8491q.c mma8491.o 

Result: xxx undefined reference to xxx

I also tried:

gcc -c mma8491q.c mma8491q.o 

Result linker input file unused because linking not done

Has anyone coded the NXP sensboard using C?

I have tried to research how linking and compiling work however it's driving me mad, any help is appreciated!

All the best, SerialMadMan

0

the compile step is not the source of your problem. however, it should look similar to:

gcc -c mma8491q.c -o mma8491q.o -I<pathTolibraryHeaderFile

I strongly suggest you keep the compile step and the link step separate

The link step should look similar to:

gcc -o test1.exe mma8491.o -L<pathToLibrary> -lmemmsensor

And, unless your preference is to use static libraries (massively expands the size of the executable,) I suggest generating a file:

libmemmsensor.so

So your code can use dynamic library accessing

Note: the Makefile has a few problems, suggest:

CFLAGS := -Wall -Wextra -pedantic -Wconversion -std=gnu99
CC := /usr/lib/gcc
RM := /usr/lib/rm
# Uncomment this for Raspberry V1
# CFLAGS += -DI2C_V1

SENSOR_SRC = mpl3115a2.c mma8491q.c mag3110.c
SENSOR_OBJ = $(SENSOR_SRC:.c=.o)
SENSOR_HDR = $(SENSOR_SRC:.c=.h)

.PHONY: all
all: libmemssensor.a libmemssensor.so

.PHONY: headers
headers: $(SENSOR_HDR)

%.o: %.c %.h
    $(CC) $(CFLAGS) -c $< -o $@

%.h: %.c
<tab>cproto $< > $@

libmemssensor.a: $(SENSOR_OBJ)
<tab>ar r $@ $(SENSOR_OBJ)

libsensor.so: bcm2835.c $(SENSOR_SRC)
    $(CC) $(CFLAGS) -fpic -shared -o $@ $^

.PHONY: clean
clean:
<tab>rm -f $(SENSOR_OBJ) libsensor.so libmemssensor.a
  • tthanks for your answer, im now going to try and use pyqt with the python code, rather than c – SerialMadMan Mar 20 '16 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.