melexis / mlx90632-library

MLX90632 library for the Melexis 90632 Infra Red temperature sensor.
Apache License 2.0
42 stars 15 forks source link

linker Error in Compilation with -I flag #47

Open saimazaidi08 opened 1 year ago

saimazaidi08 commented 1 year ago

as written in instructions "Definitions are found in library inc/ folder and you need to point your compiler -I flag there."

I have written the following command in the terminal gcc -o my_program mlx90632.c mlx90632_extended_meas.c -I./inc

in which I'm getting the following response with warnings and errors

In file included from mlx90632.c:32: ./inc/mlx90632.h:68:2: warning: "Using default BITS_PER_LONG value" [-W#warnings]

warning "Using default BITS_PER_LONG value"

^ 1 warning generated. In file included from mlx90632_extended_meas.c:31: ./inc/mlx90632.h:68:2: warning: "Using default BITS_PER_LONG value" [-W#warnings]

warning "Using default BITS_PER_LONG value"

^ 1 warning generated. Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable "_mlx90632_i2c_read", referenced from: _mlx90632_start_measurement in mlx90632-e77c9c.o _mlx90632_read_temp_ambient_raw in mlx90632-e77c9c.o _mlx90632_read_temp_object_raw in mlx90632-e77c9c.o _mlx90632_start_measurement_burst in mlx90632-e77c9c.o _mlx90632_init in mlx90632-e77c9c.o _mlx90632_addressed_reset in mlx90632-e77c9c.o _mlx90632_get_measurement_time in mlx90632-e77c9c.o ... "_mlx90632_i2c_write", referenced from: _mlx90632_start_measurement in mlx90632-e77c9c.o _mlx90632_start_measurement_burst in mlx90632-e77c9c.o _mlx90632_init in mlx90632-e77c9c.o _mlx90632_addressed_reset in mlx90632-e77c9c.o _mlx90632_write_eeprom in mlx90632-e77c9c.o _mlx90632_erase_eeprom in mlx90632-e77c9c.o _mlx90632_unlock_eeporm in mlx90632-e77c9c.o ... "_msleep", referenced from: _mlx90632_start_measurement_burst in mlx90632-e77c9c.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could anyone please tell me how to resolve these errors? also can then I be able to use the library in Arduino? p.s. I am a beginner in coding, so if you feel there could be even a basic error from my side please let me know. Thank you

Letme commented 1 year ago

Hi, You are compiling using normal gcc, so I assume you wanted to run this on your PC instead of Arduino?

The bits_per_long definition is to allow the usage of different CPU architecture, because it affects the square root calculations that are preformed by the driver. Usually, most embedded CPUs are 32 bit, but as you can see from your PC it is 64 bit. So that define is a warning because you can leave it undefined for your PC, but I suggest you define it to align with what you are doing.

The library needs a few external functions to be defined, primarly for i2c communication and for some delays (msleep). You can read more details about what you need to implement to enable communication https://melexis.github.io/mlx90632-library/group__mlx90632___a_p_i__depends.html

If you will use this library with Arduino you just need to define these functions and then add the compile and link of the library with your Arduino code. I am not sure how you are currently compiling your sources for Arduino, but the above command is from your PC's GCC compiler, not for Arduino.

karelv commented 1 year ago

Note: For arduino example, please have a look here: https://github.com/melexis/i2c-stick/blob/main/i2c-stick-arduino/