Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-DBUILD_SHARED_LIBS on MSVC fails #328

Closed
hobu opened this issue Jan 10, 2018 · 10 comments
Closed

-DBUILD_SHARED_LIBS on MSVC fails #328

hobu opened this issue Jan 10, 2018 · 10 comments
Assignees

Comments

@hobu
Copy link

hobu commented Jan 10, 2018

Configuring with -DBUILD_SHARED_LIBS=ON fails with MSVC 2015:

cmake -G "NMake Makefiles" ^
    -DCMAKE_INSTALL_PREFIX=c:/OSGeo4W64 ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DBUILD_SHARED_LIBS=ON ^
    ..
C:\projects\draco\src\draco/mesh/mesh.h(136): warning C4267: 'argument': conversion from 'size_t' to 'const int32_t', possible loss of data
NMAKE : fatal error U1073: don't know how to make 'dracodec.lib'
@FrankGalligan
Copy link
Collaborator

Reproduced with:
cmake ../ -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON

Works with:
cmake ../ -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
cmake ../ -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release

@hobu
Copy link
Author

hobu commented Mar 14, 2018

Does this mean that Draco is MSVC 2017+ only?

@tomfinegan
Copy link
Contributor

C:\projects\draco\src\draco/mesh/mesh.h(136): warning C4267: 'argument': conversion from 'size_t'
to 'const int32_t', possible loss of data
NMAKE : fatal error U1073: don't know how to make 'dracodec.lib'

That's a warning. Have you added -DENABLE_WERROR=1 to your CMake command line, or somehow added /WX to your cl.exe command lines?

@hobu
Copy link
Author

hobu commented Mar 14, 2018

Yes, there were a number of warnings. That's ok
The error that matters to me is the inability of 2015 to make the library.

NMAKE : fatal error U1073: don't know how to make 'dracodec.lib'

@hobu
Copy link
Author

hobu commented Mar 14, 2018

Sorry, I forgot to mention that it builds just fine for me on both 2017 and 2015 with -DBUILD_SHARED_LIBS=OFF

@tomfinegan
Copy link
Contributor

Can you run the nmake build in verbose mode? This should work:
$ nmake VERBOSE=1

Is any additional information provided w/VERBOSE enabled?

Are any targets working? Which target is NMake building when the error is reported?

@hobu
Copy link
Author

hobu commented Mar 14, 2018

draco_version.cc
[ 79%] Linking CXX shared library dracodec.dll
        "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --intdir=CMakeFiles\dracodec.dir --manifests  -- C:\PROGRA
~2\MICROS~1.0\VC\bin\amd64\link.exe  @CMakeFiles\dracodec.dir\objects1.rsp @C:\Users\hobu\AppData\Local\Temp\nmF580.tmp
Visual Studio Non-Incremental Link
LINK:
C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\link.exe @CMakeFiles\dracodec.dir\objects1.rsp /out:dracodec.dll /implib:dracodec.li
b /pdb:C:\projects\draco\build\dracodec.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO kernel32.lib user32.lib gdi32
.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:dracodec
.dll.manifest
Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

