Building Libs for Windows Debug Version with VS2017/Qt5.12

Having trouble installing or compiling FreeCAD? Get help here.
wmayer
Site Admin
Posts: 15716
Joined: Thu Feb 19, 2009 10:32 am

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby wmayer » Sat Mar 30, 2019 10:59 am

In order to avoid some annoying warnings the file FreeCadLibs_12.1.2_x64_vc15\include\Inventor\system\inttypes.h should be modified by adding some guards around several defines.
So this block

Code: Select all

#define HAVE_INT8_T 1
#define HAVE_UINT8_T 1
#define HAVE_INT16_T 1
#define HAVE_UINT16_T 1
#define HAVE_INT32_T 1
#define HAVE_UINT32_T 1
#define HAVE_INT64_T 1
#define HAVE_UINT64_T 1
#define HAVE_INTPTR_T 1
#define HAVE_UINTPTR_T 1
should become

Code: Select all

#ifndef HAVE_INT8_T
#define HAVE_INT8_T 1
#endif
#ifndef HAVE_UINT8_T
#define HAVE_UINT8_T 1
#endif
#ifndef HAVE_INT16_T
#define HAVE_INT16_T 1
#endif
#ifndef HAVE_UINT16_T
#define HAVE_UINT16_T 1
#endif
#ifndef HAVE_INT32_T
#define HAVE_INT32_T 1
#endif
#ifndef HAVE_UINT32_T
#define HAVE_UINT32_T 1
#endif
#ifndef HAVE_INT64_T
#define HAVE_INT64_T 1
#endif
#ifndef HAVE_UINT64_T
#define HAVE_UINT64_T 1
#endif
#ifndef HAVE_INTPTR_T
#define HAVE_INTPTR_T 1
#endif
#ifndef HAVE_UINTPTR_T
#define HAVE_UINTPTR_T 1
#endif
User avatar
apeltauer
Posts: 291
Joined: Fri Aug 11, 2017 2:19 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby apeltauer » Sat Mar 30, 2019 6:11 pm

Thanks for all the replies, I will check them all on Monday...
wmayer
Site Admin
Posts: 15716
Joined: Thu Feb 19, 2009 10:32 am

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby wmayer » Sat Mar 30, 2019 6:53 pm

Have you found a solution for the hard-coded paths with Netgen? They come from the file netgen-targets.cmake
wmayer
Site Admin
Posts: 15716
Joined: Thu Feb 19, 2009 10:32 am

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby wmayer » Sat Mar 30, 2019 9:13 pm

wmayer wrote:
Sat Mar 30, 2019 6:53 pm
Have you found a solution for the hard-coded paths with Netgen? They come from the file netgen-targets.cmake
You can use the FREECAD_LIBPACH_DIR variable to define flexible paths inside that file:

Code: Select all

# Generated by CMake

if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
   message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget ngcore mesh visual csg geom2d interface netgen gui togl nglib)
  list(APPEND _expectedTargets ${_expectedTarget})
  if(NOT TARGET ${_expectedTarget})
    list(APPEND _targetsNotDefined ${_expectedTarget})
  endif()
  if(TARGET ${_expectedTarget})
    list(APPEND _targetsDefined ${_expectedTarget})
  endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
  unset(_targetsDefined)
  unset(_targetsNotDefined)
  unset(_expectedTargets)
  set(CMAKE_IMPORT_FILE_VERSION)
  cmake_policy(POP)
  return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)


# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
  set(_IMPORT_PREFIX "")
endif()

# Create imported target ngcore
add_library(ngcore SHARED IMPORTED)

set_target_properties(ngcore PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "\$<\$<CONFIG:DEBUG>:NETGEN_ENABLE_CHECK_RANGE>;NETGEN_PYTHON"
  INTERFACE_INCLUDE_DIRECTORIES "${FREECAD_LIBPACK_DIR}/bin/Include"
  INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/bin/libs/python36.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/bin/libs/python36_d.lib>"
)

# Create imported target mesh
add_library(mesh INTERFACE IMPORTED)

