Error while using custom library "undefined reference" [AVR] - eclipse

I am using Eclipse in order to program a PID line follower robot. The microcontroller used is an Atmega328P. For that, I am using one QTR-8RC IR sensor, by Pololu and two modified servos for continuous rotation. I and my partner decided to use the Pololu AVR library since it contains functions specifically for servo control and for the IR sensor.
The problem is Eclipse does recognize the library but it does not compile.
Eg:
#include <pololu/orangutan.h>
#include <pololu/3pi.h>
#include <pololu/qtr.h>
#include <pololu/encoders.h>
unsigned char qtr_rc_pins[]={IO_D2,IO_D3,IO_D4,IO_D5,IO_D6,IO_D7}; //Setup Qtr pins
void main(){
qtr_rc_init(qtr_rc_pins,6,2000,255); //starts qtr
while(1){} //does nothing
Whenever I try to compile this eclipse gives me the following error:
undefined reference to `qtr_rc_init'
More information on the Pololu AVR library.

The undefined reference error you are getting can be solved by adding -lpololu_atmega328p to your linker flags. For more information about what compiler and linker options you need, see the "Using the Pololu AVR Library for your own projects" section in the user's guide you linked to.

Related

OpenCL program showing errors. What can be a possible solution?

I am getting certain errors as shown in the image below. I think there is a problem with the setting up of environment. I am new to this and couldn't figure out how to correct it. Please help.
enter image description here
You try to #include <CL/cl.hpp>, which is not installed with Your OpenCL implementation, check if the #include <CL/cl2.hpp> is (see https://github.com/KhronosGroup/OpenCL-CLHPP).
If You otherwise don't make usage of the OpenCL C++ Wrapper API (see Appendix D in OpenCL 1.2), then You may want to instead include <CL/cl.h> or better yet (to be portable to Apple MacOS):
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif

One default MTLLibrary from multiple .metal files (compute kernel and CIKernel implementations)?

In migrating custom Core Image filter kernels to Metal Shading Language, I encountered an error with building the default Metal library (default.metallib):
metallib: error: exactly one input file required
I was under the impression these could be in separate .metal files. Attempting to merge them into one file leads to this error:
Metal library creation failed: Error Domain=MTLLibraryErrorDomain Code=3 "Filters module must contain no vertex/fragment/kernel functions but contains 1 kernel function"
Namespacing to metal and to coreimage prevent the compute kernel from showing up as an available function in the default library.
Found this SO answer, which recommends building separate libraries:
Metal: vertexFunction defined in .metal file becomes nil once setting Compiler and Linker Options for MSL cikernel
You may create multiple Foo.metal and Bar.metal files.
Just don't add them as linker targets.
Instead #include "Foo.metal" and #include "Bar.metal" in a Main.metal file.
And only add the Main.metal file as linker target.
That way there is only one .metal file, which includes all the other .metal files. Simple.
Therefore the content of the Main.metal file may very simply look like:
#include "Foo.metal"
#include "Bar.metal"
You can’t use the default Metal build pipeline for compiling multiple .metal files containing Core Image kernels into one library right now. The linker doesn’t allow merging multiple .air files into one .metallib when setting the -cikernel flag.
You either have to put all your kernels into one .metal file or use the solution I posted in the answer you linked to above.

stm32f469 FreeRTOS+STemWin with CubeMX and keil: Bad operand types (UnDefOT, Constant) for operator (*

I'm making project generated with STM32CubeMX for stm32f469i-disco.
I have based setup on "FreeRTOSconfig.h" from "Demonstration" project in STM32CubeFWF4V1.16.0 repo. Fresh project from CubeMX compiles without problems, but after adding STemWin lib "STemWin532_CM4_OS_Keil_ot.lib" I get the error
"..........\Middlewares\ThirdParty\FreeRTOS\Source\portable\RVDS\ARMCM4F\port.c(507):
error: A1586E: Bad operand types (UnDefOT, Constant) for operator ("
Interesting fact is that "Demonstration" compiles without this error.
How do I get the project configured:
In CubeMX:
Add periphs needed: DMA2D, DSIHost, FMC etc.
Add BSP drivers for touchscreen etc.
Now, it copiles without problems.
Clone "Clock Configuration" based on "Demonstations"
In "Configuration" tab I clone all configuration based on code from "Demonstrations"
Then in Keil:
5. I update Include Path in target options.
Add all STemWin files and when i try to compile:
"...Bad operand types..."
When I disable freertos in CubeMX and add non-OS STemWin lib it compiles without problems.
When I try to compile non_OS STemWin lib with FreeRTOS enabled, it fails with the same message.
What have I tried to do?
Update port.c. Nothing changed.
Am I missing something while creating project?
After spending 2 days to find out what might be the reason for this error, I just found it and my project now compiles with FreeRTOS enabled and all the other sources used initially. Well, it's apparently a recursive include for stm32f4xx_hal.h file. I have added some modules from the demo package and those have some dependencies. Because I wanted to strip out some functions from some modules, I have manually added the includes/resources for the functions needed, which has contributed to that error, as I did not add any guards to my includes.
The offending line was in port.c file, and the error was because of a wrong constant value passed to the assembly line 483: mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
Replacing configMAX_SYSCALL_INTERRUPT_PRIORITY with any numeric value has helped in compiling the code, but I thought I should not leave it like that and it would be much better if I found out the reason for the problem.
More could be found here:
https://community.st.com/thread/44751-portc483-error-a1586e-bad-operand-types-undefot-constant-for-operator
I got a same problem while building a Nucleo-F401RE board firmware with CubeMX 4.25.
This problem started just after setting LL driver use (Low-Level driver) instead of HAL in a CubeMX setting dialog.
I think this problem is from complicit in C definition of header file.
Including LL driver header may change __NVIC_PRIO_BITS definition in somewhere.
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4
#endif
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
Changing __NVIC_PRIO_BITS to 4 in a generated source code will solve the problem.
/* mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY */
mov r0, #(configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - 4))

Cuda eclipse and time.h, Symbol 'CLOCK_PROCESS_CPUTIME_ID' could not be resolved although program runs

I admit, this is not really a problem, but more an annoying thing: basically in the Eclipse editor, installed by the Cuda toolkit, I am using this function:
/* Get current value of clock CLOCK_ID and store it in TP. */
extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
as the following:
clock_gettime((clockid_t)CLOCK_PROCESS_CPUTIME_ID, &time1);
The "problem" is that CLOCK_PROCESS_CPUTIME_ID is not resolved, and then the whole project appears as containing some error, but if I compile and run, no problem at all
I have included this
#include <time.h>
#include <iostream>
I included also the rt library. How do I make the error go away?
You need to add your includes to your project's preferences:
Right click on your project, choose General/Paths and Symbols. There, you can add your custom include directories that will be browsed by Nsight for symbols.

OpenCV project on iPhone - opencv.hpp building issue

I've cloned https://github.com/niw/iphone_opencv_test and tried to replace
#import <opencv2/imgproc/imgproc_c.h>
#import <opencv2/objdetect/objdetect.hpp>
with
#import <opencv2/opencv.hpp>
in OpenCVTestViewController.m file. But XCode threw following error:
iphone_opencv_test/opencv_device/include/opencv2/opencv.hpp:55:10: fatal error: 'opencv2/calib3d/calib3d.hpp' file not found [2]
#include "opencv2/calib3d/calib3d.hpp"
So, I've tried to remove the line #include "opencv2/calib3d/calib3d.hpp" from the opencv.hpp file. The error below was thrown:
iphone_opencv_test/opencv_device/include/opencv2/ml/ml.hpp:2075:10: fatal error: 'map' file not found [2]
#include <map>
I've also tried to change .m to .mm, but it seemed futile. Where I'm wrong?
There's a conflict between OpenCV's MAX/MIN macros and Cocoa's MAX/MIN. It leads to strange errors like this one at compile time. To bypass this problem, you can either:
1. add at the top of the pre-defined header file
2. totally decouple opencv and obj-c code, so that no .m/.mm file includes . This can be done for example by using boost GIL in-between, or using custom vanilla C++ classes to pass image data from Cocoa frameworks to opencv C++ image processing classes.