contour工程是基于计算机图形学论文:
Computing Smooth Surface Contours with Accurate Topology.
Pierre Bénard, Aaron Hertzmann, Michael Kass. ACM Transactions on
Graphics, 2013
工程来自github:
http://github.com/benardp/contours
工程需要配置的依赖库:
- cmake * Qt 4.8 libraries (Freestyle) * libQGLViewer (Freestyle) * SWIG (Freestyle)
libQGLViewer编译过程
先从官网上下载libQGLViewer-2.6.4
然后选择打开libQGLViewer-2.6.4文件夹下的libQGLViewer-2.6.4.pro文件(我已经安装好了qt),然后点击构建项目(ctl+B),然后报错:
error: LNK1104: 无法打开文件“QGLViewerd2.lib”
放弃,然后在visual studio 中编译。参照:
QGLViewer 编译安装步骤
打开visual studio 2013,点击菜单栏QT5->Open Qt Project File,选择步骤1 解压的路径\QGLViewer\QGLViewer.pro, 然后点击生成解决方案。然后生成解决方案的时候,报错:
LINK : fatal error LNK1104: 无法打开文件“GLU.lib”
估计是把所有的项目一块生成解决方案的问题,然后把右键QGLViewer单独重新生成,成功生成动态库文件。
生成的库文件在目录F:\Chen\download\libQGLViewer-2.6.4\QGLViewer下面。
接着就把生成的两个dll文件拷到响应的目录下面。
C:\Windows\System32
SWIG的编译
SWIG是C++和C语言与脚本语言的连接。在这个程序中,主要就是将C++语言中使用python的脚本语言。
所以,先安装一下python(这个大家应该都装好了,可以现在命令行里面输入python看看自己安装的是哪一个版本)。
我先安装一下python3.3.3,然后输入命令行python没反应,重启一下命令行就好了。然后输入print ('Hello World!')
成功运行。
然后按照SWIG文档的说明,把包含Python.h的文件夹D:\python\include添加到PYTHON_INCLUDE
把D:\python\libs\python33.lib添加到PYTHON_LIB,python.lib有两个,是python3.lib和phthon33.lib,我不知道添加哪个,就随便用一下后面这个吧,出了问题再说
PYTHON_INCLUDE : Set this to the directory that contains Python.h
PYTHON_LIB : Set this to the python library including path for linking
Example using Python 2.1.1:
PYTHON_INCLUDE: D:\python21\include
PYTHON_LIB: D:\python21\libs\python21.lib
到这里,我打开python文件夹下面的example文件夹下的dsp文件就自动生成项目,然后把项目改成x64平台上,就能找到源代码。我要编译的项目用camke来完成项目的编译,然后用SWIG来链接python。那我还是深切怀疑到底能不能成功运行。然后查了一下官方文档,大概是这么说的:
SWIG是一个命令行工具,可以集成到可以调用外部工具和编译器的系统中,SWIG可以在Makefile文件中被调用,也可以被像Visual Studio一样的IDE中被调用。
一些构建项目的工具也开始支持SWIG如camke,cmake可以检测到SWIG的可执行文件和对应语言的链接库,在许多不同的操作系统中,cmake知道怎么构建共享库和可加载的模块
swig hellow world!
先把下载的swig文件夹下面的swig.exe加入到环境变量path中,我把D:\chen\download\swigwin-3.0.10加入到path中,然后输入swig到命令行工具里面,显示:
Must specify an input file. Use -help for available options.
将官网上的案例程序example.cpp,example.h,example.i放到一个文件夹中。
example.h
/* example.h */
#ifndef EXAMPLE_H
#define EXAMPLE_H
//void cHelloWorld();
int compute(int a, int b);
#endif
example.cpp
/* example.cpp */
#include <iostream>
#include "example.h"
using namespace std;
int compute(int a, int b)
{
int temp = (a+b)*(a-b);
return temp;
}
example.i(swig接口文件)
/* File : example.i */
%module example
%inline %{
#include "example.h"
%}
int compute(int a,int b);
然后输入命令:cd /d D:\chen\mytest,改变命令行中的文件夹。
输入命令:
swig -c++ -python example.i
生成example_wrap.cxx和example.py两个文件。
camke
visual studio 的版本和VC版本的对应关系:
VC6.0对应VS 6.0
VC7.0对应VS 2002
VC7.1对应VS 2003
VC8.0对应VS 2005
VC9.0对应VS 2008
VC10对应VS 2010
VC11对应VS 2012
VC12对应VS 2013
在camke中选择
Generates Visual Studio 12 (VS 2013) project files.
configure
因为我用的是qt5,但是项目使用qt4,所以需要进行一些修改:
详见qt4升级到qt5需要干的那些事。
然后继续配置,报错
1、找不到GLEW,把GLEW_INCLUDE_DIR和GLEW_LIBRARY填上然后基本解决。我因为编译的是64位,所以lib文件也是glew64.lib,不知道放32位的会怎么样,尽量匹配吧。而且文件路径里面有空格貌似也没有什么关系。只要CMake的安装路径里面没有空格就行了。
报错:
如果你的CMake报错:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindGLEW.cmake:27 (find_package_handle_standard_args)
tess_RifFilter/opensubdiv/CMakeLists.txt:295 (find_package)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GLEW_LIBRARY (ADVANCED)
2、安装上了3Delight,然后给3Dlight_INCLUDE_DIR和3Delight_LIBRARY填上了值。
参考3Delight Studio Pro配置教程
然后把QGLViewerd2.lib、QGLViewer2.lib的文件路径填上去,QGLVIEWER_LIBRARY_DEBUG和QGLVIEWER_LIBRARY_RELEASE都是同一个文件路径。然后就把F:/Chen/download/libQGLViewer-2.6.4/QGLViewer填在两个环境变量里面。
报错:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
3Delight_INCLUDE_DIR
used as include directory in directory D:/chen/download/contours-master/tess_RifFilter
3Delight_LIBRARIES
linked by target "tess_RifFilter" in directory D:/chen/download/contours-master/tess_RifFilter
QGLVIEWER_LIBRARY_RELEASE
linked by target "app" in directory D:/chen/download/contours-master/freestyle/app
最后,Cmake里面显示:
Using cmake version 2.8.12
Could NOT find TBB (missing: TBB_INCLUDE_DIR TBB_LIBRARIES) (Required is at least version "4.0")
Could NOT find GLFW (missing: GLFW_INCLUDE_DIR GLFW_LIBRARIES) (Required is at least version "2.7.0")
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) (Required is at least version "1.8.4")
Could NOT find Docutils (missing: RST2HTML_EXECUTABLE) (Required is at least version "0.6")
CMake Warning at tess_RifFilter/opensubdiv/CMakeLists.txt:332 (message):
TBB was not found : support for TBB parallel compute kernels will be
diabled in Osd. If your compiler supports TBB directives, please refer to
the FindTBB.cmake shared module in your cmake installation.
Configuring done
就配置好了,有很多变量没有找到,但是没有关系。
网友评论