Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Trying to call metal_spi_get_device in a c++ class #628

Description

@Emil808

Hi, I'm trying to make a device driver and want to use the metal spi API. When I make a c++ class and try to use metal_spi_get_device, compiling will result in an undefined reference. Is it something with the makefile?

I back track and tried it with something simple, I have these:

main.c

#include "func.h"
int main(){
func_init(); 
return 0; 
}

func.h

#ifdef __cplusplus
    extern "C" {
#endif

void init_func(void); 

#ifdef __cplusplus
}
#endif

func.cpp

#include "func.h"
#include <metal/spi.h> 

#ifdef __cplusplus
extern "C" {
#endif 

void init_func(void){
metal_spi_get_device(1); 
}

#ifdef __cplusplus
}
#endif

makefile

ROGRAM ?= sandbox

CFILES = $(wildcard *.c) 
CXXFILES= $(wildcard *.cpp)
OBJFILES = $(CFILES:.c=.o) 
CXXOBJFILES = $(CXXFILES:.cpp=.o)


$(PROGRAM): $(OBJFILES) $(CXXOBJFILES) #$(wildcard *.c) $(wildcard *.h) $(wildcard *.S) $(wildcard *.cpp)
	
	$(CXX) $(CXXFLAGS)  -Iinclude  $(OBJFILES) $(CXXOBJFILES)  $(LDFLAGS) -lstdc++ $(LOADLIBES) $(LDLIBS) -o $@
	
%.o : %.c %.cpp
	
	$(CXX) $(CXXFLAGS) -c $@ $<
clean:
	rm -f $(PROGRAM) $(PROGRAM).hex $(OBJFILES)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions