For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Building OCC with Samples with VS2017

Marco's picture

Hi,

I try to build OCC with VS2017. I downloaded the source package for 7.1.0 und created a VS solution with CMAKE.

Then I downloaded and compile Freetype and Freeimage with VS 2017. I got problems with TK, so here I use the prebuild packages from the occ website (https://www.opencascade.com/content/3rd-party-components).

I can compile the OCC libraries. That works fine, but I am getting linker errors for the Samples.

E.g. creating "Viewer3d" results in linker errors:

1>TKernel.lib(MMgt_TShared.obj) : error LNK2005: "public: virtual void __cdecl MMgt_TShared::Delete(void)const " (?Delete@MMgt_TShared@@UEBAXXZ) ist bereits in mfcsample.lib(mfcsample.dll) definiert.
1>TKernel.lib(NCollection_BaseMap.obj) : error LNK2005: "protected: void __cdecl NCollection_BaseMap::Destroy(void (__cdecl*)(class NCollection_ListNode *,class opencascade::handle<class NCollection_BaseAllocator> &),bool)" (?Destroy@NCollection_BaseMap@@IEAAXP6AXPEAVNCollection_ListNode@@AEAV?$handle@VNCollection_BaseAllocator@@@opencascade@@@Z_N@Z) ist bereits in mfcsample.lib(mfcsample.dll) definiert.
1>TKernel.lib(Standard_Transient.obj) : error LNK2005: "public: virtual void __cdecl Standard_Transient::Delete(void)const " (?Delete@Standard_Transient@@UEBAXXZ) ist bereits in mfcsample.lib(mfcsample.dll) definiert.

...

(The given symbol, displayed in its decorated form, was multiply defined.)

I have no idea where the problem comes from. Freetype, Freeimage is compiled with /MD or /MDd. The OCC projects also use this compile switch.

Any suggestions, hints are welcome!!!

Best regards

Marco

Kirill Gavrilov's picture

Your problem looks strange, but I would suggest first trying OCCT 7.2.0 (beta) which includes some fixes for compatibility with VS2017.
https://dev.opencascade.org/index.php?q=node/1202

Marco's picture

Hi Kirill,

I tried to compile it: same problem.

I also tried to compile a console application without MFC and I am getting linker errors for the Sin, Tan etc functions from "Standard_" of TKernel. Seems the CMake files are not really up to date. Here the problem is that for static linking the define "HAVE_NO_DLL" isn't set proper in the projects files of the solution :(

Kirill Gavrilov's picture

I don't remember any patches for building MFC samples with OCCT static builds.
Thus samples are just not configured for such use case - using static libraries is more tricky within application project.
 

Karthick G's picture

Hello,

Even I spent couple of days trying to run Viewer3D.exe using Visual studio 2017, without much success (I used OpenCASCADE-7.2.0-vc10-64).

I managed to build OCC7,2 with VS2017, due to the 3rd party dlls depending on VS2010, I could not run the MFC sample. It will be convenient if you people can attach a OpenCascade installer compiled with VS2017.

Best regards,

Karthick

Mouhamadou Mansour MBOW's picture

Hello guys,

I have the same problem in the configuration of OCC 7.2 with VS2017.

Have you found any solution since then?

Thanks for helping.

David Maung's picture

I was able to build and run the MFC samples in OpenCascade 7.2 with Visual Studio 2017.  I used the following steps.

0) Build all third parties from source and build and install OpenCascade 7.2.

1) Open a VS2017 Command Prompt.

2) Change to your OpenCascade install directory.

d:\>cd \lib\OpenCascade7.2-x64-release

3) Run the env.bat script.  I use vc141 because OpenCascade 7.2 does not seem to have updated the batch scripts for vc15.

d:\lib\OpenCascade7.2-64-release>env.bat vc141 win64

4) Run the custom.bat script (which calls custom_vc14_64.bat).

d:\lib\OpenCascade7.2-64-release>custom.bat

5) Run the env.bat script again (because there is a circular dependency in env.bat on TCL_DIR and TK_DIR which you should have defined in custom_vc14_64.bat).

d:\lib\OpenCascade7.2-64-release>env.bat vc141 win64

6) Change to the MFC samples directory

d:\lib\OpenCascade7.2-64-release>cd samples\mfc\standard

7. Run msvc.bat, verify that your project settings use the same architecture and windows SDK, and build.

d:\lib\OpenCascade7.2-64-release\samples\mfc\standard>msvc.bat vc141 win64

There may be extraneous steps there, but that worked for me.