The Question
Programming Arduino is something new to me - I've included what I believe is relevant, though please comment if more code/info is needed.
I'm creating a sketch that uses the ArduinoHttpClient library installed via the IDE's 'Manage Libraries' option.
Yesterday all was well - sketch compiles.
Today I get the error below. Nothing changed between yesterday and today that I can tell.
I have tried the code on other machines - 2 work, 1 doesn't and I cannot tell what is wrong and don't fully understand the actual error.
Can anybody explain a) what the error means and b) what i might be able to do to resolve it?
Code pieces
In file included from
/Users/me/Documents/Arduino/libraries/ArduinoHttpClient/src/ArduinoHttpClient.h:8:0,
from
/Users/me/Documents/Proj/network-comms/ard-mkr-wifi-1010/box_register.h:1,
from
/Users/me/Documents/Proj/network-comms/ard-mkr-wifi-1010/ard-mkr-wifi-1010.ino:11:
/Users/me/Documents/Arduino/libraries/ArduinoHttpClient/src/HttpClient.h:12:1:
error: expected ',' or ';' before 'static' static const int
HTTP_SUCCESS =0; ^~~~~~ exit status 1 Error compiling for board
Arduino MKR WiFi 1010.
The ArduinoHttpClient.h file is as installed and unchanged:
// Library to simplify HTTP fetching on Arduino
// (c) Copyright Arduino. 2016
// Released under Apache License, version 2.0
#ifndef ArduinoHttpClient_h
#define ArduinoHttpClient_h
#include "HttpClient.h"
#include "WebSocketClient.h"
#include "URLEncoder.h"
#endif
box_register.h at line one just includes the lib
#include <ArduinoHttpClient.h>
HttpClient.h from the Arduino lib is as - includes the line being reported:
// Class to simplify HTTP fetching on Arduino
// (c) Copyright MCQN Ltd. 2010-2012
// Released under Apache License, version 2.0
#ifndef HttpClient_h
#define HttpClient_h
#include <Arduino.h>
#include <IPAddress.h>
#include "Client.h"
static const int HTTP_SUCCESS =0; /// <------ LINE 11
// The end of the headers has been reached. This consumes the '\n'
// Could not connect to the server
static const int HTTP_ERROR_CONNECTION_FAILED =-1;
// This call was made when the HttpClient class wasn't expecting it
// to be called. Usually indicates your code is using the class
// incorrectly
static const int HTTP_ERROR_API =-2;
// Spent too long waiting for a reply
ard-mkr-wifi-1010.ino showing line including box_register
// va_start, va_end
#include <stdarg.h>
#include <WiFiNINA.h>
#include <PubSubClient.h>
#include <RTCZero.h>
#include <WiFiUdp.h>
#include <Wire.h>
#include "./arduino_secrets.h"
#include "./box_register.h" // <----- HERE
#include "./ntp.h"
Related
I have a problem compiling a tss file. Somehow there seems to be a conflict in a type definition, although i include the headers of an official function "Tss2_Sys_GetRandom.c".
In file included from botan_rng.cpp:9:
/home/pi/TPM_Scripts/Scripts/tpm2-tss/src/tss2-sys/sysapi_util.h:67:8: error: using typedef-name ‘TSS2_SYS_CONTEXT’ after ‘struct’
struct TSS2_SYS_CONTEXT;
^~~~~~~~~~~~~~~~
In file included from /home/pi/TPM_Scripts/Scripts/tpm2-tss/src/tss2-sys/sysapi_util.h:12,
from botan_rng.cpp:9:
/home/pi/TPM_Scripts/Scripts/tpm2-tss/include/tss2/tss2_sys.h:26:46: note: ‘TSS2_SYS_CONTEXT’ has a previous declaration here
typedef struct _TSS2_SYS_OPAQUE_CONTEXT_BLOB TSS2_SYS_CONTEXT;
The includes look like this:
1 #include <iostream>
2
3 #ifdef HAVE_CONFIG_H
4 #include <config.h>
5 #endif
6
7 #include "tss2_tpm2_types.h"
8 #include "tss2_mu.h"
9 #include "sysapi_util.h"
10
11 #include <botan/botan.h>
12
13 using namespace std;
14 using namespace Botan;
Does anybody have an idea why this is happenning? The TSS includes are the same as they are in "Tss2_Sys_GetRandom.c", and the GetRandom Function works properly, if i call it in terminal, so why is there a conflict, when i try to compile the exact same include paths.
Tss2_Sys_GetRandom.c looks like this:
/* SPDX-License-Identifier: BSD-2-Clause */
/***********************************************************************;
* Copyright (c) 2015 - 2017, Intel Corporation
* All rights reserved.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "tss2_tpm2_types.h"
#include "tss2_mu.h"
#include "sysapi_util.h"
Thanks for help in advance.
I am working on the communication between a raspberry pi and a kestrel plate (from procerus technologies). Now, I need to receive information from the packages of the kestrel, for this I am using an old code used in a Gumstix. At the time of compiling it gives me the error of the title ("u8" was not declared in this scope). The error is present in several files. For example
I suppose the error is related to the Linux version
#include "dllsetup.h"
#include "type.h"
#include <vector>
#include <linux/types.h>
#include <asm/types.h>
#include <sys/types.h>
#ifndef LINUX
EXTERN_LINK template class DYNAMIC_LINK std::vector<u8>;
#endif
//! Packet Data Type defines for easy writing of code.
typedef std::vector<u8> PacketData;
typedef std::vector<u8>::iterator PacketDataIter;
u8 isn't in the standard but uint8_t is (included in stdint.h and cstdint). Check your includes, verify that you defined u8 somewhere.
I'm looking at the <linux/types.h> kernel header, and I can't find u8. There is a __u8 pulled in via <asm/types.h>, through two more layers of inclusion.
If I compile
#include <linux/types.h>
u8 u;
on Ubuntu 18 with gcc-7.3.0, it suggests this.
test.c:2:1: error: unknown type name ‘u8’; did you mean ‘__u8’?
u8 u;
^~
__u8
I'm developing some additional options for a game (which means I don't have knowledge about whole game's methods, classes etc.).
Anyway, I have been trying to build the project for codes I've developed to test them. I've encountered some DirectX, Windows SDK Version, Compiler problems but managed to solve them.
I've downloaded source codes through SVN, so whole project is actually working. I just couldn't manage to build it in my local laptop or desktop computer.
This time I'm getting xmemory0 error:
Code: C2280
Description: 'std::pair::pair(const std::pair &)':
attempting to reference a deleted function File: xmemory0 Line:840
Code part of the error is:
// xmemory0 internal header (from <memory>)
#pragma once
#ifndef _XMEMORY0_
#define _XMEMORY0_
#ifndef RC_INVOKED
#include <cstdint> /* for uintptr_t */
#include <cstdlib>
#include <limits>
#include <new>
#include <xutility>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma push_macro("new")
#undef new
... // other code lines
template<class _Objty,
class... _Types>
void construct(_Objty *_Ptr, _Types&&... _Args)
{ // construct _Objty(_Types...) at _Ptr
::new ((void *)_Ptr) _Objty(_STD forward<_Types>(_Args)...); // HERE IS GETTING ERROR
}
... // other code lines
I downloaded OpenCV 3.0.0-rc1 and build it using CMAKE-gui 3.2.2 using VS2012 Win64 compiler. Binaries and libraries got generated and I set it up with Qt 64 bit. All programs are working fine except when I try to use the feature cv::LineSegmentDetector it shows a compile error in private.hpp file. The error says
unexpected end-of-line
My code is as follows
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/private.hpp>
#include <opencv2/core/utility.hpp>
using namespace std;
int main()
{
cv::Mat image = cv::imread("C:\\Users\\IMAGE\\Desktop\\PROJ\\SAMPLE.png");
cv::imshow("TEST",image);
cv::waitKey();
cv::LineSegmentDetector lsd;
return 0;
}
And on following the error I found the 2nd line of the following part of the code in private.hpp as error highlighted.
#ifdef HAVE_EIGEN
# if defined __GNUC__ && defined __APPLE__
# pragma GCC diagnostic ignored "-Wshadow"
# endif
# include <Eigen/Core>
# include "opencv2/core/eigen.hpp"
#endif
# if defined __GNUC__ && defined __APPLE__
Please let me know if I am doing some implementation mistake or some changes in the private.hpp can fix this error. I am using windows 8 64 bit.
oh, never try to use something, that is called "private", i guess...
#include <opencv2/opencv.hpp> // includes all others
#include <opencv2/core/utility.hpp> // getTickCount, etc.
int main()
{
// LineSegmentDetector is an abstract class, you can't create an
// instance on the stack, but need to use Ptr and factory:
cv::Ptr<cv::LineSegmentDetector> lsd = cv::createLineSegmentDetector();
return 0;
}
After fixing the previous problem (see my one other question that I have asked). I had declared more classes.
One of these is called CombatAdmin which does various things: (Header file)
#ifndef COMBATADMIN_H
#define COMBATADMIN_H
#include <string> // Need this line or it complains
#include <Player.h>
#include <Sound.h>
#include <Enemy.h>
#include <Narrator.h>
using namespace std;
class Enemy;
class Player;
class CombatAdmin // Code yet to be commented here, will come soon.
{
public:
CombatAdmin();
void healthSet(double newHealth, string playerName);
void comAdSay(string sayWhat);
void playerFindsChest(Player *player,Weapon *weapon,Armour *armour);
void youStoleOurStuffEncounter(Player *player);
void comAdWarning(string enemyName);
void comAdAtkNote(string attack, double damage,string target,string aggresor);
void entDefeated(string entName);
void comAdStateEntHp(string ent, double hp);
void comAdStateScanResults(string enemyName, double enemyHealth);
string doubleToString(double number);
string intToString(int number);
bool isRandEncounter();
void randomEncounter(Player *player,Sound *sound,Narrator *narrator);
bool combatRound(Player *player, Enemy *enemy, Sound *sound, bool ran);
void playerFindsItem(string playerName,string itemName,double itemWeight,double playerWeight);
void playerFindsGold(string playerName,double coinCnt,double playerCoinCnt);
};
#endif // COMBATADMIN_H
It is then instanced in the main.cpp file like this: (Snippet of the main.cpp file)
#include <iostream> // Required for input and output
#include <Item.h> // Item header file.
#include <Weapon.h> // Header files that I have made for my classes are needed for this program
#include <sstream> // Needed for proper type conversion functions
#include <windows.h> // for PlaySound() and other functions like sleep.
#include <time.h> // Needed to seed the rand() function.
#include <mmsystem.h> // Not sure about this one, possibly defunct in this program.
#include <stdio.h> // Needed for a similar kind of output as iostream for various functions error msgs.
#include <irrKlang.h> // The header file of the sound lib I am using in this program.
#include <Narrator.h> // The narrators's header file.
#include <Pibot.h> // Other header files of classes.
#include <Armour.h>
#include <Player.h>
#include <Weapon.h>
#include <CombatAdmin.h>
using namespace irrklang;
using namespace std;
// Forward referenced functions
void seedRandom(); // Seeds the random number so it will be random as apposed to pseudo random.
string getPlayerName(string temp); // Gets the player's new name.
int main(int argc, char* argv[])
{
// Variables and object pointers declared here.
CombatAdmin *comAd = new CombatAdmin(); // Handles combat.
Narrator *narrator = new Narrator(); // The Narrator that says stuff
Pibot *piebot = new Pibot(); // PIbot, the player's trusty companion
string temp; // Temp string for input and output
However, when I try to compile the project, I get the following error:
C:\Documents and Settings\James Moran.HOME-B288D626D8\My Documents\C++ projects\Test Project\main.cpp|59|undefined reference to `CombatAdmin::CombatAdmin()'|
I am using the Code::Blocks IDE (ver 10.05), with the GNU GCC compiler. The project is of type "Console application". I am using windows XP 32 bit SP3.
I have tried changing to search directories to include where the object files are, but no success there.
As can be seen from the code, the narrator and PIbot are instanced just fine. (then used, not shown)
My question is, therefore, what do I need to do to stop these errors occurring? As when I encountered similar "Undefined reference to x" errors before using libraries. I had just forgotten to link to them in Code::Blocks and as soon as I did, they would work.
As this class is of my own making I am not quite sure about this.
Do say if you need more information regarding the code etc.
You have declared the default constructor (CombatAdmin()) and thus prevented the compiler from automatically generating it. Thus, you either need to 1) remove declaration of the default constructor from the class, or 2) provide an implementation.
I had this kind of error and the cause was that the CombatAdmin.cpp file wasn't selected as a Build target file: Prject->Properties->Build targets
Are you sure you've to include your header as:
#include <CombatAdmin.h>
?
I think you need to include your header file as:
#include "CombatAdmin.h"
And same for other headers written by you, like these:
#include "Armour.h"
#include "Player.h"
#include "Weapon.h"
//and similarly other header files written by you!
See this topic:
What is the difference between #include <filename> and #include "filename"?
My solution was just to add a line in the header before the class defenition:
class CombatAdmin;