set_target_properties(mesh PROPERTIES
  INTERFACE_LINK_LIBRARIES "ngcore;\$<LINK_ONLY:gprim>;\$<LINK_ONLY:la>;\$<LINK_ONLY:gen>;\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/lib/zlib.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/lib/zlibd.lib>;\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/bin/libs/python36.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/bin/libs/python36_d.lib>"
)

# Create imported target visual
add_library(visual INTERFACE IMPORTED)

set_target_properties(visual PROPERTIES
  INTERFACE_LINK_LIBRARIES "ngcore;\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/bin/libs/python36.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/bin/libs/python36_d.lib>;opengl32;glu32"
)

# Create imported target csg
add_library(csg INTERFACE IMPORTED)

set_target_properties(csg PROPERTIES
  INTERFACE_LINK_LIBRARIES "mesh;\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/bin/libs/python36.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/bin/libs/python36_d.lib>;ngcore"
)

# Create imported target geom2d
add_library(geom2d INTERFACE IMPORTED)

set_target_properties(geom2d PROPERTIES
  INTERFACE_LINK_LIBRARIES "mesh;\$<\$<NOT:\$<CONFIG:DEBUG>>:${FREECAD_LIBPACK_DIR}/bin/libs/python36.lib>;\$<\$<CONFIG:DEBUG>:${FREECAD_LIBPACK_DIR}/bin/libs/python36_d.lib>;ngcore"
)

# Create imported target interface
add_library(interface INTERFACE IMPORTED)

set_target_properties(interface PROPERTIES
  INTERFACE_LINK_LIBRARIES "mesh;csg;geom2d;visual"
)

# Create imported target netgen
add_executable(netgen IMPORTED)

# Create imported target gui
add_library(gui SHARED IMPORTED)

set_target_properties(gui PROPERTIES
  INTERFACE_LINK_LIBRARIES "nglib"
)

# Create imported target togl
add_library(togl SHARED IMPORTED)

set_target_properties(togl PROPERTIES
  INTERFACE_LINK_LIBRARIES "C:/ActiveTcl/lib/tcl86t.lib;C:/ActiveTcl/lib/tk86t.lib;opengl32;glu32"
)

# Create imported target nglib
add_library(nglib SHARED IMPORTED)

set_target_properties(nglib PROPERTIES
  INTERFACE_LINK_LIBRARIES "ngcore"
)

if(CMAKE_VERSION VERSION_LESS 3.0.0)
  message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.")
endif()

# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/netgen-targets-*.cmake")
foreach(f ${CONFIG_FILES})
  include(${f})
endforeach()

# Cleanup temporary variables.
set(_IMPORT_PREFIX)

# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
  foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
    if(NOT EXISTS "${file}" )
      message(FATAL_ERROR "The imported target \"${target}\" references the file
   \"${file}\"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   \"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
    endif()
  endforeach()
  unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)

# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
User avatar
apeltauer
Posts: 291
Joined: Fri Aug 11, 2017 2:19 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby apeltauer » Mon Apr 01, 2019 5:37 am

wmayer wrote:
Sat Mar 30, 2019 9:15 am
I am downloading the file FreeCADLibs_12.1.2_x64_VC15.7z which I hope is the right one.
Btw, what is the difference between FreeCADLibs_12.1.2_x64_VC15_binary_debug.7z and FreeCADLibs_12.1.2_x64_VC15_bin_debug.7z or FreeCADLibs_12.1.2_x64_VC15_binary_release.7z and FreeCADLibs_12.1.2_x64_VC15_bin_release.7z?
I just have delete the old ones. Now 3 files are listed
  • FreeCADLibs_12.1.2_x64_VC15.7z --> is the complete libpack, including all cmakes, header, libs, etc files
  • FreeCADLibs_12.1.2_x64_VC15_binary_debug.7z --> containing the 3rd party binaries and all needed files to run the debug version. If you copy these files to your cmake binary dir, FreeCAD should run...
  • FreeCADLibs_12.1.2_x64_VC15_binary_release.7z --> containing all 3rd party files to run FreeCAD in the release mode, These files can be used to create a clean installer...
User avatar
apeltauer
Posts: 291
Joined: Fri Aug 11, 2017 2:19 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby apeltauer » Mon Apr 01, 2019 1:02 pm

