user1611830
user1611830

Reputation: 4857

failure linking C code

I a ma total noob in C programming. I took some code that throws this error when I run make :

Undefined symbols for architecture x86_64:
  "_rp_osc_adc_sign", referenced from:
      _rp_osc_meas_min_max in worker.o
      _meas_period in worker.o
  "_rp_osc_meas_cnv_cnt", referenced from:
      _rp_osc_meas_convert in worker.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [make_c_app] Error

I am using OS X Yosemite and here's the make file

CC=$(CROSS_COMPILE)gcc
RM=rm

OBJECTS=main.o fpga.o worker.o calib.o fpga_awg.o generate.o fpga_pid.o pid.o

INCLUDE=

#CFLAGS=$(CFLAGS) -Wall -Werror -g
CFLAGS+= -Wall -Werror -g -fPIC $(INCLUDE)
LDFLAGS=-shared


OUT_DIR=../
C_OUT_NAME=$(OUT_DIR)controller.so

all: make_c_app
clean: clean_c_app

make_c_app: $(OBJECTS)
    $(CC) -o $(C_OUT_NAME) $(OBJECTS) $(CFLAGS) $(LDFLAGS)

clean_c_app:
    $(RM) -f $(C_OUT_NAME) $(OBJECTS)

and the method the linker is complaining about

int rp_osc_meas_min_max(rp_osc_meas_res_t *ch_meas, int sig_data)
{
    int s_data = rp_osc_adc_sign(sig_data);

    if(ch_meas->min > s_data)
        ch_meas->min = s_data;
    if(ch_meas->max < s_data)
        ch_meas->max = s_data;

    ch_meas->avg += s_data;

    return 0;
}

Where the error can come from ?

EDIT : rp_osc_adc_sign is defined the following way

inline int rp_osc_adc_sign(int in_data)
{
    int s_data = in_data;
    if(s_data & (1<<(c_osc_fpga_adc_bits-1)))
        s_data = -1 * ((s_data ^ ((1<<c_osc_fpga_adc_bits)-1)) + 1);
    return s_data;
}

Upvotes: 0

Views: 63

Answers (1)

epsilones
epsilones

Reputation: 11609

You should delete the inline tag that is written before the function

rp_osc_adc_sign(int in_data)

rp_osc_meas_cnv_cnt

Upvotes: 1

Related Questions