這篇內容是如何建構開發環境!
OS: ubuntu 12.10 32bit
1. 安裝開發套件:
sudo apt-get install build-essential
sudo apt-get install libqt4-dev
sudo apt-get install libcoin60
sudo apt-get install libsoqt4-dev
2. 撰寫sample code
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
int main(int argc, char ** argv)
{
printf("hello");
// Initializes SoQt library (and implicitly also the Coin and Qt
// libraries). Returns a top-level / shell Qt window to use.
QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
root->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
root->addChild(col);
root->addChild(new SoCone);
// Use one of the convenient SoQt viewer classes.
SoQtExaminerViewer * eviewer = new SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(root);
eviewer->show();
// Pop up the main window.
SoQt::show(mainwin);
// Loop until exit.
SoQt::mainLoop();
// Clean up resources.
delete eviewer;
root->unref();
SoQt::done();
return 0;
}
3.compile
產生project (QT.pro)
qmake -project
產生Makefile
qmake
compile
make
這時候會產生make error
是因為qmake產生Makefile沒有去做SoQT 和 Coin3D的動態連結
4 修改Makefile
在 LIBS後面加 -lSoQt -lCoin
LIBS = $(SUBLIBS) -L/usr/lib/i386-linux-gnu -lQtGui -lQtCore -lpthread -lSoQt -lCoin
5 finish
make
./QT
沒有留言:
張貼留言