CMakeFiles/dracodec.dir/draco_version.cc.obj CMakeFiles/draco_attributes.dir/src/draco/attributes/attribute_octahedron_t
ransform.cc.obj CMakeFiles/draco_attributes.dir/src/draco/attributes/attribute_quantization_transform.cc.obj CMakeFiles/
draco_attributes.dir/src/draco/attributes/attribute_transform.cc.obj CMakeFiles/draco_attributes.dir/src/draco/attribute
s/geometry_attribute.cc.obj CMakeFiles/draco_attributes.dir/src/draco/attributes/point_attribute.cc.obj CMakeFiles/draco
_compression_attributes_dec.dir/src/draco/compression/attributes/attributes_decoder.cc.obj CMakeFiles/draco_compression_
attributes_dec.dir/src/draco/compression/attributes/kd_tree_attributes_decoder.cc.obj CMakeFiles/draco_compression_attri
butes_dec.dir/src/draco/compression/attributes/sequential_attribute_decoder.cc.obj CMakeFiles/draco_compression_attribut
es_dec.dir/src/draco/compression/attributes/sequential_attribute_decoders_controller.cc.obj CMakeFiles/draco_compression
_attributes_dec.dir/src/draco/compression/attributes/sequential_integer_attribute_decoder.cc.obj CMakeFiles/draco_compre
ssion_attributes_dec.dir/src/draco/compression/attributes/sequential_normal_attribute_decoder.cc.obj CMakeFiles/draco_co
mpression_attributes_dec.dir/src/draco/compression/attributes/sequential_quantization_attribute_decoder.cc.obj CMakeFile
s/draco_compression_decode.dir/src/draco/compression/decode.cc.obj CMakeFiles/draco_compression_mesh_dec.dir/src/draco/c
ompression/mesh/mesh_decoder.cc.obj CMakeFiles/draco_compression_mesh_dec.dir/src/draco/compression/mesh/mesh_edgebreake
r_decoder.cc.obj CMakeFiles/draco_compression_mesh_dec.dir/src/draco/compression/mesh/mesh_edgebreaker_decoder_impl.cc.o
bj CMakeFiles/draco_compression_mesh_dec.dir/src/draco/compression/mesh/mesh_sequential_decoder.cc.obj CMakeFiles/draco_
compression_point_cloud_dec.dir/src/draco/compression/point_cloud/point_cloud_decoder.cc.obj CMakeFiles/draco_compressio
n_point_cloud_dec.dir/src/draco/compression/point_cloud/point_cloud_kd_tree_decoder.cc.obj CMakeFiles/draco_compression_
point_cloud_dec.dir/src/draco/compression/point_cloud/point_cloud_sequential_decoder.cc.obj CMakeFiles/draco_core.dir/sr
c/draco/core/cycle_timer.cc.obj CMakeFiles/draco_core.dir/src/draco/core/data_buffer.cc.obj CMakeFiles/draco_core.dir/sr
c/draco/core/decoder_buffer.cc.obj CMakeFiles/draco_core.dir/src/draco/core/divide.cc.obj CMakeFiles/draco_core.dir/src/
draco/core/draco_types.cc.obj CMakeFiles/draco_core.dir/src/draco/core/encoder_buffer.cc.obj CMakeFiles/draco_core.dir/s
rc/draco/core/hash_utils.cc.obj CMakeFiles/draco_core.dir/src/draco/core/options.cc.obj CMakeFiles/draco_core.dir/src/dr
aco/core/quantization_utils.cc.obj CMakeFiles/draco_core.dir/src/draco/core/shannon_entropy.cc.obj CMakeFiles/draco_core
.dir/src/draco/core/symbol_coding_utils.cc.obj CMakeFiles/draco_core.dir/src/draco/core/symbol_decoding.cc.obj CMakeFile
s/draco_core.dir/src/draco/core/symbol_encoding.cc.obj CMakeFiles/draco_core_bit_coders.dir/src/draco/core/bit_coders/ad
aptive_rans_bit_decoder.cc.obj CMakeFiles/draco_core_bit_coders.dir/src/draco/core/bit_coders/adaptive_rans_bit_encoder.
cc.obj CMakeFiles/draco_core_bit_coders.dir/src/draco/core/bit_coders/direct_bit_decoder.cc.obj CMakeFiles/draco_core_bi
t_coders.dir/src/draco/core/bit_coders/direct_bit_encoder.cc.obj CMakeFiles/draco_core_bit_coders.dir/src/draco/core/bit
_coders/rans_bit_decoder.cc.obj CMakeFiles/draco_core_bit_coders.dir/src/draco/core/bit_coders/rans_bit_encoder.cc.obj C
MakeFiles/draco_core_bit_coders.dir/src/draco/core/bit_coders/symbol_bit_decoder.cc.obj CMakeFiles/draco_core_bit_coders
.dir/src/draco/core/bit_coders/symbol_bit_encoder.cc.obj CMakeFiles/draco_dec_config.dir/draco_dec_config.cc.obj CMakeFi
les/draco_io.dir/src/draco/io/mesh_io.cc.obj CMakeFiles/draco_io.dir/src/draco/io/obj_decoder.cc.obj CMakeFiles/draco_io
.dir/src/draco/io/obj_encoder.cc.obj CMakeFiles/draco_io.dir/src/draco/io/parser_utils.cc.obj CMakeFiles/draco_io.dir/sr
c/draco/io/ply_decoder.cc.obj CMakeFiles/draco_io.dir/src/draco/io/ply_encoder.cc.obj CMakeFiles/draco_io.dir/src/draco/
io/ply_reader.cc.obj CMakeFiles/draco_io.dir/src/draco/io/point_cloud_io.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh
/corner_table.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh/mesh.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh/mesh_
are_equivalent.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh/mesh_attribute_corner_table.cc.obj CMakeFiles/draco_mesh.
dir/src/draco/mesh/mesh_cleanup.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh/mesh_misc_functions.cc.obj CMakeFiles/dr
aco_mesh.dir/src/draco/mesh/mesh_stripifier.cc.obj CMakeFiles/draco_mesh.dir/src/draco/mesh/triangle_soup_mesh_builder.c
c.obj CMakeFiles/draco_metadata.dir/src/draco/metadata/geometry_metadata.cc.obj CMakeFiles/draco_metadata.dir/src/draco/
metadata/metadata.cc.obj CMakeFiles/draco_metadata_dec.dir/src/draco/metadata/metadata_decoder.cc.obj CMakeFiles/draco_p
oint_cloud.dir/src/draco/point_cloud/point_cloud.cc.obj CMakeFiles/draco_point_cloud.dir/src/draco/point_cloud/point_clo
ud_builder.cc.obj CMakeFiles/draco_points_dec.dir/src/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd
_tree_decoder.cc.obj CMakeFiles/draco_points_dec.dir/src/draco/compression/point_cloud/algorithms/float_points_tree_deco
der.cc.obj
MT:
C:/Program Files (x86)/Windows Kits/8.1/bin/x64/mt.exe /nologo /manifest dracodec.dll.manifest /outputresource:dracodec.
dll;#2
[ 79%] Built target dracodec
        "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe" -f CMakeFiles\draco_decoder.dir\bui
