contour工程編譯

contour工程是基于計(jì)算機(jī)圖形學(xué)論文:

Computing Smooth Surface Contours with Accurate Topology.
Pierre Bénard, Aaron Hertzmann, Michael Kass. ACM Transactions on
Graphics, 2013

工程來(lái)自github:
http://github.com/benardp/contours

工程需要配置的依賴庫(kù):

  • cmake * Qt 4.8 libraries (Freestyle) * libQGLViewer (Freestyle) * SWIG (Freestyle)

libQGLViewer編譯過(guò)程

參考:libQGLViewer的安裝配置與編譯

先從官網(wǎng)上下載libQGLViewer-2.6.4

然后選擇打開(kāi)libQGLViewer-2.6.4文件夾下的libQGLViewer-2.6.4.pro文件(我已經(jīng)安裝好了qt),然后點(diǎn)擊構(gòu)建項(xiàng)目(ctl+B),然后報(bào)錯(cuò):
error: LNK1104: 無(wú)法打開(kāi)文件“QGLViewerd2.lib”

放棄,然后在visual studio 中編譯。參照:
QGLViewer 編譯安裝步驟
打開(kāi)visual studio 2013,點(diǎn)擊菜單欄QT5->Open Qt Project File,選擇步驟1 解壓的路徑\QGLViewer\QGLViewer.pro, 然后點(diǎn)擊生成解決方案。然后生成解決方案的時(shí)候,報(bào)錯(cuò):
LINK : fatal error LNK1104: 無(wú)法打開(kāi)文件“GLU.lib”
估計(jì)是把所有的項(xiàng)目一塊生成解決方案的問(wèn)題,然后把右鍵QGLViewer單獨(dú)重新生成,成功生成動(dòng)態(tài)庫(kù)文件。
生成的庫(kù)文件在目錄F:\Chen\download\libQGLViewer-2.6.4\QGLViewer下面。

接著就把生成的兩個(gè)dll文件拷到響應(yīng)的目錄下面。
C:\Windows\System32

SWIG的編譯

SWIG是C++和C語(yǔ)言與腳本語(yǔ)言的連接。在這個(gè)程序中,主要就是將C++語(yǔ)言中使用python的腳本語(yǔ)言。

所以,先安裝一下python(這個(gè)大家應(yīng)該都裝好了,可以現(xiàn)在命令行里面輸入python看看自己安裝的是哪一個(gè)版本)。

我先安裝一下python3.3.3,然后輸入命令行python沒(méi)反應(yīng),重啟一下命令行就好了。然后輸入print ('Hello World!')
成功運(yùn)行。
然后按照SWIG文檔的說(shuō)明,把包含Python.h的文件夾D:\python\include添加到PYTHON_INCLUDE
把D:\python\libs\python33.lib添加到PYTHON_LIB,python.lib有兩個(gè),是python3.lib和phthon33.lib,我不知道添加哪個(gè),就隨便用一下后面這個(gè)吧,出了問(wèn)題再說(shuō)

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

到這里,我打開(kāi)python文件夾下面的example文件夾下的dsp文件就自動(dòng)生成項(xiàng)目,然后把項(xiàng)目改成x64平臺(tái)上,就能找到源代碼。我要編譯的項(xiàng)目用camke來(lái)完成項(xiàng)目的編譯,然后用SWIG來(lái)鏈接python。那我還是深切懷疑到底能不能成功運(yùn)行。然后查了一下官方文檔,大概是這么說(shuō)的:

SWIG是一個(gè)命令行工具,可以集成到可以調(diào)用外部工具和編譯器的系統(tǒng)中,SWIG可以在Makefile文件中被調(diào)用,也可以被像Visual Studio一樣的IDE中被調(diào)用。

一些構(gòu)建項(xiàng)目的工具也開(kāi)始支持SWIG如camke,cmake可以檢測(cè)到SWIG的可執(zhí)行文件和對(duì)應(yīng)語(yǔ)言的鏈接庫(kù),在許多不同的操作系統(tǒng)中,cmake知道怎么構(gòu)建共享庫(kù)和可加載的模塊

swig hellow world!

先把下載的swig文件夾下面的swig.exe加入到環(huán)境變量path中,我把D:\chen\download\swigwin-3.0.10加入到path中,然后輸入swig到命令行工具里面,顯示:
Must specify an input file. Use -help for available options.

將官網(wǎng)上的案例程序example.cpp,example.h,example.i放到一個(gè)文件夾中。

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兩個(gè)文件。

camke

visual studio 的版本和VC版本的對(duì)應(yīng)關(guān)系:
VC6.0對(duì)應(yīng)VS 6.0
VC7.0對(duì)應(yīng)VS 2002
VC7.1對(duì)應(yīng)VS 2003
VC8.0對(duì)應(yīng)VS 2005
VC9.0對(duì)應(yīng)VS 2008
VC10對(duì)應(yīng)VS 2010
VC11對(duì)應(yīng)VS 2012
VC12對(duì)應(yīng)VS 2013
在camke中選擇
Generates Visual Studio 12 (VS 2013) project files.

configure
因?yàn)槲矣玫氖莙t5,但是項(xiàng)目使用qt4,所以需要進(jìn)行一些修改:
詳見(jiàn)qt4升級(jí)到qt5需要干的那些事。

然后繼續(xù)配置,報(bào)錯(cuò)
1、找不到GLEW,把GLEW_INCLUDE_DIR和GLEW_LIBRARY填上然后基本解決。我因?yàn)榫幾g的是64位,所以lib文件也是glew64.lib,不知道放32位的會(huì)怎么樣,盡量匹配吧。而且文件路徑里面有空格貌似也沒(méi)有什么關(guān)系。只要CMake的安裝路徑里面沒(méi)有空格就行了。

報(bào)錯(cuò):
如果你的CMake報(bào)錯(cuò):
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都是同一個(gè)文件路徑。然后就把F:/Chen/download/libQGLViewer-2.6.4/QGLViewer填在兩個(gè)環(huán)境變量里面。

報(bào)錯(cuò):
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

就配置好了,有很多變量沒(méi)有找到,但是沒(méi)有關(guān)系。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容