wmayer wrote:
Sat Mar 30, 2019 9:54 am
When using FreeCADLibs_12.1.2_x64_VC15 then I got a few warnings:
CMake Warning (dev) at src/Base/CMakeLists.txt:393 (target_link_libraries):
Link library type specifier "debug" is followed by specifier "optimized"
instead of a library name. The first specifier will be ignored.
This warning is for project developers. Use -Wno-dev to suppress it.


CMake Warning (dev) at src/Mod/Path/libarea/CMakeLists.txt:148 (target_link_libraries):
Link library type specifier "optimized" is followed by specifier
"optimized" instead of a library name. The first specifier will be
ignored.
This warning is for project developers. Use -Wno-dev to suppress it.
which apparently is caused by to what the Python libs are set:

Code: Select all

Found PythonLibs: optimized;optimized;optimized;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36.lib;optimized;debug;optimized;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36_d.lib;debug;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36_d.lib (found suitable version "3.6.8", minimum required is "3") 
Fixed this is in "Shiboken2Config.cp36-win_amd64.cmake" line 44

Code: Select all

    if( NOT {${PYTHON_LIBRARY}} )
      shiboken_find_required_python(3)
    endif()
wmayer wrote:
Sat Mar 30, 2019 10:59 am
In order to avoid some annoying warnings the file FreeCadLibs_12.1.2_x64_vc15\include\Inventor\system\inttypes.h should be modified by adding some guards around several defines.
So this block

Code: Select all

#define HAVE_INT8_T 1
#define HAVE_UINT8_T 1
#define HAVE_INT16_T 1
#define HAVE_UINT16_T 1
#define HAVE_INT32_T 1
#define HAVE_UINT32_T 1
#define HAVE_INT64_T 1
#define HAVE_UINT64_T 1
#define HAVE_INTPTR_T 1
#define HAVE_UINTPTR_T 1
should become

Code: Select all

