• 7125阅读
  • 3回复

关于Qt和其他库的编译问题 [复制链接]

上一主题 下一主题
离线zhaonash
 

只看楼主 倒序阅读 楼主  发表于: 2006-04-20
在Qt中调用其他的库 该怎样编译呢?
[ 此贴被XChinux在2006-04-20 21:18重新编辑 ]
爱因斯坦说: 每个人都可以是99%的勤奋+1%的天赋,但1%的天赋是最关键的。我只信前半句!
离线XChinux

只看该作者 1楼 发表于: 2006-04-20
你要调用什么库?它是以什么形式提供的
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线billdates
只看该作者 2楼 发表于: 2006-04-20
In your .pri file or your .pro file, use "LIBPATH += <YOUR_LIB_PATH_SEPARATED_BY_SPACES>"
and in the same file, use "LIBS += <YOUR_LIB_NAME>"

e.g., you have a project named QTCN and in that project, you have 2 sub directories: QTCN/DIR1 and QTCN/DIR2. In DIR1 you want to include libMy.so (in /usr/local/lib) for Linux and My.dll (in C:/MyLib) for Win32. Do the following:

In project dir QTCN/, create a file mydef.pri with the following content:
win32{
  LIBPATH += C:/MyLib
}
else{
#assume linux
  LIBPATH += /usr/local/lib
}
in QTCN/DIR1/DIR1.pro
TOPLEVEL=..
include ($$TOPLEVEL/mydef.pri)
win32{
  LIBS +=-lMy
}
else{
  LIBS +=-lMy
}

Comments:
1. You don't have to use mydef.pri but it's a good practice.
2. You don't have to define LIBPATH this way. You can forget about the mydef.pri part and simply use things like "LIBS += -L/usr/local/lib -lMy" in your .pro file but if you have big projects, the example I gave should be a good thing to do.
离线zhaonash

只看该作者 3楼 发表于: 2006-04-22
intel 的ipp   刚开始学不知道能不能和Qt一起编译
爱因斯坦说: 每个人都可以是99%的勤奋+1%的天赋,但1%的天赋是最关键的。我只信前半句!
快速回复
限100 字节
 
上一个 下一个