如何在mac上构建qt 5项目 [英] How to build qt 5 project on mac

查看:903
本文介绍了如何在mac上构建qt 5项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Mac上构建一个简单的Qt 5程序。但我失败了。



代码很简单:

  #include< QtWidgets / QApplication> 

int main(int argc,char * argv [])
{
QApplication app(argc,argv);
return app.exec();
}

我使用:

  clang ++ -I〜/ Qt5.0.0 / 5.0.0 / clang_64 / include -L / Users / crazylion / Qt5.0.0 / 5.0.0 / clang_64 / lib test.cpp 

然后我得到这个错误:

 架构x86_64的未定义符号:
QApplication :: exec(),引用自:
_main in test-jPGORy.o
QApplication :: QApplication引用自:test-jPGORy.o
中的
_mainQApplication ::〜QApplication(),引用自:
_main in test- jPGORy.o
ld:没有为架构x86_64找到符号
clang:error:linker命令失败,退出代码为1(使用-v查看调用)
解决方案

>如果你想使用clang ++来使用qmake,你需要指定要链接的库,以及你提供的库目录。

  clang ++ -I〜/ Qt5.0.0 / 5.0.0 / clang_64 / include -L / Users / crazylion / Qt5.0.0 / 5.0.0 / clang_64 / lib -lQtCore -lQtGui test.cpp 


I try to build a simple Qt 5 program on Mac. But I failed.

The code is very simple:

#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
    QApplication app (argc, argv);
    return app.exec();
}

I used:

clang++ -I ~/Qt5.0.0/5.0.0/clang_64/include -L/Users/crazylion/Qt5.0.0/5.0.0/clang_64/lib    test.cpp

Then I got this error:

Undefined symbols for architecture x86_64:
  "QApplication::exec()", referenced from:
      _main in test-jPGORy.o
  "QApplication::QApplication(int&, char**, int)", referenced from:
      _main in test-jPGORy.o
  "QApplication::~QApplication()", referenced from:
      _main in test-jPGORy.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there anything i missing?

解决方案

If you want to use clang++ in favor of qmake, you need to specify libraries to link against to, along with the library directory (which you supplied).

clang++ -I ~/Qt5.0.0/5.0.0/clang_64/include -L/Users/crazylion/Qt5.0.0/5.0.0/clang_64/lib  -lQtCore -lQtGui  test.cpp

这篇关于如何在mac上构建qt 5项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