ld.make /nologo -L                  CMakeFiles\draco_decoder.dir\depend
        "C:\Program Files\CMake\bin\cmake.exe" -E cmake_depends "NMake Makefiles" C:\projects\draco C:\projects\draco C:
\projects\draco\build C:\projects\draco\build C:\projects\draco\build\CMakeFiles\draco_decoder.dir\DependInfo.cmake --co
lor=
Dependee "C:\projects\draco\build\CMakeFiles\draco_decoder.dir\DependInfo.cmake" is newer than depender "C:/projects/dra
co/build/CMakeFiles/draco_decoder.dir/depend.internal".
Dependee "C:/projects/draco/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "C:/projects/draco/
build/CMakeFiles/draco_decoder.dir/depend.internal".
Scanning dependencies of target draco_decoder
        "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe" -f CMakeFiles\draco_decoder.dir\bui
ld.make /nologo -L                  CMakeFiles\draco_decoder.dir\build
[ 80%] Building CXX object CMakeFiles/draco_decoder.dir/src/draco/tools/draco_decoder.cc.obj
        C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  @C:\Users\hobu\AppData\Local\Temp\nmFDDC.tmp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl   /TP  -IC:\projects\draco\..\googletest -IC:\projects\draco\src /DWIN32 /D_WINDOWS /W3 /GR /EHsc -DDRACO_POINT_CLOUD
_COMPRESSION_SUPPORTED -DDRACO_MESH_COMPRESSION_SUPPORTED -DDRACO_STANDARD_EDGEBREAKER_SUPPORTED -DDRACO_PREDICTIVE_EDGE
BREAKER_SUPPORTED -DDRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -DDRACO_ATTRIBUTE_DEDUPLICATION_SUPPORTED /MT /O2 /Ob2 /DNDE
BUG /FoCMakeFiles\draco_decoder.dir\src\draco\tools\draco_decoder.cc.obj /FdCMakeFiles\draco_decoder.dir\ /FS -c C:\proj
ects\draco\src\draco\tools\draco_decoder.cc

