Do i need to use different library in Arduino? - keyboard

I was making an project and i need to use Arduino UNO as HID. So, i installed Keyboard library (version 1.0.4) from library manager and write just basic program in new sketch to test it:
#include <Keyboard.h>
void setup() {
// initialize the Keyboard library
Keyboard.begin();
}
void loop() {
Keyboard.press('A');
delay(1000);
Keyboard.release('A');
delay(1000);
}
I compiled it, but it gives me errors:
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino: In function 'void setup()':
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino:4:3: error: 'Keyboard' was not declared in this scope
Keyboard.begin();
^~~~~~~~
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino: In function 'void loop()':
C:\Users\medic\AppData\Local\Temp\.arduinoIDE-unsaved202314-8852-isv7gn.mjro\sketch_feb4a\sketch_feb4a.ino:8:3: error: 'Keyboard' was not declared in this scope
Keyboard.press('A');
^~~~~~~~
exit status 1
Compilation error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
I was searching on the internet and find a solution to install other libraries. I installed other libraries from GitHub and some sites to try them, but it didn't work.

Related

Problem requiring native c++ addon from electron

Error when I require a Native Addon C++ from electron that works fin from Node.js
Recently I developed my first native C++ Addon for node that works fine with my node project (node version 10.15.0)
The Addon has been built using XCode, which project has been generating using CMake.
I´m having the following error when I use the same native C++ addon from my Electron app.
dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
Expected in: flat namespace
dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
Referenced from: /Users/vicentvidal/Documents/Desarrollo/DASNet2/dasaudio/build/DASNetAddon.node
Expected in: flat namespace
As I can see the problem appears just when I call from my Electron App
const addon = require('bindings')('DASNetAddon');
which call the following C++ code
static NAN_MODULE_INIT(Init) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("StreamingWorker").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(2);
SetPrototypeMethod(tpl, "sendToAddon", sendToAddon);
constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
Nan::Set(target, Nan::New("StreamingWorker").ToLocalChecked(),
Nan::GetFunction(tpl).ToLocalChecked());
}
My Electron version is 3.0.10
My Nan version 2.12.1
My bindings version 1.3.1
Does anybody has any suggestion?
I'm not positive that this is the problem but it is possible that, because the function template is missing your C++ class name, the namespace is coming from somewhere else. Here's one of my Nan Init() functions. The line following the // Prepare constructor template qualifies the New argument with a class namespace.
void Metadata::Init(v8::Local<v8::Object> exports) {
Nan::HandleScope scope;
// Prepare constructor template
v8::Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(Metadata::New);
constructor.Reset(ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(2);
ctor->SetClassName(Nan::New("Metadata").ToLocalChecked());
// Prototype
Nan::SetPrototypeMethod(ctor, "copy", Metadata::copy);
Nan::Set(exports, Nan::New("Metadata").ToLocalChecked(), ctor->GetFunction());
}
I haven't tried running/loading in an Electron environment, nor on a Mac, so I can only say this works fine on Linux. But because your error message refers to "FunctionTemplate3New" it's a guess.

Sony device has different kernel config than source. Why?

I tried to build simple kernel module (using source downloaded from developer.sonymobile.com) but after compiling i can't insmod it: Unknown symbol __gnu_mcount_nc so i founded a solution and I wrote another module using assembler and I exported this function. After this module insmoded correctly but I see in lsmod that all modules are permament. I have a problem with simple filesystem (Permission denied - default action when pointer is null), on PC this code works without any errors.
I guess the config is wrong in source code, (probably offset of some fields in structure is another than in device).
Version of built is: 24.0.A.5.14 (downloaded from developer.sonymobile.com site).
Can I do anything to get this same configuration as in device?
I had not /proc/config.gz so I can't get it easily.
Module source:
#include <linux/module.h>
#include <linux/kernel.h>
int __init example_init(void)
{
printk("Hello world!\n");
return 0;
}
void __exit example_exit(void)
{
printk("example module exit\n");
}
module_init(example_init);
module_exit(example_exit);
And I see Hello World! in dmesg but module is still permament.
Source of __gnu_mcount_nc i found here: http://doc.ironwoodlabs.com/arm-arm-none-eabi/html/getting-started/arm-mcount.html
Do you compile with with profile enable -pg flag when you build the kernel module? It looks that way.
The kernel module Makefile for CFLAGS.

VS2013 VC++ libcurl LNK2028 LNK2019 linking errors

I'm trying to get Libcurl working in my VC++ project on VS2013 Community. I've been toiling with this for many hours, and I've tried essentially everything on Stack and Google about it, to no avail.
My most recent attempt was sparked by this answer, that mentions libcurl as a Nuget package. This is good, because it comes with all of the .lib files required. I have however run into the same problem as this fellow, in that I'm getting a linker error.
I'm importing the following libraries as 'Additional Dependencies' in the Project Configuration settings under Linker -> Input:
libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib;
Obviously, each one of these .lib files is in a different directory inside the nuget package folder inside the project folder, so under Linker -> General my 'Additional Library Directories' is set to:
"PATHTOPROJECT\packages\curl.7.30.0.2\build\native\lib\v110\x64\Release\static";
"PATHTOPROJECT\packages\zlib.1.2.8.1\build\native\lib\v110\Win32\Release\static\cdecl";
"PATHTOPROJECT\packages\openssl.1.0.1.21\build\native\lib\v110\x64\Release\static\cdecl";
"PATHTOPROJECT\packages\libssh2.1.4.3.1\build\native\lib\v110\x64\Release\static\cdecl";
I am trying to use static libraries, because I don't want to drag .dll's with my project executable if I can avoid it. It's also worth noting that my most recent attempt at using libcurl also includes SSL and whatnot, but I don't actually need those extras. Really, I just need a static libcurl library, but I can't find or compile one it seems.
In my code, I'm also using this include: #include "curl/curl.h"
I've also added the Additional Include directory correctly under 'Additional Include Directories' under C/C++ -> General:
PROJECTPATH\packages\curl.7.30.0.2\build\native\include
Now, this all compiles fine as long as I don't try and use curl in the project code.
So, the errors when I do try and use curl in the code:
CURL *curl;
curl = curl_easy_init();
That piece of code generates these errors:
1>Main.obj : error LNK2028: unresolved token (0A000453) "extern "C" void * __cdecl curl_easy_init(void)" (?curl_easy_init##$$J0YAPAXXZ) referenced in function "private: class System::String ^ __clrcall Project::Main::CurlRequest(class System::String ^,class System::String ^,class System::String ^,class System::String ^)" (?CurlRequest#Main#Project##$$FA$AAMP$AAVString#System##P$AAV34#000#Z)
1>Main.obj : error LNK2019: unresolved external symbol "extern "C" void * __cdecl curl_easy_init(void)" (?curl_easy_init##$$J0YAPAXXZ) referenced in function "private: class System::String ^ __clrcall Project::Main::CurlRequest(class System::String ^,class System::String ^,class System::String ^,class System::String ^)" (?CurlRequest#Main#Project##$$FA$AAMP$AAVString#System##P$AAV34#000#Z)
There is of course more to my curl using code, but that bare minimum shows the basics of the linking error. What can I do to fix this? As I mentioned before I've tried a whole range of solutions, some of which I'll list below:
Many answers to the questions regarding problems using libcurl in VS projects mention downloading libcurl from http://curl.haxx.se/latest.cgi?curl=win32-devel-msvc, but that link doesn't work as of now, so I can't use it.
More answers say to just compile libcurl from source. The source comes with .vcproj files, none of which compile for me without hundreds of errors, so that's out.
Solved.
This Github project is a .bat file that downloads the libcurl source, compiles it, and makes the libraries (both static and dynamic). Importing the static library created by this (libcurl_a.lib) and using it in my project along with the include directory has worked.
I'll leave this question with an unaccepted answer in case someone can provide other helpful steps that would have fixed the problem I had in using the nuget package installation.
Finally.

Code Blocks output doesn't execute linux

I am pretty new to linux and i wanted to try to make a small opengl
program just as a test. I'm using glfw and i made a very easy test:
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
using namespace std;
int main()
{
if (!glfwInit())
{
return -1;
}
GLFWwindow *window = glfwCreateWindow(800, 600, "Het werkt", NULL, NULL);
if (!window)
{
glfwTerminate();
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
glfwSwapBuffers(window);
}
}
Now if i try to run this in Code::Blocks itself, it runs fine, debug, release, it doesn't matter, it works. But when i try to execute it outside Code::Blocks, it goes wrong. If i double click the executable nothing happens, and if i ./ExecutableName in the terminal it gives me this error:
error while loading shared libraries: libglfw.so.3: cannot open shared object file: No such file or directory
All of the libs are in the same directory as the executable, so i don't get why it gives this error.
By the way i'm working on Linux Mint.
Thanks in advance for your help!
You should place those libraries in your $PATH. Issue a echo $PATH command and see if you can find the libraries in there (within those paths) - if not, you will have to put them in there someway. I'm not sure if you can just copy-paste the libraries in there, so probably you may want to search for them using your linux distribution's package management system. As you are using Linux Mint, maybe you could try searching with sudo aptitude search glfw and then try installing the corresponding packages.

undefined reference to `siglongjmp' error when compiling android cocos2dx project for x86 architecture

I am trying to build a cocos2dx project for x86 android architecture but i get the following error when i try to compile it.
./obj/local/x86/curl.a(hostip.o):(.text.alarmfunc+0x21): undefined reference to `siglongjmp'
./obj/local/x86/curl.a(hostip.o): In function `Curl_resolv_timeout':
(.text.Curl_resolv_timeout+0x156): undefined reference to `sigsetjmp'
When i googled the error i found that it has been reported as issue 19851 in google code. They have not made any fixes yet but they had suggested to add a modified libc.so and sched.h file. I tried this and it did not work.
Can anyone tell me how to fix this.
Try adding this code to one of your .c or .cpp modules:
#if __i386 && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include <setjmp.h>
#ifdef __cplusplus
extern "C" {
void siglongjmp(jmp_buf env, int val);
int sigsetjmp(jmp_buf env, int savemask);
}
#endif
void siglongjmp(jmp_buf env, int val)
{
longjmp(env, val);
}
int sigsetjmp(jmp_buf env, int savemask)
{
return setjmp(env);
}
#endif
Fixed the issue by copying libc.so attached in response to issue 19851 to latest version of ndk. I was using ndkr8 and copying the libc.so file to ndkr8d fixed the issue.
Go to the Android NDK page & follow the download and installation instructions.
https://developer.android.com/tools/sdk/ndk/index.html
I'm on OSX, android-ndk-r10e-darwin-x86_64.bin fixed the error for my setup.

Resources