VCOS does not name a type - c++

I'm, trying to output video from raspicam to framebuffer 0, and I'm having an issue with BCM_HOST, where I get a ton of errors from the included vcos.h.
All the errors are of the same 2 types:
'VCHPRE_' does not name a type,
'vcos_boot_t' has not been declared,
In files: connection.h vc_ispmanx.h, message.h etc.
etc.
I'll link to a full pastebin of errors below
I don't even know where to begin solving these, I moved /opt/vc from raspbian to my sysroot folder using VisualGDB's synchronize sysroot feature, and all the include files are there.
Is this a problem with the files themselves? It can't be,
Thanks for any help,
-D
Pastebin link: https://mypastebin.com/xQdN7mZZInHx
Example:
#include <stdio.h>
#include <syslog.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include "bcm_host.h"
using namespace std;
int main(int argc, char **argv) {
{
DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_MODEINFO_T display_info;
DISPMANX_RESOURCE_HANDLE_T screen_resource;
VC_IMAGE_TRANSFORM_T transform;
uint32_t image_prt;
VC_RECT_T rect1;
int ret;
int fbfd = 0;
char *fbp = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
return 0;
}

Ok, it seems that using VisualGDB sysroot synchronize tool causes some files to be copied with 0 length. I checked vcos.h and it was empty, but on my linux system it had data. Fixed by copying all the files manually.

Related

Redirect ostream to output file

I am still very inexperienced with cpp.
I have a function I'd like to call from a .cpp file, below is its header:
int wsq_encode(unsigned char* bufferRAW, int width, int height, char compressRate, std::ostream &streamWSQ);
I need to write a code that opens tons of RAW image formats (bufferRAW) and compress them to .wsq according to this company's algorithm, all the while using the width, height and compression rate parameters via argv[]. The output file is supposed to go to streamWSQ.
The wsq_encode is closed and I won't go into it. I am having trouble passing the output file to wsq_encode. The code I need to write is very simple:
#include "../inc/libcorewsq.h"
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char **argv) {
unsigned char raw[20];
strcpy ((char*)raw, argv[1]);
int width = atoi(argv[2]);
int height = atoi(argv[3]);
ostream arq;
arq.open ("out.wsq");
wsq_encode (raw, width, height, 5, arq);
return 0;
}
I still battling how to do this. I need to compile and run it using GCC 4.4.7 inside a CentOS ssh shell.
Try using std::ofstream, where the f is for files.
Opening std::ostream opens a generic output stream.
#include is irrelevant: you failed to link in the definition of the function.

C++ access function from C DLL/lib

I'm desperately trying to access a DLL supplied with some hardware. I have the DLL, the LIB file and the headers for the DLL.
I first tried using C# but failed due to the large data structures that are passed around. I got the functions called but the values in the structures that are modified are not correct.
I then thought about writing a wrapper class in C++ and use this as a library for C#. But again here I can call the function but if I tested an signed long that is passed it is "1072955392l" instead of "-1l".
I then just renamed the cpp file to ".c" and compiled it again. Now I get the correct value.
Are there some differences in the datatypes from C to C++?
The functions for the LIb in the supplied include file are declared like that:
_declspec (dllimport) long ResetControl(Registers* regs);
I compile using VS2013:
cl test.cpp /link test.lib
cl test.c /link test.lib
The cpp file and c file are the same unless I needed to include #include for the cpp and wrap the dll include header in
extern "C"
{
#include "test.h"
}
The test.c file looks like:
//#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdio.h>
#include <math.h>
#include "test.h"
int main (int argc, char **argv)
{
Registers Regs;
Reset (&Regs);
printf ("Value: %dl\n\r", Regs.Product);
return 0;
}
The C++ file:
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdio.h>
#include <math.h>
extern "C"
{
#include "test.h"
}
int main (int argc, char **argv)
{
Registers Regs;
Reset (&Regs);
printf ("Value: %dl\n\r", Regs.Product);
return 0;
}
Both compile, but the result of printing Regs.Products is different:
C: -1l
C++: 1072955392l
What am I doing wrong here?
I saw somewhere that there is a matter of aligning to 4 bytes while compiling the client of the DLL.
However have a look to those pages:
http://www.codeproject.com/Articles/21/Beginner-s-Tutorial-Calling-Visual-Basic-ActiveX-D
http://www.codeproject.com/Articles/6242/Step-by-Step-Calling-C-DLLs-from-VC-and-VB-Part
Alexandre

MinGW portability

I'm completely new to C++, but I have created a minor program, looking to port the program to other computers, but when I "install" the program I get this error...-static-libgcc -static-libstdc++ missing, is there a file I should be including in the program itself, or is this a library I have to install on each computer? The computers that I expect to run the program will be windows xp. Source code of the file is as follows:
#include <stdlib.h>
#include <windows.h>
#include <direct.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, const char *argv[])
{
_chdir("C:\\Program Files\\NCHSoftware\\Talk\\");
string number = "start talk.exe -dial " + std::string(argv[1]+4);
system(number.c_str());
exit;
return 0;
}
They are shared lib's that would need to be on the host computer.
To learn how to compile a static version;
See here: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Read the "-static-libgcc" & "-static-libstdc++" sections.

C++/Qt FFmpeg library error: program has unexpectedly finished

I am trying to use ffmpeg library on windows in C++/Qt. This is my main function:
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
#define INT64_C(val) val##LL
#define UINT64_C(val) val##ULL
#include <QtCore>
#include <SDL/SDL.h>
#ifdef __MINGW32__
#undef main
#endif
//--------------- FFMPEG Headers and Libraries ---------------
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
int main(int c, char *args[])
{
av_register_all();
AVFormatContext *ctx;
if(avformat_open_input(&ctx,"salam.avi",NULL,NULL)!=0)
return -1;
return 0;
}
It gets compiled & linked fine. But I get this error when I try to run it:
The program has unexpectedly finished
This happens on *avformat_open_input* function. What's the problem? Is it about my code, or it is a problem with my libraries?
Thanks in advance
Finally I found it. The answer is so simple. ctx should be initialized by NULL.
AVFormatContext *ctx = NULL;
Could be a problem with the AVI. Make sure your avi is supported by FFMPEG. use this tool To check what exactly the format is and look up the FFMPEG library help/support to see if the format is supported or not.

Undefined reference to 'Class::Class'

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;