draco_decoder.cc
C:\projects\draco\src\draco/attributes/point_attribute.h(68): warning C4267: '=': conversion from 'size_t' to 'unsigned
int', possible loss of data
C:\projects\draco\src\draco/metadata/metadata.h(134): warning C4267: 'return': conversion from 'size_t' to 'int', possib
le loss of data
C:\projects\draco\src\draco/point_cloud/point_cloud.h(57): warning C4267: 'return': conversion from 'size_t' to 'int32_t
', possible loss of data
C:\projects\draco\src\draco/mesh/mesh.h(51): warning C4267: 'argument': conversion from 'size_t' to 'const uint32_t', po
ssible loss of data
C:\projects\draco\src\draco/mesh/mesh.h(61): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possib
le loss of data
C:\projects\draco\src\draco/mesh/mesh.h(136): warning C4267: 'argument': conversion from 'size_t' to 'const uint32_t', p
ossible loss of data
NMAKE : fatal error U1073: don't know how to make 'dracodec.lib'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code
'0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code
'0x2'

@hobu
Copy link
Author

hobu commented Aug 21, 2018

Thanks for the fix. I just tried it out and I get past building the draco.dll, but the tests do not build completely (they build without trouble in a static, non-BUILD_SHARED_LIBS=ON configuration, however).

[ 96%] Linking CXX executable draco_tests.exe
LINK: command "C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\draco_tests.dir\objects1.rsp /out:draco_tests.exe /implib:draco_tests.lib /pdb:C:\projects\draco\build\draco_tests.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console draco.lib googletest\googlemock\gtest\gtest.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:draco_tests.exe.manifest" failed (exit code 1120) with the following output:
mesh_encoder_test.cc.obj : error LNK2019: unresolved external symbol "class testing::internal::Mutex testing::internal::g_linked_ptr_mutex" (?g_linked_ptr_mutex@internal@testing@@3VMutex@12@A) referenced in function "class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> * __cdecl std::_Uninitialized_move_al_unchecked1<class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> *,class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> *,class std::allocator<class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> > >(class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> *,class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> *,class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> *,struct std::_Wrap_alloc<class std::allocator<class testing::internal::linked_ptr<struct testing::internal::ParameterizedTestCaseInfo<class draco::MeshEncoderTest>::TestInfo> > > &,struct std::_General_ptr_iterator_tag,struct std::_Any_tag)" (??$_Uninitialized_move_al_unchecked1@PEAV?$linked_ptr@UTestInfo@?$ParameterizedTestCaseInfo@VMeshEncoderTest@draco@@@internal@testing@@@internal@testing@@PEAV123@V?$allocator@V?$linked_ptr@UTestInfo@?$ParameterizedTestCaseInfo@VMeshEncoderTest@draco@@@internal@testing@@@internal@testing@@@std@@@std@@YAPEAV?$linked_ptr@UTestInfo@?$ParameterizedTestCaseInfo@VMeshEncoderTest@draco@@@internal@testing@@@internal@testing@@PEAV123@00AEAU?$_Wrap_alloc@V?$allocator@V?$linked_ptr@UTestInfo@?$ParameterizedTestCaseInfo@VMeshEncoderTest@draco@@@internal@testing@@@internal@testing@@@std@@@0@U_General_ptr_iterator_tag@0@U_Any_tag@0@@Z)
draco_tests.exe : fatal error LNK1120: 1 unresolved externals

@tomfinegan tomfinegan reopened this Aug 29, 2018
@tomfinegan
Copy link
Contributor

I won't have time to look into this for at least a couple of days, as far as workarounds go: Just disable the tests when doing shared library builds for now.

I suspect the fix for this may be to avoid use of the CMake support in googletest in favor of referencing the sources directly as a static library in the Draco CMake file. If you want to try that yourself it's not very difficult. Basically:

  1. Comment out the add_subdirectory call that pulls in googletest's CMake build.
  2. Add this in the same place:

