目录
1 大恒sdk在VS下环境配置(参考大恒自带的C++开发说明) 2 大恒sdk在qtcreator下的环境配置 3 代码
1 大恒sdk在VS下环境配置
在解决方案资源管理窗口中选中用户创建的工程,然后点击菜单中的project->properties弹出Property page窗口。 选择Configuration Properties->C/C++ ->General在Additional Include Directories中填写GalaxyIncludes.h所在目录路径地址(依用户安装目录为准),如图2-1所示。 图2-1 配置引用头文件
2.1.2 配置lib文件 然后选择Configuration Properties->Linker->General在Additional Library Directories中填写GxIAPICPP.lib所在目录路径地址(依用户安装目录为准),如图2-2所示。 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20191217221842984.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1Mjk5MjIz,size_16,color_FFFFFF,t_70)
图2-2配置lib文件路径
然后选择Configuration Properties->Linker->Input在Additional Dependencies中填写GxIAPICPP.lib如图2-3所示。 图2-3配置引用lib的名称
2 大恒sdk在qtcreator下的环境配置
参考了vs中的配置,我们知道我们需要用到 …\C++ SDK\lib\x64目录下的GxIAPICPPEx.lib库文件,另外我们还需要添加包含路径,其中包含路径为 含有GalaxyIncludes.h的文件夹路径。在这里应该是…\C++ SDK\inc
综上我们分为两步走,一个是添加库文件,第二就是添加含有.h文件的路径到包含目录中。
1 添加库文件
step 1
参考我前面写的文章 https://blog.csdn.net/qq_35299223/article/details/103532423,在.pro文件中右击添加库进入如下界面。 在库文件中选择浏览,选择C++\SDK\lib\x64下的GxIAPICPPEx.lib文件,得到自动生成的路径如下,记得务必把debug下自动补全d的一项勾给去掉,否则编译的时候会出现无法打开GxIAPICPPExd.lib的错误,原因是路径下根本没有GxIAPICPPExd.lib这个文件,只有GxIAPICPPEx.lib这个文件!也就是不管release还是debug都是这个lib文件!
另外,添加该lib文件的时候不要去同时修改Include path,直接让他自动生成就好,这样确保一定能够找到这个lib文件 这样得到的结果是下面这样的,但是还没有结束,请继续看step 2 ![在这里插入图片描述](https://img-blog.csdnimg.cn/2019121722311248.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1Mjk5MjIz,size_16,color_FFFFFF,t_70)
step 2
上面只包含了lib文件,但是缺少了头文件,因此我们在main中添加"GalaxyIncludes.h"的时候会出现找不到的情况,原因是我们没有添加"GalaxyIncludes.h"的include path,所以我们需要另外添加include path 参考上面的库文件的include path,我们直接添加下面一行,这样就能够找到我们需要的头文件"GalaxyIncludes.h"了。
INCLUDEPATH += $$PWD/'../../../CameraDemo/C++ SDK/inc'
DEPENDPATH += $$PWD/'../../../CameraDemo/C++ SDK/inc'
step 3
如果还有报错或者无法打开库文件的话,无法打开的原因可能是没有找到这个文件,所以考虑在电脑的环境变量中,把上面两个路径添加进去。如下所示 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20191217223620568.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1Mjk5MjIz,size_16,color_FFFFFF,t_70)
代码
CamDemo.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-12-17T19:33:29
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = CamDemo
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
CONFIG +=C++11
unix|win32: LIBS += -L$$PWD/'../../../CameraDemo/C++ SDK/lib/x64/' -lGxIAPICPPEx
INCLUDEPATH += $$PWD/'../../../CameraDemo/C++ SDK/lib/x64'
DEPENDPATH += $$PWD/'../../../CameraDemo/C++ SDK/lib/x64'
INCLUDEPATH += $$PWD/'../../../CameraDemo/C++ SDK/inc'
DEPENDPATH += $$PWD/'../../../CameraDemo/C++ SDK/inc'
main.cpp
#include "mainwindow.h"
#include
#include
#include "GalaxyIncludes.h"
#include
int main(int argc, char *argv[])
{
using namespace std;
QApplication a(argc, argv);
MainWindow w;
w.show();
IGXFactory::GetInstance().Init();
//枚举设备
GxIAPICPP::gxdeviceinfo_vector vectorDeviceInfo;
IGXFactory::GetInstance().UpdateDeviceList(1000, vectorDeviceInfo);
for (uint32_t i = 0; i |