I'm quite new on C++ and QT, but I did manage to set up my environment to compile and link against ffmpeg (I downloaded and installed this Version "Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)" and the latest ffmpeg shared libs (FFmpeg 32-bit Shared Versions, FFmpeg 32-bit Dev Versions from http://ffmpeg.zeranoe.com/builds/)
I have this simple app:
#include "frmmain.h"
#include "ui_frmmain.h"
#define __STDC_CONSTANT_MACROS
namespace ffmpeg
{
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
}
frmMain::frmMain(QWidget *parent) :
QDialog(parent),
ui(new Ui::frmMain)
{
ui->setupUi(this);
ffmpeg::avcodec_register_all();
ffmpeg::AVFormatContext *pFormatCtx;
if ((ffmpeg::avformat_open_input(&pFormatCtx,"d:\\1.wmv" , NULL, NULL)) < 0)
{
printf("could not open the file");
}
}
frmMain::~frmMain()
{
delete ui;
}
The build process runns with no errors, but if I debug the project I get an Segmentation fault
If I run the project it just crashes without any message.
Any ideas what I'm doing wrong?
Thanks in advance
easy one :)
ffmpeg::AVFormatContext *pFormatCtx = NULL;
Related
I am trying to build Crypto++ and target Windows XP. Reading this, I made these changes before building the library:
Platform Toolset = Visual Studio 2017 - Windows XP (v141_xp)
Predefine macros WINVER=0x0501 and _WIN32_WINNT=0x0501
Then I compiled some code (with the same changes as before for XP compatibility):
#include <iostream>
#include <stdio.h>
#include <cryptopp/cryptlib.h>
#include <cryptopp/blake2.h>
int main() {
using namespace CryptoPP;
BLAKE2b hash;
std::string password = "hunter1";
hash.Update((const byte*)password.data(), password.size());
std::string digest;
digest.resize(hash.DigestSize());
hash.Final((byte*)&digest[0]);
printf("Message: %s\n", password.c_str());
puts("Digest:");
for (char ch : digest)
printf("%02hhX", ch);
putchar('\n');
}
This works fine on Windows 10, but when I copy the Release directoty to Windows XP for testing, I get this error:
]
So, what am I doing wrong, and how can I use this library on Windows XP, if at all?
I am making a game that can be played on mac and windows with cocos2d-x.
I first wrote the code in mac's Xcode, and it worked on mac.
When I took the project to windows and tried to build it in Visual Studio 2017, an error occurred.
Error C1083 Cannot open include file: 'cxxabi.h': No such file or directory Narazumono c:\users\masanori\desktop\narazumono3.17\classes_win\nrzcoding.cpp 10
I use cxxabi.h to get the class name of the object.
#include "NRZCoding.h"
#include <cxxabi.h>
#include <cstdio>
#include <algorithm>
#include "NRZUtils.h"
using namespace std;
USING_NS_CC;
namespace NRZCoding {
...
const string& EncodableObject::getClassName()
{
if (_className.size() > 0) {
return _className;
}
const type_info& id = typeid(*this);
int stat;
char *name = abi::__cxa_demangle(id.name(),0,0,&stat);
CCASSERT(name != NULL && stat == 0, "failed to demangle");
_className = string(name);
free(name);
return _className;
}
...
What do I need to do?
I am using cocos2d-x 3.17.1 and Visual Studio 2017.
Thank you.
Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".
.PRO file:
CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:\Users\Test\Desktop\opencv\build\include
LIBS += C:\Users\Test\Desktop\mingw\bin\libopencv_*.dll
main.cpp:
#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
using namespace std;
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}
What im doing wrong?
Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:
did you build openCV with mingw64? If not, do so.
are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...
i found this code for QT Creator and am brand new to the IDE, but have been trying to get this code to run. The main error I am seeing is about 12 instances of similar errors related to Qextserialport.
C:\Users\Hassman\Downloads\aQtLow\aQtLow\dtransferusb.cpp:
34: error: undefined reference to `QextSerialPort::QextSerialPort(QextSerialPort::QueryMode, QObject*)'
I'm not quite sure what to do about it, and am kind of lost. I am running QTCreator 5.1.1 and I imagine there may be a compatibility issue, but please someone give me a hand. Maybe I haven't linked the header to my file correctly? Any suggestions would be appreciated!
#include "dtransferusb.h"
#include <QDebug>
#include <QByteArray>
#include "C:/Users/Hassman/Downloads/aQtLow/aQtLow/qextserialport/src/qextserialport.h"
#include "C:/Users/Hassman/Downloads/aQtLow/aQtLow/qextserialport/src/qextserialport_p.h"
#include "globals.h"
dtransferusb::dtransferusb(QObject *parent) :
QThread(parent)
{
}
void dtransferusb::run()
{
SerPort= new QextSerialPort();
int ExpectedLength = NUMBER_OF_REGISTERS * 2 + NUMBER_OF_COILS / 8 + 1;
QTime Startup, Sleeper;
Startup.start();
while(!Shutdown)
{
if(SerPort->isOpen())
{//the port is open so check for data
Sleeper.start();
while((ExpectingResponse > 0) && (SerPort->bytesAvailable() < ExpectedLength))
{
msleep(25);
if(Sleeper.elapsed() > 5000) break;
}
if(SerPort->bytesAvailable() >= ExpectedLength)
{//data found
Receive(ExpectedLength);
}
else
{
if((ExpectingResponse > 2) && (Startup.elapsed() > 15000))
{
qDebug() << "DTxfrUsb " << QString::number(Cfg.DTxfrUsb) << " finds the lack of expected response utterly demoralizing " << SerPort->portName() << " " << QDateTime::currentDateTime().toString(TIMESTAMP_FORMAT);
P[Cfg.Prc].CommFailure();
ExpectingResponse = 0;
SerPort->close();
Sleeper.start();
while(Sleeper.elapsed() < 1000) msleep(100);
}
else
{
if(!WriteRequest())
{
Send(1,0,0); //Function 1 siginfies "gimme data"
}
}
}
}
else
{//need to open the port
SerPort->reset();
SerPort->setPortName(Cfg.Port);
SerPort->setBaudRate(BAUD9600);
SerPort->setDataBits(DATA_8);
SerPort->setStopBits(STOP_1);
SerPort->setFlowControl(FLOW_OFF);
SerPort->setParity(PAR_NONE);
SerPort->setTimeout(1000);
QextSerialPort is a 3rd-party library that is not affiliated with the official Qt Project. You can find it at https://code.google.com/p/qextserialport/ -- You will need to install QextSerialPort separately.
Some extra notes:
Since you are new, I recommend using Qt 5.2.1 instead. It has many new features and bug fixes over Qt 5.1.1.
"Qt Creator" is the name of the IDE, "Qt" is the name of the libraries. The current version of the IDE is Qt Creator 3.1, the current version of the libraries is Qt 5.2.1.
Qt has its own built-in QSerialPort class, which I recommend if you want to write your own code.
(1) To use these classes in your application, use the following include statement:
#include <QtSerialPort/QtSerialPort>
(2) To link against the module, add this line to your qmake .pro file:
QT += serialport
Qt Serial Port Documentation
I coded a simple application using SDL which displays a simple window on Windows 8 (64 bits). In a first time I compiled and executed my code with Win32 configuration (default configuration) and the program works perfectly. Now I want to have the same execution but this time with x64 configuration. So I configured Visual using 'configurations manager' in my project properties and change my SDL.lib and SDLmain.lib choosing x64 libraries in the linker. The project compilation is ok but the execution fails saying that the application has failed to start properly. Here's a screen of the message (the memory address is always the same at each execution) :
And my c++ code :
#include <iostream>
#include <SDL/SDL.h>
#include <GL/glew.h>
#include <GL/glu.h>
#define WIDTH 500
#define HEIGHT 500
static float angle = 0.0f;
static void eventListener(SDL_Event *pEvent, bool *pContinue)
{
while (SDL_PollEvent(pEvent))
{
switch(pEvent->type)
{
case SDL_QUIT:
*pContinue = false;
break;
case SDL_KEYDOWN:
switch (pEvent->key.keysym.sym)
{
case SDLK_ESCAPE:
*pContinue = false;
break;
}
break;
}
}
}
#undef main
int main(void)
{
SDL_Event myEvent;
bool isAlive = true;
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Simple SDL window", NULL);
SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);
while (isAlive == true)
{
eventListener(&myEvent, &isAlive);
}
SDL_Quit();
return (0);
}
I don't understand this message which is not precise. However my x64 SDL libraries linked to my project seems to be correct because the compilation is ok. So I wonder what's happening here. Does anyone already have encountered the same problem ?
Just googled for your error message, and it says that this error code (0x0c000007b) means INVALID_IMAGE_FORMAT.
This means that either you are mixing 32 and 64 bit binaries or you have corrupted binaries. Try to place you binary and your dependencies at the same folder and run the application. If the error continues, than one of your libraries must be corrupted. Else, it was a problem with the Windows loading a library for a different platform of your compiled binary.