include_directories("${GTEST_SRC_DIR}/googletest")
add_library(gtest STATIC "${GTEST_SRC_DIR}/googletest/gtest-all.cc")

I think that's it. If you try this and run into any issues: Please post them here.

@hobu
Copy link
Author

hobu commented Oct 2, 2018

Reporting back that the tests are running for me now. There's a failure, but I'll make a new ticket for it.

@hobu hobu closed this as completed Oct 2, 2018
dyangrun added a commit to dyangrun/draco that referenced this issue Apr 29, 2019
commit 785c9c4
Merge: deef28e a32c1f0
Author: Lou Quillio <[email protected]>
Date:   Wed Mar 13 13:52:24 2019 -0700

    Merge pull request google#511 from louquillio/update-copyright-footer

    Update page footer template to display current year in copyright legend.

commit a32c1f0
Author: Lou Quillio <[email protected]>
Date:   Wed Mar 13 13:49:10 2019 -0700

    Update page footer template to display current year in copyright legend.

    Hopefully also kicks off a gh-pages rebuild.

commit deef28e
Merge: bb91e08 df1d453
Author: Lou Quillio <[email protected]>
Date:   Wed Mar 13 13:36:41 2019 -0700

    Merge pull request google#510 from louquillio/update-gems

    Update gems to address reported vulnerabilities.

commit df1d453
Author: Lou Quillio <[email protected]>
Date:   Wed Mar 13 13:32:33 2019 -0700

    Update gems to address reported vulnerabilities.

commit bb91e08
Author: Katrin Leinweber <[email protected]>
Date:   Wed Mar 6 00:37:34 2019 +0100

    Hyperlink DOI to preferred resolver (google#501)

    See https://www.doi.org/doi_handbook/3_Resolution.html#3.8

commit 265bbfc
Author: Frederic L <[email protected]>
Date:   Wed Mar 6 00:33:20 2019 +0100

    attributes/point_d_vector: Prevent a singend/unsigned mismatch (google#489)

commit d132946
Author: thibault <[email protected]>
Date:   Wed Mar 6 00:26:12 2019 +0100

    Remove useless semicolons after macros (google#473)

commit 8833cf8
Author: Igor Vytyaz <[email protected]>
Date:   Thu Jan 31 10:18:06 2019 -0800

    Updated snapshot to 1.3.5
    * Added option to build Draco for Universal Scene Description
    * Code cleanup
    * Bug fixes

commit e9337d1
Merge: eee8bf5 9648d72
Author: Tom Finegan <[email protected]>
Date:   Wed Sep 26 09:21:16 2018 -0700

    Merge pull request google#468 from google/restore_ie_compat

    Restore IE support.

commit 9648d72
Author: Tom Finegan <[email protected]>
Date:   Wed Sep 26 08:52:07 2018 -0700

    Restore IE support.

    Closes google#466

commit eee8bf5
Merge: 063994c 407c1d5
Author: FrankGalligan <[email protected]>
Date:   Mon Aug 20 16:04:59 2018 -0700

    Merge pull request google#455 from FreddyFunk/update_contributing_for_styleguide

    Update CONTRIBUTING.md

commit 407c1d5
Author: Frederic Laing <[email protected]>
Date:   Sun Aug 19 16:54:50 2018 +0200

    Update CONTRIBUTING.md

commit 063994c
Author: Frank Galligan <[email protected]>
Date:   Fri Aug 17 12:01:27 2018 -0700

    Update snapshot to 1.3.4

commit c93f507
Merge: e3a9d6c 5c15f38
Author: FrankGalligan <[email protected]>
Date:   Wed Aug 15 09:04:52 2018 -0700

    Merge pull request google#452 from google/fix_shared_nmake_build

    Fix NMake builds with BUILD_SHARED_LIBS enabled.

commit 5c15f38
Author: Tom Finegan <[email protected]>
Date:   Tue Aug 14 15:14:30 2018 -0700

    Fix NMake builds with BUILD_SHARED_LIBS enabled.

    Fixes google#328

# Conflicts:
#	CMakeLists.txt
danielgronlund pushed a commit to danielgronlund/draco that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants