MacOS下kdchart编译使用
本意是想用Qt chart 做一个甘特图,一番百度之后,发现没有适当的案例可以借鉴,若干大神提及kdchart,据说很简单,遂于官网(https://www.kdab.com/development-resources/qt-tools/kd-chart/)下载之。而后入坑,其深无比。
chapter 1:下载
在官网下载kdchart源码是需要注册的,首先注册的时候那个图形验证就刷不出来,你根本看不到还有一个图形验证的东西,填写完信息之后提交,就会提示错误,还是英文的。不是网速的问题,而是网关的问题,因为那玩意需要翻墙。这够奇葩不?一个不需要翻墙就能打开的网站,注册验证信息要翻墙才能刷出来,这谁能想得到?
弄好验证码之后,网站会向你填写的邮箱发送注册验证信息,通过之后才能注册成功,OK。等邮件。。。。反复操作就是收不到邮件,这又是为啥?TMD,人家不能往微软的live邮箱发邮件。但是人家也不告诉你,就是没动静。思来想去,我换了一下我的qq邮箱,终于收到了验证邮件,这才算注册完成。
而后下载源代码。
此篇章,前前后后困扰本人两天。
chapter2:编译
网络上大神只是,编译这个很简单,用Qt打开源码里面src文件夹里面的src.pro,直接debug一次,release一次就行了。就生成了库文件。但是怎么弄都是出错,各种bug。期间换了一台windows电脑,安装Qt,还是同样的问题。百思不得其解,郁郁寡欢数日。
茫然中,查看源码文件夹下的readme文件。文件中说了有一个install.txt你可以看一下。里面写了应该怎么编译kdchart,Windows,unix/linux,MacOS各个平台的编译方法都有。
以MacOS为例:
================== MAC ==========================
From the top directory of your KD Chart installation run the
“configure” scripts.Use depending on the kind of build on one of the following;
./configure.sh -shared -debug
./configure.sh -shared -release
./configure.sh -static -debug
./configure.sh -static -releaseTo define the install-location use for example;
./configure.sh -shared -debug -prefix /opt/kdchartNOTE: Don’t use releative paths for the prefix, they will not work.
Set your DYLD_LIBRARY_PATH to point to your KD Chart installation
lib directory. If you do not have DYLD_LIBRARY_PATH set already
then use these lines:
DYLD_LIBRARY_PATH=/path/to/kdchart/lib:$DYLD_LIBRARY_PATH export
DYLD_LIBRARY_PATHThe above has to be added into your .bashrc or similar to make it
permanent. It may also, of course, be run from a shell just before
building KD Chart, but in this case your settings will only be
available for this shell.Build everything by typing:
make
(optionally:) Install KD Chart:
From your top-level KD Chart directory just type
make install
This will copy the necessary files into the sub-directories of
your installation path: /usr/local/KDAB/KDChart-VERSION/
- Have a look at the example applications to get you started with the
KD Chart 2.x API.
你看,安装方法详细不?拉倒吧,这根本不是初级用户能看懂的好吗?然后我又开始踩雷排坑。
按照之前体验linux的思路,命令行,复制黏贴啊。于是开始进坑。
第一个:
直接./configure.sh -shared -debug,然后不知道安装哪儿去了!!!!才看到后面的-prefix。
然后./configure.sh -shared -debug -prefix /opt/kdchart,这回知道安装到哪儿了。
第二个:
复制粘贴,
DYLD_LIBRARY_PATH=/path/to/kdchart/lib:$DYLD_LIBRARY_PATH export
DYLD_LIBRARY_PATH
也没留意这里有个/path/to/kdchart/啊,make,make install,一顿操作猛如虎。失败告终。找到/opt/kdchart/,rm -rf删除之。
改成