Making win32 console application (without mfc)

Hi
Please help me in this reagrd. Is it possible to make applications using opencascade WITHOUT ANY GUI functions, as win32 console applications.
I would be greatful, if some body can give me a "hello world" program of that kind. May be just ,making a box.

Please help me in this
TIA

Francois Lauzon's picture

Yes it's possible, and here is a simple program:

#include
#include

int
main( int argc,
char **argv )
{
// build a simple box
BRepPrimAPI_MakeBox aBox(1,2,5);
aBox.Build();

// dump the topological structure to cout
BRepTools::Dump(aBox.Shape(),std::cout);

return 1;

}

Good Luck,
Francois.

Nagarajan's picture

Thanks a lot Francois

But i have a bit of problem. Probably my setting somewhere is not correct.

The standard header files refered by opencascade are refered like "iostream.h", "strstream.h" like that.
But in vc++ 6 there are only "strstream" and like that. So i am getting an error that
Cannot open include file: 'strstream.h': No such file or directory

Please help me how to resolve this conflict.
Thanks

Nagarajan's picture

Hi,
Now i am getting theis two errors. Please suggest me how to correct them. I am running the program given by Francois, above.

c:\opencascade5.1\ros\inc\standard_real.hxx(315) : error C2065: 'asinh' : undeclared identifier
d:\naga\code\check1\first_open\hjh.cpp(13) : error C2664: 'Dump' : cannot convert parameter 2 from 'class std::basic_ostream >' to 'class ostream &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Error executing cl.exe.

Rob Bachrach's picture

VC6 actually has both kinds of includes, but there can be conflicts
if you mix them. If you have WNT in defined either in your code
(before any CASCADE includes) or in your compiler arguments (probably
better) and you are using cascade 5.2, that should use the proper
includes. The WNT should also fix the asinh problem (and may fix
the Dump problem as well, but I am not sure).

Nagarajan's picture

Thanks, That include conflict i have resolved it now.

But i am not able to dump the shape into cout as Francis told. Please tell me how to do it.
Or if you can tell me how to initialise the AIS context from the scratch so that i can display some simple model, it will be great.

I am a starter and want to know how to display models. As i dont know much about mfcs, it becomes difficult.
TIA

sas's picture

This is the error i am getting, how to resolve this!

pls help me

Compiling...
StdAfx.cpp
c:\program files\microsoft visual studio\vc98\include\strstream(51) : error C2039: 'seekdir' : is not a member of 'ios'
c:\program files\microsoft visual studio\vc98\include\ios.h(106) : see declaration of 'ios'
c:\program files\microsoft visual studio\vc98\include\strstream(51) : error C2061: syntax error : identifier 'seekdir'
c:\program files\microsoft visual studio\vc98\include\strstream(54) : error C2039: 'openmode' : is not a member of 'ios'
c:\program files\microsoft visual studio\vc98\include\ios.h(106) : see declaration of 'ios'
c:\program files\microsoft visual studio\vc98\include\strstream(54) : error C2061: syntax error : identifier 'openmode'
c:\program files\microsoft visual studio\vc98\include\strstream(91) : error C2629: unexpected 'class std::ostrstream ('
c:\program files\microsoft visual studio\vc98\include\strstream(91) : error C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\strstream(109) : error C2629: unexpected 'class std::strstream ('
c:\program files\microsoft visual studio\vc98\include\strstream(109) : error C2238: unexpected token(s) preceding ';'
Error executing cl.exe.

hi.exe - 8 error(s), 0 warning(s)

sas's picture

i solved the problem, but no output, just print Shape: and crash.
Do you have any solution for this.
help me
sas

sas's picture

i solved the problem, but no output, just print Shape: and crash.
Do you have any solution for this.
help me
sas

Kunkun Tang's picture

Hi Francois,

I am a new beginner trying to use Open Cascade. These are the softwares I use:
VS .Net 2003 + Open Cascade 6.3
I created a new win32 console application "test1", and writed in the test1.cpp file as you stated, and I didn't do anything else:

// test1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include
#include

int _tmain(int argc, _TCHAR* argv[])
{
// build a simple box
BRepPrimAPI_MakeBox aBox(1,2,5);
aBox.Build();

// dump the topological structure to cout
BRepTools::Dump(aBox.Shape(),std::cout);

return 1;

}

But when I tried to build it, I received these linking errors:

------ Build started: Project: test1, Configuration: Release Win32 ------

