简体   繁体   English

Mac OS X上的Qt C ++编译/链接

[英]Qt c++ compilation/linking on mac os x

I need to write some code for an application that uses a camera with Ethernet connection. 我需要为使用带有以太网连接的摄像头的应用程序编写一些代码。 The company who made the camera has provided include files to read images from the camera. 制作相机的公司提供了包含文件,以从相机读取图像。 The files are : ImageLib.h , PvApi.h and PvRegIo.h and some library files libImagelib.a and libPvAPI.a and libPvAPI.dylib libPvJNI.dylib I put the librarie files in /opt/local/lib/ . 这些文件是:ImageLib.h,PvApi.h和PvRegIo.h以及一些库文件libImagelib.a和libPvAPI.a和libPvAPI.dylib libPvJNI.dylib我将librarie文件放在/opt/local/lib/ I put the include files in /opt/local/include/ 我将包含文件放在/opt/local/include/

In the other hand, company provided some *.cpp examples that contains makefile for compilation. 另一方面,公司提供了一些* .cpp示例,其中包含用于编译的makefile。 I compiled some examples and they worked perfectly. 我汇编了一些示例,它们运行良好。 Now, I decide to compile one example provided by the company to list the connected cameras called ListCameras.cpp. 现在,我决定编译公司提供的一个示例,以列出名为ListCameras.cpp的已连接摄像机。 I create a new project on QT and just I copied the code of ListCameras.cpp. 我在QT上创建了一个新项目,仅复制了ListCameras.cpp的代码。 My ListCameras.pro is like this:c 我的ListCameras.pro像这样:c

QT       += core

QT       -= gui

TARGET    = ListCameras
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH+=-l/opt/local/include/
LIBS+=-L/opt/local/lib/
LIBS+= -lPvAPI
LIBS+= -lPvJNI
DEFINES += _x64 _OSX

Unfortunately, I got these build errors: 不幸的是,我遇到了这些构建错误:

15:56:02: Running steps for project ListCameras...
15:56:02: Starting: "/usr/bin/make" 
clang++ -c -pipe -mmacosx-version-min=10.6 -std=c++0x -g -gdwarf-2 -Wall -W -fPIE -D_x64 -D_OSX -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_CORE_LIB -I../../5.0.2/clang_64/mkspecs/macx-clang -I../ListCameras -I-l/opt/local/include/ -I../../5.0.2/clang_64/include -I../../5.0.2/clang_64/include/QtCore -I../../5.0.2/clang_64/lib/QtCore.framework/Headers -I. -I. -o main.o ../ListCameras/main.cpp
../ListCameras/main.cpp:79:51: warning: unused parameter 'junk' [-Wunused-parameter]
void SetConsoleCtrlHandler(void (*func)(int), int junk)
                                                  ^
../ListCameras/main.cpp:89:23: warning: unused parameter 'Signo' [-Wunused-parameter]
void CtrlCHandler(int Signo)
                      ^
../ListCameras/main.cpp:140:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                        printf("%s - %8s - Unique ID = % 8lu IP@ = %15s [%s]\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCameras/main.cpp:147:57: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                        printf("%s - %8s - Unique ID = % 8lu (unavailable, %u)\n",cameraList[i].SerialString,
                                                       ~^~~~
../ListCameras/main.cpp:152:53: warning: flag ' ' results in undefined behavior with 'u' conversion specifier [-Wformat]
                    printf("%s - %8s - Unique ID = % 8lu (*)\n",cameraList[i].SerialString,
                                                   ~^~~~
../ListCameras/main.cpp:171:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
             ^
../ListCameras/main.cpp:171:26: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char* argv[])
                         ^
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o ListCameras main.o   -L/opt/local/lib/ -lPvAPI -lPvJNI -F/Users/rafikgouiaa/Qt//5.0.2/clang_64/lib -framework QtCore 
7 warnings generated.
15:56:02: The process "/usr/bin/make" exited normally.
15:56:02: Configuration unchanged, skipping qmake step.
15:56:02: Could not start process "" 
Error while building/deploying project ListCameras (kit: Desktop Qt 5.0.2 clang 64bit)
When executing step 'Custom Process Step'
15:56:02: Elapsed time: 00:00.

It looks like that it lacks some libraries or flags! 看起来它缺少一些库或标志! Any help please? 有什么帮助吗?


error 错误

  dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /opt/local/lib//libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO

After your edit, it seems that you need a copy of libjpeg . 编辑之后,似乎您需要libjpeg的副本。 You need to do two things: 您需要做两件事:

  1. Add LIBS += -L/opt/local/lib -ljpeg to the .pro file. LIBS += -L/opt/local/lib -ljpeg到.pro文件。

  2. Install macports and, on the command line, do sudo port install jpeg to install the jpeg library. 安装macports,并在命令行上执行sudo port install jpeg以安装jpeg库。

Hopefully this solves this particular issue. 希望这可以解决此特定问题。

You are getting answers about your build, which you need to resolve. 您正在获得有关构建的答案,您需要解决这些问题。 You are also getting some warnings from the compilation step, several of which can be safely ignored, but the ones describing undefined behavior should be investigated . 您还会从编译步骤中获得一些警告,可以安全地忽略其中的一些警告,但是应该研究那些描述未定义行为的警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM