在mac os x上进行Qt c ++编译/链接

时间:2014-03-27 20:08:35

标签: c++ macos qt gcc makefile

我需要为使用带以太网连接的摄像头的应用程序编写一些代码。制作相机的公司提供了包含从相机读取图像的文件。文件是:ImageLib.h,PvApi.h和PvRegIo.h以及一些库文件libImagelib.a和libPvAPI.a以及libPvAPI.dylib libPvJNI.dylib 我把图书馆文件放在/opt/local/lib/中。我将包含文件放在/opt/local/include/

另一方面,公司提供了一些* .cpp示例,其中包含用于编译的makefile。我编写了一些例子,他们工作得很好。 现在,我决定编译公司提供的一个示例,列出名为ListCameras.cpp的已连接摄像头。 我在QT上创建了一个新项目,只是我复制了ListCameras.cpp的代码。 我的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

不幸的是,我遇到了这些构建错误:

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.

看起来它缺少一些库或标志!有什么帮助吗?


错误

  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

2 个答案:

答案 0 :(得分:0)

编辑后,您似乎需要libjpeg的副本。你需要做两件事:

  1. LIBS += -L/opt/local/lib -ljpeg添加到.pro文件中。

  2. 安装macports,并在命令行上执行sudo port install jpeg安装jpeg库。

  3. 希望这可以解决这个特殊问题。

答案 1 :(得分:0)

您正在获得有关您需要解决的构建的答案。您也会从编译步骤中收到一些警告,其中一些可以安全地忽略,但应该调查描述未定义行为的

相关问题