I am using Qt 5.12.2 with MinGW 7.3.0 on Windows 10 x64.
I want to use Allied Vision Vimba SDK but get this error message when I want to compile:
C:\Program Files\Allied Vision\Vimba_3.1\VimbaCPP\Include\IFeatureObserver.h:59: Fehler: function 'AVT::VmbAPI::IFeatureObserver::~IFeatureObserver()' definition is marked dllimport
IMEXPORT virtual ~IFeatureObserver() {}
^
IFeatureObserver.h:
#ifndef AVT_VMBAPI_IFEATUREOBSERVER_H
#define AVT_VMBAPI_IFEATUREOBSERVER_H
#include <VimbaCPP/Include/VimbaCPPCommon.h>
#include <VimbaCPP/Include/SharedPointerDefines.h>
#include <VimbaCPP/Include/Feature.h>
#include <vector>
namespace AVT {
namespace VmbAPI {
class IFeatureObserver
{
public:
IMEXPORT virtual void FeatureChanged( const FeaturePtr &pFeature ) = 0;
IMEXPORT virtual ~IFeatureObserver() {}
protected:
IMEXPORT IFeatureObserver() {}
IMEXPORT IFeatureObserver( const IFeatureObserver& ) { /* No copy ctor */ }
};
typedef std::vector<IFeatureObserverPtr> IFeatureObserverPtrVector;
}} // namespace AVT::VmbAPI
#endif
This exact same problem was already posted here, but I think I should not open a 6 years old thread.
As discribed here https://stackoverflow.com/a/20644594/8010301 this problem seems to be solved already.
But I don't really know what to do.
Like egur said, I have to define the macro AVT_VMBAPI_CPP_EXPORTS in my makefile.
How to define this Macro and where(.pro file of my project or the Makefile inside the Build dir of my Project)? A small guid or an example would be very kind.
I am quite new to c++ and especially developing in Windows. I hope I can find help here.
Related
I'm trying build Qt project in MSVC 2019.
I installed Qt VS Tools v.2.10.1 (rev. 2), opened my Qt-project in MSVC through Qt VS Tools. But when I try to build it I keep getting the same error:
"E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr" in Qt-library file QtCore\qrunnable.h:
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QRUNNABLE_H
#define QRUNNABLE_H
#include <QtCore/qglobal.h>
#include <functional>
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QRunnable
{
bool m_autoDelete = true;
Q_DISABLE_COPY(QRunnable)
public:
virtual void run() = 0;
constexpr QRunnable() noexcept = default; //<- error message points here
virtual ~QRunnable();
static QRunnable *create(std::function<void()> functionToRun);
bool autoDelete() const { return m_autoDelete; }
void setAutoDelete(bool autoDelete) { m_autoDelete = autoDelete; }
};
QT_END_NAMESPACE
#endif
In VC-project settings everything seems to be well (additional libraries and directories).
Can anyone tell me some hint how can I fix that?
Thanks a lot in advance!
I tried different Qt versions for MSVC 2019
:
5.15.2_msvc2019_64,
6.2.4_msvc2019_64,
6.3.2_msvc2019_64,
6.4.2_msvc2019_64,
but error is still here.
I'm using the AppGameKit 2 C++ libraries with Xcode.
I'm using a template project that's given for development on Mac OSX and my code is identical to the default template save for changing a initWithCString to initWithUTF8String, but it compiled after that anyway, so it's not a problem.
The problem started when I tried to rename one of the classes that comes with the template, called template.h/.cpp. The option to rename in the refactor menu was greyed out, so I duplicated the class and changed all of the #includes to point to the new class, then removed the old one from the project.
When I hit run, I got about 20 errors all saying stuff like Unknown type name 'NSString' and Unknown type name 'Protocol'.
I looked around and found answers like this one: ios - Parse Issues in NSObjCRuntime, NSZone, and NSObject but it didn't solve the issue, because according to those, my code should work.
The includes of the main class (Core.mm) is here:
// includes
#import <Cocoa/Cocoa.h>
#include "agk.h"
#include "template.h"
The code in template.h is here:
#ifndef _H_APP
#define _H_APP
// Include AGK libraries
#include "agk.h"
// used in Core.mm to set the window properties
#define DEVICE_WIDTH 1280
#define DEVICE_HEIGHT 720
#define WINDOW_TITLE "Title"
#define FULLSCREEN 0
// Global values for the app
class app
{
public:
// global game vars
public:
// constructor
app() {}
~app() {}
void Begin( void );
void Loop( void );
void End( void );
};
extern app App;
#endif
The code in template.cpp is here:
// Includes
#include "template.h"
// Namespace
using namespace AGK;
app App;
void app::Begin (void){
agk::SetVirtualResolution (1280, 720);
agk::SetClearColor(0,0,0); // light blue
agk::SetSyncRate(60,0);
agk::SetScissor(0,0,0,0);
}
void app::Loop (void){
agk::Print( agk::ScreenFPS() );
agk::Sync();
}
void app::End (void){}
I can't make any sense of this because it shouldn't make sense.
Well, I found the problem. In the template project, the template.cpp file was marked as an Objective-C++ source file, but it obviously wasn't being reimported as one. Changing the file type fixed the problem.
Xcode 11.7
( in 2020 )
change the type, to do it more intuitively
This is cause you imports C or C++ file in your project.For this you add all your header file that imported in .pch file or any common file should declare like this:
#ifdef __OBJ C__
//Import header file
#endif
I am trying to make a managed .dll in c++ that requires the support for multithreading. I am developing in visual Studio 2013, using platform toolset version v120. the reason I need this to be a managed assembly is because it is required to integrate the assembly in LabView.
following the steps in Creating and Using a Managed Assembly in VC++ 2010 gives good results. but I obviously need to implement something more complicated and when I include threading and write the following code:
#pragma once
#include <thread>
using namespace System;
using namespace std;
namespace MultiThread_module {
public ref class multiThreadingTest
{
public:
String^ GetVersion();
int someNumber;
private:
thread testThread;
};
}
I get following errors:
"thread" is not supported when compiling with /clr or /clr:pure.
a member of a managed class cannot be of a non-managed class type
error directive: ERROR: Concurrency Runtime is not supported when
compiling /clr.
error directive: is not supported when compiling with /clr or
/clr:pure.
A friend of mine says it is impossible to write multi-threaded code in Visual Studio without using external packages like boost. It kind of seemed unlikely since Multithreading has already been already there for C# and VB for a long time!
So, I would be happy if you could let me know what I am doing wrong OR if it is really hard to have a managed multithreaded .dll developed in c++?
You can use the managed thread library: System.Threading.Thread.
#pragma once
using namespace System;
using namespace std;
using namespace System::Threading;
namespace MultiThread_module {
public ref class multiThreadingTest
{
public:
String^ GetVersion();
int someNumber;
private:
Thread^ testThread;
};
}
If it's purely CLR then I suggest you use the example provided before. If you want to have the threading completely native and just use CLR to wrap it, I'd like to refer you to my answer at : using clr and std::thread
Might be an old question, but I looked into this same problem before. Since CLR does not allow you to include std::thead at
compile time, you could try to use it only at linking time. Normally
you could resolve this be forward declaring the class in your header
and including them only in your cpp files. However you can forward
declare your own classes in header files, but you can't for
classes in namespace std. According to the C++11 standard, 17.6.4.2.1:
The behavior of a C++ program is undefined if it adds declarations or
definitions to namespace std or to a namespace within namespace std
unless otherwise specified.
A workaround for this problem is to create a threading class that
inherits from std::thread that you can forward declare. The header
file for this class would look like:
#pragma once
#include <thread>
#include <utility>
namespace Threading
{
class Thread : std::thread
{
public:
template<class _Fn, class... _Args> Thread(_Fn fn, _Args... args) : std::thread(fn, std::forward<_Args...>(args...))
{
}
private:
};
}
In the header file that you would like to use the thread you can do
forward declare it like:
#pragma once
// Forward declare the thread class
namespace Threading { class Thread; }
class ExampleClass
{
public:
ExampleClass();
void ThreadMethod();
private:
Threading::Thread * _thread;
};
In your source file you can then use the theading class like:
#include "ExampleClass.h"
#include "Thread.h"
ExampleClass::ExampleClass() :
{
_thread = new Threading::Thread(&ExampleClass::ThreadMethod, this);
}
void ExampleClass::ThreadMethod()
{
}
Hope it might help anyone.
I have 1 native c++ dll, CppApp, another project is managed c++, GatWayLibrary, with /clr
In GatewayLibrary, I called functions from native CppApp dll.
but I got unresolve token errors.
Here are my code snips:
CppApp.h
=========
#ifdef CPPAPP_EXPORTS
#define CPPAPP_API __declspec(dllexport)
#else
#define CPPAPP_API __declspec(dllimport)
#endif
class CPPAPP_API CppApp
{
public:
CppApp();
~CppApp();
ContextManager & contextMgr() { return m_rplContextMng; }
INativeListener* m_listener;
void registerListener(INativeListener* listener)
{
m_listener = listener;
}
...........
}
In separate project, GateWaylibrary, wrap the native dll as
#include "../CppApp/CppApp.h"
#include <vcclr.h>
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma comment(lib, "CppApp.lib")
namespace GatewayLibrary{
//.net equvelant of the argument class
public ref class DotNetEventArg{
internal:
//contructor takes native version of argument to transform
DotNetEventArg(const NativeCPPArgs& args) {
....
...
}
the managed c++ has the linking errors as unresolved tokens for all the function calls from the native c++.
I did include the CppApp.lib as Additional Dependencies
and the directory.
Can anyone please help? many thanks ahead.
Edit:
here is of the place I called the native c++
`GatewayLibrary::EventGateway::EventGateway()
{
nativeCode_ = new CppApp();
//note; using 'this' in ctor is not a good practice
nativeListener_ = new NativeListenerImp(this);
//register native listener
nativeCode_->registerListener(nativeListener_);
}`
I'm trying to integrate c++ code with awesomium functionalities, but I get many errors.
It seems that VisualStudio doesn't like my definition/declaration of the WebCore element. I copied it from http://wiki.awesomium.com/tutorials/tutorial-1-hello-awesomium.html.
I have simplified the code until this, and I still get the errors.
SimpleClass.cpp:
#include <Awesomium/WebCore.h>
include "SimpleClass.h"
using namespace Awesomium;
CSimpleClass::CSimpleClass(){
WebCore *web_core = WebCore::Initialize(WebConfig());
}
CSimpleClass::~CSimpleClass(){
}
SimpleClass.h:
class CSimpleClass
{
public:
CSimpleClass(void);
~CSimpleClass(void);
WebCore *web_core;
};
Thanks!
Change your SimpleClass.h header to read:
#pragma once
#ifndef SIMPLECLASS_H
#define SIMPLECLASS_H
// forward declarations
namespace Awesomium{
class WebCore;
}
class CSimpleClass
{
public:
CSimpleClass(void);
~CSimpleClass(void);
Awesomium::WebCore *web_core;
};
#endif /* SIMPLECLASS_H */
That way you announce to your compiler that there exists a type WebCore in the namespace Awesonium, and then you can use it to declare the member pointer CSimpleClass::web_core.
Potential dependency issues aside, the problem is that your header does not know that you want to use the Awesomium namespace.
Either (preferred) be explicit in the header about your definition of *web_core by doing
class CSimpleClass
{
public:
CSimpleClass(void);
~CSimpleClass(void);
Awesomium::WebCore *web_core; //note the use of Awesomium::
};
or (if you really must) include your header after your using directive
#include <Awesomium/WebCore.h>
using namespace Awesomium;
#include "SimpleClass.h"