Compiling...
stdafx.cpp
Compiling...
test1.cpp
Linking...
Creating library Release/test1.lib and object Release/test1.exp
test1.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Storable::ShallowDump(class std::basic_ostream > &)const " (?ShallowDump@Standard_Storable@@UBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Standard_Storable::HashCode(int)const " (?HashCode@Standard_Storable@@UBEHH@Z)
test1.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall Standard_Storable::Delete(void)" (?Delete@Standard_Storable@@UAEXXZ) referenced in function "public: virtual __thiscall Standard_Storable::~Standard_Storable(void)" (??1Standard_Storable@@UAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Standard::Free(void * &)" (?Free@Standard@@SAXAAPAX@Z) referenced in function "public: virtual void * __thiscall Standard_Storable::`vector deleting destructor'(unsigned int)" (??_EStandard_Storable@@UAEPAXI@Z)
test1.obj : error LNK2019: unresolved external symbol "private: void __thiscall Handle_Standard_Transient::EndScope(void)" (?EndScope@Handle_Standard_Transient@@AAEXXZ) referenced in function "public: __thiscall Handle_Standard_Transient::~Handle_Standard_Transient(void)" (??1Handle_Standard_Transient@@QAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: void __thiscall Standard_Type::Print(class std::basic_ostream > &)const " (?Print@Standard_Type@@QBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function "public: void __thiscall Standard_Type::operator<<(class std::basic_ostream > &)const " (??6Standard_Type@@QBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
test1.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall Standard_Failure::Throw(void)const " (?Throw@Standard_Failure@@MBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Transient __thiscall Standard_Transient::This(void)const " (?This@Standard_Transient@@UBE?AVHandle_Standard_Transient@@XZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall Standard_Failure::DynamicType(void)const " (?DynamicType@Standard_Failure@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Transient::ShallowDump(class std::basic_ostream > &)const " (?ShallowDump@Standard_Transient@@UBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Standard_Transient::HashCode(int)const " (?HashCode@Standard_Transient@@UBEHH@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Standard_Transient::Delete(void)const " (?Delete@Standard_Transient@@UBEXXZ)
test1.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Standard_Transient::~Standard_Transient(void)" (??1Standard_Transient@@UAE@XZ) referenced in function "public: virtual __thiscall Standard_Failure::~Standard_Failure(void)" (??1Standard_Failure@@UAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: void __thiscall Standard_Failure::Destroy(void)" (?Destroy@Standard_Failure@@QAEXXZ) referenced in function "public: virtual __thiscall Standard_Failure::~Standard_Failure(void)" (??1Standard_Failure@@UAE@XZ)
test1.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall Standard_DomainError::Throw(void)const " (?Throw@Standard_DomainError@@EBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall Standard_DomainError::DynamicType(void)const " (?DynamicType@Standard_DomainError@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: __thiscall Standard_Failure::Standard_Failure(void)" (??0Standard_Failure@@QAE@XZ) referenced in function "public: __thiscall Standard_DomainError::Standard_DomainError(void)" (??0Standard_DomainError@@QAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: __thiscall Standard_Failure::Standard_Failure(char const * const)" (??0Standard_Failure@@QAE@QBD@Z) referenced in function "public: __thiscall Standard_DomainError::Standard_DomainError(char const * const)" (??0Standard_DomainError@@QAE@QBD@Z)
test1.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall Standard_RangeError::Throw(void)const " (?Throw@Standard_RangeError@@EBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall Standard_RangeError::DynamicType(void)const " (?DynamicType@Standard_RangeError@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall Standard_OutOfRange::Throw(void)const " (?Throw@Standard_OutOfRange@@EBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall Standard_OutOfRange::DynamicType(void)const " (?DynamicType@Standard_OutOfRange@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall Standard_ConstructionError::Throw(void)const " (?Throw@Standard_ConstructionError@@EBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall Standard_ConstructionError::DynamicType(void)const " (?DynamicType@Standard_ConstructionError@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Standard_OutOfRange::Raise(char const * const)" (?Raise@Standard_OutOfRange@@SAXQBD@Z) referenced in function "public: double __thiscall gp_XY::Coord(int)const " (?Coord@gp_XY@@QBENH@Z)
test1.obj : error LNK2001: unresolved external symbol __imp__Standard_PI
test1.obj : error LNK2019: unresolved external symbol "public: double __thiscall gp_Dir::Angle(class gp_Dir const &)const " (?Angle@gp_Dir@@QBENABV1@@Z) referenced in function "public: unsigned int __thiscall gp_Dir::IsParallel(class gp_Dir const &,double)const " (?IsParallel@gp_Dir@@QBEIABV1@N@Z)
test1.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Standard_ConstructionError::Raise(char const * const)" (?Raise@Standard_ConstructionError@@SAXQBD@Z) referenced in function "public: class gp_Dir __thiscall gp_Dir::Crossed(class gp_Dir const &)const " (?Crossed@gp_Dir@@QBE?AV1@ABV1@@Z)
test1.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall gp_VectorWithNullMagnitude::Throw(void)const " (?Throw@gp_VectorWithNullMagnitude@@EBEXXZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class Handle_Standard_Type const & __thiscall gp_VectorWithNullMagnitude::DynamicType(void)const " (?DynamicType@gp_VectorWithNullMagnitude@@UBEABVHandle_Standard_Type@@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: void __thiscall TopTools_ListOfShape::Clear(void)" (?Clear@TopTools_ListOfShape@@QAEXXZ) referenced in function "public: __thiscall TopTools_ListOfShape::~TopTools_ListOfShape(void)" (??1TopTools_ListOfShape@@QAE@XZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepBuilderAPI_Command::IsDone(void)const " (?IsDone@BRepBuilderAPI_Command@@UBEIXZ)
test1.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall BRepBuilderAPI_Command::Delete(void)" (?Delete@BRepBuilderAPI_Command@@UAEXXZ) referenced in function "public: virtual __thiscall BRepBuilderAPI_Command::~BRepBuilderAPI_Command(void)" (??1BRepBuilderAPI_Command@@UAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: void __thiscall TopLoc_SListOfItemLocation::Clear(void)" (?Clear@TopLoc_SListOfItemLocation@@QAEXXZ) referenced in function "public: __thiscall TopLoc_SListOfItemLocation::~TopLoc_SListOfItemLocation(void)" (??1TopLoc_SListOfItemLocation@@QAE@XZ)
test1.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall BRepBuilderAPI_MakeShape::IsDeleted(class TopoDS_Shape const &)" (?IsDeleted@BRepBuilderAPI_MakeShape@@UAEIABVTopoDS_Shape@@@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepBuilderAPI_MakeShape::Modified(class TopoDS_Shape const &)" (?Modified@BRepBuilderAPI_MakeShape@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual class TopTools_ListOfShape const & __thiscall BRepBuilderAPI_MakeShape::Generated(class TopoDS_Shape const &)" (?Generated@BRepBuilderAPI_MakeShape@@UAEABVTopTools_ListOfShape@@ABVTopoDS_Shape@@@Z)
test1.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall BRepBuilderAPI_MakeShape::Build(void)" (?Build@BRepBuilderAPI_MakeShape@@UAEXXZ)
test1.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall BRepBuilderAPI_MakeShape::Delete(void)" (?Delete@BRepBuilderAPI_MakeShape@@UAEXXZ) referenced in function "public: virtual __thiscall BRepBuilderAPI_MakeShape::~BRepBuilderAPI_MakeShape(void)" (??1BRepBuilderAPI_MakeShape@@UAE@XZ)
test1.obj : error LNK2019: unresolved external symbol "public: static void __cdecl BRepTools::Dump(class TopoDS_Shape const &,class std::basic_ostream > &)" (?Dump@BRepTools@@SAXABVTopoDS_Shape@@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function _main
test1.obj : error LNK2019: unresolved external symbol "public: class TopoDS_Shape const & __thiscall BRepBuilderAPI_MakeShape::Shape(void)const " (?Shape@BRepBuilderAPI_MakeShape@@QBEABVTopoDS_Shape@@XZ) referenced in function _main
test1.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall BRepPrimAPI_MakeBox::Build(void)" (?Build@BRepPrimAPI_MakeBox@@UAEXXZ) referenced in function _main
test1.obj : error LNK2019: unresolved external symbol "public: __thiscall BRepPrimAPI_MakeBox::BRepPrimAPI_MakeBox(double,double,double)" (??0BRepPrimAPI_MakeBox@@QAE@NNN@Z) referenced in function _main
Release/test1.exe : fatal error LNK1120: 43 unresolved externals

Build log was saved at "file://e:\example\test1\Release\BuildLog.htm"
test1 - 44 error(s), 0 warning(s)

---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped

I would be grateful if you could give me any suggestion.

Many thanks,
Kunkun