Build/Compile application

Have problem to build any application using open cascade libraries. Tried the example projects at https://dev.opencascade.org/doc/overview/html/samples__projects.html Tried cmake with various error messages in some cases with complain about 3rd party QT libraries and generated Makefile that do absolutely nothing then make is executed. Also tried the QT projects but whatever I do most exciting thing happening is issue counter start to count.

Checked required library though expect I already have what is needed since I compile and run FreeCAD which use open cascade.

Anybody know how to simply get the necessary compiler flags? Or could redirect me to a simple application than FreeCAD that I do compile successfully?

Nicklas Karlsson

Dmitrii Pasukhin's picture

Hello, coule you give logs and a little more details? The problem is not clear for me.

Best regards, Dmitrii.

Nicklas Karlsson's picture

Trying glfw among the application examples cmake succeed but make fail because it can't find #include <Aspect_DisplayConnection.hxx>

Trying OCCTOverview amoung the application examples graphical configuration tool cmake produce error message
CMake Error at CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE):
Unknown CMake command "OCCT_INCLUDE_CMAKE_FILE".
Think I have been able to work around this problem before but only to get another error message.

Most software libraries require only some compiler and linker flags. Have done a lot of programming before so if I have these there should be no problem, the examples are for novices so either the instructions work or no idea how to do.

Nicklas Karlsson's picture

Also tried pkg-config but seems it does not work with open cascade. Found a package occt-misc for debian with some "cmake" files but not sure if they may make any difference.

Nicklas Karlsson's picture

Another try with cmake graphical version:

CMake Error at adm/cmake/qt.cmake:11 (message):
Could not find used third-party product: 3RDPARTY_QT_DIR
Call Stack (most recent call first):
CMakeLists.txt:34 (include)
CMakeLists.txt:841 (OCCT_INCLUDE_CMAKE_FILE)

Nicklas Karlsson's picture

Trying example application sample/qt/OCCTOverview cmake produces error:

CMake Error at CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE):
Unknown CMake command "OCCT_INCLUDE_CMAKE_FILE".

Looking into CMakeLists.txt row three OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) I could not find the referenced file so this might be the reason why it fail.

Nicklas Karlsson's picture

It might have been some version incompatibility problem. Not sure if the cmake files in the samples directory is old.

Starting with something that is known to work cmake files from FreeCAD I got some success. Though will take some time to sort things out since this a quite large application.

Dmitrii Pasukhin's picture

The problem still not clear for me. Could you give logs. You give just a part of each of your scenarion.

Just a few moments:

>>Unknown CMake command "OCCT_INCLUDE_CMAKE_FILE". 

Means that you use only a part of CMake. You need to use root CMakeList.txt or build with genproj instead of CMake

>>Could not find used third-party product: 3RDPARTY_QT_DIR

Mean you do not give path for QT. on GUI you be able to see each values and modify them.

Best regards, Dmitrii.

Nicklas Karlsson's picture

Made another try using instructions from this video https://www.youtube.com/watch?v=SfRFG_Pk9pk with CMakeLists.txt as below:

cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(Lesson_04 CXX)
find_package(OpenCASCADE)
include_directories(SYSTEM ${OpenCASCADE_INCLUDE_DIR})
add_executable(Lesson_04
main.cpp
)
foreach(LIB ${OpenCASCADE_LIBRARIES})
target_link_libraries(Lesson_04 ${OpenCASCADE_LIBRARY_DIR}d/${LIB}.lib)
target_link_libraries(Lesson_04 debug ${OpenCASCADE_LIBRARY_DIR}d/${LIB}.lib)
target_link_libraries(Lesson_04 optimized ${OpenCASCADE_LIBRARY_DIR}/${LIB}.lib)
endforeach()

With this attempt I got error message translated from Swedish "Nor rule to make target ”/usr/lib/x86_64-linux-gnud/TKernel.lib”, needed by ”Lesson_04”. Stop. It might happen TKernel.lib is wrong filename as compilation of FreeCAD work.

Currently working with the cmake files from FreeCAD as I can compile FreeCAD using these and they do compile and #include files are read. Then something is added required linking with open cascade library it fail with "undefined reference" so linker flags is most certainly missing. This is where I am now reading thru the cmake files.

genproj I have not tried yet.

Nicklas Karlsson's picture

Found a file on my Linux computer /usr/lib/x86_64-linux-gnu/libTKernel.so and might be filenamse is wrong and TKernel.lib is the filename if using Windows.

Nicklas Karlsson's picture

There might be a problem with the files in "/usr/lib/cmake/opencascade" in particular the file "OpenCASCADEApplicationFrameworkTargets.cmake" there I found the line INTERFACE_LINK_LIBRARIES "TKernel" which is almost what the compiler look for. But filename i my Linux Debian distribution is /usr/lib/x86_64-linux-gnu/libTKernel.so

It might be Linux filename is libTKernel.so while windows filename is TKernel.lib and as is now cmake generate filenames for windows.

Nicklas Karlsson's picture

Creating links from /usr/lib/x86_64-linux-gnu/TKernel.lib to /usr/lib/x86_64-linux-gnu/libTKernel.so and for all the others libraries compiler complain about from *.lib to lib*.so do solve the build problem or more exact the linker problem problem. Application do also execute without an error so probably everything is OK but have not tried anything visual yet.

Manually creating this links is however not a good solution. Question is if this is a bug? Or if I made something stupid?

Dmitrii Pasukhin's picture

CMake procedure be able to extract correct names for installed solutions.

/usr/lib/x86_64-linux-gnu/libTKernel.so it is correct name for Linux distributions.

A little later I found a correct giude how to link OCC into your project and will share with you.

Best regards, Dmitrii.