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
Related
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.
I've implemented a piece of code with Eigen and I would like Eigen to use BLAS and LAPACK .
I've seen here, that is possible but I don't know how or where to put those values/directives in the code.
I have to expecify somewhere the value EIGEN_USE_BLAS but I have no idea where.
I've seen that Eigen's source includes the code of BLAS and LAPACK, but I completelly ignore if it uses it by default or what. I'm using Eigen 3.3.3.
You don't put those directives in the code, you compile your code with these macros. For example:
LAPACK_FLAGS=('-D EIGEN_USE_LAPACKE=1 -lm -lblas -llapack -llapacke')
g++ --std=c++11 eigenSVD.cpp -o eigenSVD.cpp ${LAPACK_FLAGS[#]}
Take a look at Eigen/SVD, if your code is compiled with EIGEN_USE_LAPACKE, you see Eigen-lapacke interface and lapacke header files will be included.
#if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT)
#ifdef EIGEN_USE_MKL
#include "mkl_lapacke.h"
#else
#include "src/misc/lapacke.h"
#endif
#include "src/SVD/JacobiSVD_LAPACKE.h"
#endif
Well, I have found the solution
Include in your .h file the following:
// includes to make Eigen use BLAS+LAPACK
#include <complex>
#define EIGEN_SUPERLU_SUPPORT
#define EIGEN_USE_BLAS
#define EIGEN_USE_LAPACKE
#define LAPACK_COMPLEX_CUSTOM
#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
// includes to call Eigen
#include <Eigen/Sparse>
#include <Eigen/StdVector>
The complex includes are necessary regardless of the use of complex matrices because LAPACK demmands you to define what you call a complex type.
Here is the code, straight out of the sample. 64 bit install, x64 build.
#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
PGDLLEXPORT Datum plsample_call_handler(PG_FUNCTION_ARGS); // <-- the answer!!
PG_FUNCTION_INFO_V1(plsample_call_handler);
Datum
plsample_call_handler(PG_FUNCTION_ARGS)
{
Datum retval;
retval = 42;
return retval;
}
It compiles and links OK. Here is the SQL:
CREATE FUNCTION plsample_call_handler() RETURNS language_handler
AS 'TryPostgresPl.dll'
LANGUAGE C;
CREATE LANGUAGE plsample
HANDLER plsample_call_handler;
And here is the error message.
ERROR: could not find function "plsample_call_handler" in file "C:/Program Files/PostgreSQL/9.5/lib/TryPostgresPl.dll"
SQL state: 42883
So near and yet so far. Really no idea where to look.
Edited to show the answer as per Nick Barnes. Note that a peek with depends.exe showed 2 exports previously, now 3.
The sample in the Postgres docs is squarely targeted at Linux environments; apparently there's a bit more involved in Windows. There is an excellent article by #CraigRinger which explains how to go about it in Visual Studio.
In this case, it looks like you just need to add the following function prototype:
PGDLLEXPORT Datum plsample_call_handler(PG_FUNCTION_ARGS);
For me (Postgres 13 x64, VS2019, MSVC 14.27), it was enough to just add PGDLLEXPORT in front of PG_FUNCTION_INFO_V1, i.e:
PGDLLEXPORT PG_FUNCTION_INFO_V1(my_func);
Looking closer, this expands to the equivalent of:
PGDLLEXPORT extern Datum my_func(PG_FUNCTION_ARGS);
... plus a bunch more stuff
You'll notice that's very similar to what's being done manually in the accepted answer, so this way seems to avoid some duplication. The only difference is the extern keyword; to be honest I don't know enough about C to know why putting PGDLLEXPORT before extern is still valid (rather than after it as I see in all the examples), but the compiler doesn't complain and the extension works.
YMMV especially if these macros change in the future.
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.
I have some C code in an iOS project that I would like to optimize using GCD. Currently I can only get my code to compile if change my C file to an Objective-C file and import the Foundation framework. What do I have to include in my C file to get access to GCD?
I've tried:
#include <dispatch/dispatch.h>
but that doesn't seem to work it always complains about code blocks having the ^ character
You'll need to tell the compiler to enable Blocks with the -fblocks flag. You'll also need to use a compiler that understands blocks (Clang, for one).
You might need to;
#include <Block.h>
But it's not something I've done myself so could be wrong here.