#ifndef HAVE_INT8_T
#define HAVE_INT8_T 1
#endif
#ifndef HAVE_UINT8_T
#define HAVE_UINT8_T 1
#endif
#ifndef HAVE_INT16_T
#define HAVE_INT16_T 1
#endif
#ifndef HAVE_UINT16_T
#define HAVE_UINT16_T 1
#endif
#ifndef HAVE_INT32_T
#define HAVE_INT32_T 1
#endif
#ifndef HAVE_UINT32_T
#define HAVE_UINT32_T 1
#endif
#ifndef HAVE_INT64_T
#define HAVE_INT64_T 1
#endif
#ifndef HAVE_UINT64_T
#define HAVE_UINT64_T 1
#endif
#ifndef HAVE_INTPTR_T
#define HAVE_INTPTR_T 1
#endif
#ifndef HAVE_UINTPTR_T
#define HAVE_UINTPTR_T 1
#endif
Modified the header file.
I updated the libpack and uploaded again (https://github.com/apeltauer/FreeCAD/re ... bPack_12.1)
User avatar
apeltauer
Posts: 291
Joined: Fri Aug 11, 2017 2:19 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby apeltauer » Mon Apr 01, 2019 1:04 pm

apeltauer wrote:
Mon Apr 01, 2019 1:02 pm
wmayer wrote:
Sat Mar 30, 2019 9:54 am
When using FreeCADLibs_12.1.2_x64_VC15 then I got a few warnings:
CMake Warning (dev) at src/Base/CMakeLists.txt:393 (target_link_libraries):
Link library type specifier "debug" is followed by specifier "optimized"
instead of a library name. The first specifier will be ignored.
This warning is for project developers. Use -Wno-dev to suppress it.


CMake Warning (dev) at src/Mod/Path/libarea/CMakeLists.txt:148 (target_link_libraries):
Link library type specifier "optimized" is followed by specifier
"optimized" instead of a library name. The first specifier will be
ignored.
This warning is for project developers. Use -Wno-dev to suppress it.
which apparently is caused by to what the Python libs are set:

Code: Select all

Found PythonLibs: optimized;optimized;optimized;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36.lib;optimized;debug;optimized;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36_d.lib;debug;C:/Projects/FreeCADLibs_12.1.2_x64_VC15/bin/libs/python36_d.lib (found suitable version "3.6.8", minimum required is "3") 
Fixed this is in "Shiboken2Config.cp36-win_amd64.cmake" line 44

Code: Select all

    if( NOT ${${PYTHON_LIBRARY}} )
      shiboken_find_required_python(3)
    endif()
wmayer wrote:
Sat Mar 30, 2019 10:59 am
In order to avoid some annoying warnings the file FreeCadLibs_12.1.2_x64_vc15\include\Inventor\system\inttypes.h should be modified by adding some guards around several defines.
So this block

Code: Select all

#define HAVE_INT8_T 1
#define HAVE_UINT8_T 1
#define HAVE_INT16_T 1
#define HAVE_UINT16_T 1
#define HAVE_INT32_T 1
#define HAVE_UINT32_T 1
#define HAVE_INT64_T 1
#define HAVE_UINT64_T 1
#define HAVE_INTPTR_T 1
#define HAVE_UINTPTR_T 1
should become

Code: Select all

#ifndef HAVE_INT8_T
#define HAVE_INT8_T 1
#endif
#ifndef HAVE_UINT8_T
#define HAVE_UINT8_T 1
#endif
#ifndef HAVE_INT16_T
#define HAVE_INT16_T 1
#endif
#ifndef HAVE_UINT16_T
#define HAVE_UINT16_T 1
#endif
#ifndef HAVE_INT32_T
#define HAVE_INT32_T 1
#endif
#ifndef HAVE_UINT32_T
#define HAVE_UINT32_T 1
#endif
#ifndef HAVE_INT64_T
#define HAVE_INT64_T 1
#endif
#ifndef HAVE_UINT64_T
#define HAVE_UINT64_T 1
#endif
#ifndef HAVE_INTPTR_T
#define HAVE_INTPTR_T 1
#endif
#ifndef HAVE_UINTPTR_T
#define HAVE_UINTPTR_T 1
#endif
Modified the header file.
I updated the libpack and uploaded again (https://github.com/apeltauer/FreeCAD/re ... bPack_12.1)
wmayer
Site Admin
Posts: 15716
Joined: Thu Feb 19, 2009 10:32 am

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby wmayer » Mon Apr 01, 2019 1:16 pm

Any news about the netgen stuff?
User avatar
apeltauer
Posts: 291
Joined: Fri Aug 11, 2017 2:19 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby apeltauer » Mon Apr 01, 2019 1:25 pm

wmayer wrote:
Mon Apr 01, 2019 1:16 pm
Any news about the netgen stuff?
No, not right now, i will try to build netgen with occ support tomorrow again....

Update:
Now i have builded netgen with occ support. But i dont understand it right now how it works... :?:
Using with occ support, the build will donwload a occ zip file from (https://github.com/NGSolve/ngsolve_depe ... _win64.zip)
This version is not the same version we are using. Also it only contains the release version.
After building netgen in debug mode i only get dlls named like the release ones e.g. (nglib.dll). This dlls are linking against the release opencascade dlls.....
Do we just need the release dlls?!?!
User avatar
sgrogan
Posts: 5800
Joined: Wed Oct 22, 2014 5:02 pm

Re: Building Libs for Windows Debug Version with VS2017/Qt5.12

Postby sgrogan » Mon Apr 01, 2019 10:29 pm

apeltauer wrote:
Mon Apr 01, 2019 1:25 pm
Now i have builded netgen with occ support. But i dont understand it right now how it works... :?:
Ouch, this is messy.
I cloned the source from here: https://github.com/NGSolve/netgen.git I attempted to build from HEAD because I have no idea what tag to use.
I banged away in the CMake gui for a while and eventually got everything to link against the 12.1.2 Libpack, I think. I got an overloaded function error in VS when trying to build the nglib project.
I'm trying to reproduce now, but I had to set paths to zlib, pybind11, occ, and tk/tcl in the Libpack after I broke the link to the NGSolve downloaded dependencies. The NG dependencies were never downloaded, I think because I started with CMake instead of using the .sln file first.

Warning: Doing it this way required an update to CMake 3.14