ZLib linking issues

Hello Everyone,

I am trying to use opennurbs latest version and link it to my src code but I have linking issues at the end with zlib. Any idea why it is happening?


Also, I am linking in Cmake in this way:
find_library(STARPU_LIBRARY NAMES starpu-1.4 PATHS /home/babazado/.local/easybuild/software/2023/x86-64-v3/MPI/gcc12/openmpi4/starpu/1.4.3/lib64)

find_library(H-MATRIX-LIBRARY NAMES H_matrix PATHS “${CMAKE_BINARY_DIR}/SRC/H_matrix”)

find_library(EM-LIBS-MATH-LIBRARY NAMES Math PATHS “${CMAKE_BINARY_DIR}/SRC/EM_LIBS/Math”)

find_library(EM-LIBS-MATRIX-LIBRARY NAMES Matrix PATHS “${CMAKE_BINARY_DIR}/SRC/EM_LIBS/Matrix”)

find_library(OPENNURBS-LIBRARY NAMES opennurbsStatic PATHS “${CMAKE_BINARY_DIR}/SRC/opennurbs”)

find_library(ZLIB-LIBRARY NAMES zlib PATHS “${CMAKE_BINARY_DIR}/SRC/opennurbs/zlib”)

find_library(UUID-LIBRARY NAMES uuid PATHS /usr/lib /usr/local/lib)

target_link_libraries(LCN-HMatrix PUBLIC
LCN
${OPENNURBS-LIBRARY}

${UUID-LIBRARY}

${ZLIB-LIBRARY} 

${EM-LIBS-MATH-LIBRARY} 

${EM-LIBS-MATRIX-LIBRARY} 

${H-MATRIX-LIBRARY} 

${STARPU-LIBRARY})

It can find the .a files for all directories I am trying to link. and I see those in my build directory. You can see my cmake file for the main.cpp directory as well.

CMakeLists.txt (4.1 KB)

openNURBS already links to zlib in its own CMakeLists.txt.

This is a very simple CMakeLists.txt for a little test I was working on the other day, I don’t do anything related to zlib here because openNURBS already takes care of the linking:

cmake_minimum_required(VERSION 3.16)
project(samplecppreadtextentities)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(../../src/lib/opennurbs build_opennurbs)

if (MSVC)
  add_definitions(-DOPENNURBS_IMPORTS)
endif()


add_executable(
  samplecppreadtextentities
  SampleCppReadTextEntity.cpp
)

target_link_libraries(samplecppreadtextentities OpenNURBS)

The difference is that OP is using opennurbsStatic library, while @fraguada - you’re using the shared library. If @Omid1 can use the shared library for opennurbs that’d be great.

1 Like

Hi @fraguada and @menno . I used shared library and it is linking without issue now. Thanks for the comments and help!

2 Likes