一半君的总结纸

听话只听一半君

windows 8.1下编译alembic 1.5.8 Visual Studio 2012各种错误备忘录

想在pyqt界面里加abc viewer,神经错乱的备忘录,仅作参考

git clone https://github.com/openexr/openexr.git
cd IlmBase
setlocal
del /f CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=c:\local -G "Visual Studio 11 2012 Win64" ..\ilmbase
# 开vs build,之后右键点INSTALL project,build来安装

Boost可以下别人预先编译好的boost.teeks99.com
NumPy也有Unofficial Windows Binaries for Python Extension Packages

尝试1:
用别人的 FindNumPy.cmake

cmake -DCMAKE_INSTALL_PREFIX=c:\local -G "Visual Studio 11 Win64" ..\alembic-1_05_08

错误太多放弃…

尝试2:用alembic 1.5.8包里的自带的build\windows下的build script

下载
boost_1_58_0 prebuilt binary
hdf5-1.8.5-patch1 prebuilt binary
openexr-2.2.0
ilmbase-2.2.0
zlib-1.2.8
放到 alembic 解压以后的 contrib 目录下

备选:
sphinx 1.3.1
Graphviz 2.38

编译顺序:
zlib-1.2.8
ilmbase
openexr
pyilmbase
alembic

注意事项:

    • 如果使用VS编译openexr的时候如果出现如下错误提示,把ilmbase的lib目录加到executable directories里就可以了,如果用msbuild,似乎把lib目录加到PATH最前面也可以
      4>  Generating b44ExpLogTable.h
      4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(172,5): error MSB6006: "cmd.exe" exited with code -1073741515.
      
    • 在VS2010或以上版本,Microsoft.Cpp.x64.user.props对所有的c++ project有效,在这儿改
      %USERPROFILE%\AppData\Local\Microsoft\MSBuild
      
    • cmake常用命令
      # 查看有哪些help property
      cmake --help-property-list
      
      # 显示具体某个property的帮助
      cmake --help-property RUNTIME_OUTPUT_DIRECTORY
      
      # out of source build
      md build & cd build
      cmake -DCMAKE_INSTALL_PREFIX=d:\xx -G "Visual Studio 11 Win64" ..
      
    • git如何checkout某个release tag
      # clone之后,用这个命令查看有哪些tags
      git tag -l
      
      # 用git checkout tags/<tag_name>来checkout指定的tag
      git checkout tags/1.5.8
      

      alembic

    • pyilmbase编译的时候出现
      definition of dllimport function not allowed
      

      这是因为PyIex.vcxproj里的PreprocessorDefinitions里PyIex_EXPORTS应该是大写 PYIEX_EXPORTS
      还有PyImath.vcxproj里的PreprocessorDefinitions里PyImath_EXPORTS应该是大写 PYIMATH_EXPORTS

      所以我在D:\source\alembic-1_05_08\contrib\PyIlmBase\PyIex\CMakeLists.txt里面加上了

      ADD_DEFINITIONS(-DPYIEX_EXPORTS)
      

      在D:\source\alembic-1_05_08\contrib\PyIlmBase\PyImath\CMakeLists.txt里面加上了

      ADD_DEFINITIONS(-DPYIMATH_EXPORTS)
      

      以及出现

      fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
      

      windows系统下没有 unistd.h, 有个替代版

      如果用Debug模式会出现

      LINK : fatal error LNK1104: cannot open file 'python27_d.lib'
      

      这个一般你从python官网下的安装包不带,除非你自己用debug模式编译python,所以还是用Release模式吧

      还看到

      4>     Creating library D:/source/alembic-1_05_08/contrib/PyIlmBase/build/PyImath/Release/imathmodule.lib and object D:/source/alembic-1_05_08/contrib/PyIlmBase/build/PyImath/Release/imathmodule.exp
      4>imathmodule.obj : error LNK2019: unresolved external symbol "class boost::python::class_<class Imath_2_2::Rand32,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified> __cdecl PyImath::register_Rand32(void)" (?register_Rand32@PyImath@@YA?AV?$class_@VRand32@Imath_2_2@@Unot_specified@detail@python@boost@@U3456@U3456@@python@boost@@XZ) referenced in function "void __cdecl init_module_imath(void)" (?init_module_imath@@YAXXZ)
      4>imathmodule.obj : error LNK2019: unresolved external symbol "class boost::python::class_<class Imath_2_2::Rand48,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified> __cdecl PyImath::register_Rand48(void)" (?register_Rand48@PyImath@@YA?AV?$class_@VRand48@Imath_2_2@@Unot_specified@detail@python@boost@@U3456@U3456@@python@boost@@XZ) referenced in function "void __cdecl init_module_imath(void)" (?init_module_imath@@YAXXZ)
      4>imathmodule.obj : error LNK2019: unresolved external symbol "void __cdecl PyImath::register_StringArrays(void)" (?register_StringArrays@PyImath@@YAXXZ) referenced in function "void __cdecl init_module_imath(void)" (?init_module_imath@@YAXXZ)
      4>PyImathFun.obj : error LNK2019: unresolved external symbol "public: __cdecl PyImath::PyReleaseLock::PyReleaseLock(void)" (??0PyReleaseLock@PyImath@@QEAA@XZ) referenced in function "public: static class PyImath::FixedArray<int> __cdecl PyImath::detail::VectorizedFunction1<struct PyImath::`anonymous namespace'::abs_op<int>,struct boost::mpl::vector1<struct boost::mpl::bool_<1> >,int __cdecl(int)>::apply(class PyImath::FixedArray<int> const &)" (?apply@?$VectorizedFunction1@U?$abs_op@H@?A0x72aaa1b5@PyImath@@U?$vector1@U?$bool_@$00@mpl@boost@@@mpl@boost@@$$A6AHH@Z@detail@PyImath@@SA?AV?$FixedArray@H@3@AEBV43@@Z)
      4>PyImathBasicTypes.obj : error LNK2001: unresolved external symbol "public: __cdecl PyImath::PyReleaseLock::PyReleaseLock(void)" (??0PyReleaseLock@PyImath@@QEAA@XZ)
      4>PyImathFun.obj : error LNK2019: unresolved external symbol "public: __cdecl PyImath::PyReleaseLock::~PyReleaseLock(void)" (??1PyReleaseLock@PyImath@@QEAA@XZ) referenced in function "public: static class PyImath::FixedArray<int> __cdecl PyImath::detail::VectorizedFunction1<struct PyImath::`anonymous namespace'::abs_op<int>,struct boost::mpl::vector1<struct boost::mpl::bool_<1> >,int __cdecl(int)>::apply(class PyImath::FixedArray<int> const &)" (?apply@?$VectorizedFunction1@U?$abs_op@H@?A0x72aaa1b5@PyImath@@U?$vector1@U?$bool_@$00@mpl@boost@@@mpl@boost@@$$A6AHH@Z@detail@PyImath@@SA?AV?$FixedArray@H@3@AEBV43@@Z)
      4>PyImathBasicTypes.obj : error LNK2001: unresolved external symbol "public: __cdecl PyImath::PyReleaseLock::~PyReleaseLock(void)" (??1PyReleaseLock@PyImath@@QEAA@XZ)
      4>PyImathFun.obj : error LNK2019: unresolved external symbol "void __cdecl PyImath::dispatchTask(struct PyImath::Task &,unsigned __int64)" (?dispatchTask@PyImath@@YAXAEAUTask@1@_K@Z) referenced in function "public: static class PyImath::FixedArray<int> __cdecl PyImath::detail::VectorizedFunction1<struct PyImath::`anonymous namespace'::abs_op<int>,struct boost::mpl::vector1<struct boost::mpl::bool_<1> >,int __cdecl(int)>::apply(class PyImath::FixedArray<int> const &)" (?apply@?$VectorizedFunction1@U?$abs_op@H@?A0x72aaa1b5@PyImath@@U?$vector1@U?$bool_@$00@mpl@boost@@@mpl@boost@@$$A6AHH@Z@detail@PyImath@@SA?AV?$FixedArray@H@3@AEBV43@@Z)
      4>PyImathBasicTypes.obj : error LNK2001: unresolved external symbol "void __cdecl PyImath::dispatchTask(struct PyImath::Task &,unsigned __int64)" (?dispatchTask@PyImath@@YAXAEAUTask@1@_K@Z)
      4>D:\source\alembic-1_05_08\contrib\PyIlmBase\build\PyImath\Release\imathmodule.dll : fatal error LNK1120: 6 unresolved externals
      

      这个原因可能是因为我用的precompiled boost binary是static linking的,要么把imathmodule project的configuration type改成static,看这里Using Boost::Python::Object causes linker errors
      Boost Python class export fails to compile with linking error in visual studio 2013
      所以又只好切换回debug模式,但是少python27_d.lib,强迫症发作,不想用网上下的,自己来编译python2.7.10,乱搞以后觉得作为最终用户还是用release模式吧

      又发现新错误

      D:\source\alembic-1_05_08\contrib\PyIlmBase\PyImath\PyImathBasicTypes.cpp : fatal error C1128: number of sections exceeded object file format limit : compile with /bigobj
      

      原因 Build issue with MSVS 2010 and the C++ standard
      Penalty of the MSVS compiler flag /bigobj

    • 如何知道一个.lib或者.dll是static的还是dynamic的
      可以用VS的lib命令,如果有一堆.obj就是static的,什么都没有就是dynamic的

      lib /list foo.lib
      

      或者用dumpbin

      dumpbin /imports foo.dll
      
    • 错误
      fatal error C1083: Cannot open include file: 'inttypes.h'
      

      解决方法是
      Why Microsoft Visual Studio cannot find ?

错误

7>D:\xxx\include\openEXR\halfLimits.h(63): warning C4003: not enough actual parameters for macro 'min'
7>D:\xxx\include\openEXR\halfLimits.h(64): warning C4003: not enough actual parameters for macro 'max'

解决方法是加#define NOMINMAX
warning C4003: not enough actual parameters for macro ‘min’

    • cmake命令举例
      #cmake添加 preprocessor
      add_definitions(-DGEN_OUTFILES)
      
      # 加include
      include_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc)
      
      # 加lib搜索路径
      link_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/<lib or something similar>)
      
      add_executable(yourexe src1.c ...)
      target_link_libraries(yourexe OpenCL)
      
      # 设环境变量
      set(ENV{PATH} "/home/martink")
      
    • CMake Error: TARGETS given no LIBRARY DESTINATION for shared library target
      INSTALL(
        TARGETS lemon
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        COMPONENT library
      )
      

      自己写findxxx.cmake的module,如果cmake没自带的话:
      Using external libraries that CMake doesn’t yet have modules for

    • 错误
      82>C:\Program Files\HDF_Group\HDF5\1.8.15\bin\hdf5.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x330
      

      参考这里:
      CMake and HDF5 revisited

    • 错误:
      10>d:\source\test\alembic-1_05_08\lib\abcopengl\Foundation.h(106): fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory
      

      这是因为cmakelists.txt里似乎没设GLUT_INCLUDE_DIR

    • glut 3.7编译错误 如果看到
      fatal error U1052: file 'win32.mak' not found
      

      需要

      set "INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v6.0A\include;%INCLUDE%"
      

      此外

      LINK : fatal error LNK1104: cannot open file 'glut32.lib'
      

      打开include/gl/glut.h 去掉下面这行

      #pragma comment (lib, "glut32.lib")    /* link with Win32 GLUT lib */
      

      看这里 glut 3.7 compilation error

      glut相关参考
      How to fix this Error: #include “Cannot open source file gl/glut.h”
      Building OpenGL/GLUT Programs

      glut在cgtoolkit带了,不想自己编译的话可以去nvidia下载,看这 Cg 3.1 Toolkit Documentation
      32bit的glut编译没问题,除了需要注释掉 和改下particle.c以外, 64bit的nmake运行后出了一堆类似下面的错误提示
      glut_bitmap.obj : error LNK2019: unresolved external symbol __imp_glBitmap referenced in function glutBitmapCharacter

      glut_bitmap.obj : error LNK2019: unresolved external symbol __imp_glBitmap referenced in function glutBitmapCharacter
      ...
      MSVCRT.lib(gs_report.obj) : error LNK2019: unresolved external symbol IsProcessorFeaturePresent referenced in function __report_gsfailure
      glut32.dll : fatal error LNK1120: 115 unresolved externals
      

      所以要么用cgtoolkit里的,要么去试试freeglut
      (算不算乱搞)

http://stackoverflow.com/a/14930829

  • 错误
    9>     Creating library D:/source/test/alembic_build/lib/Alembic/Abc/Tests/Release/Abc_PropertyTests.lib and object D:/source/test/alembic_build/lib/Alembic/Abc/Tests/Release/Abc_PropertyTests.exp
    9>AlembicAbcCoreOgawa.lib(ReadUtil.obj) : error LNK2019: unresolved external symbol "private: static union half::uif const * const half::_toFloat" (?_toFloat@half@@0QBTuif@1@B) referenced in function "void __cdecl Alembic::AbcCoreOgawa::v7::ConvertData<signed char,class half>(char *,void *,unsigned __int64)" (??$ConvertData@CVhalf@@@v7@AbcCoreOgawa@Alembic@@YAXPEADPEAX_K@Z)
    9>AlembicAbcCoreAbstract.lib(ScalarSample.obj) : error LNK2001: unresolved external symbol "private: static union half::uif const * const half::_toFloat" (?_toFloat@half@@0QBTuif@1@B)
    9>AlembicAbcCoreOgawa.lib(ReadUtil.obj) : error LNK2019: unresolved external symbol "private: static unsigned short const * const half::_eLut" (?_eLut@half@@0QBGB) referenced in function "void __cdecl Alembic::AbcCoreOgawa::v7::ConvertData<signed char,class half>(char *,void *,unsigned __int64)" (??$ConvertData@CVhalf@@@v7@AbcCoreOgawa@Alembic@@YAXPEADPEAX_K@Z)
    9>AlembicAbcCoreAbstract.lib(ScalarSample.obj) : error LNK2001: unresolved external symbol "private: static unsigned short const * const half::_eLut" (?_eLut@half@@0QBGB)
    9>D:\source\test\alembic_build\lib\Alembic\Abc\Tests\Release\Abc_PropertyTests.exe : fatal error LNK1120: 2 unresolved externals
    

    未解决 这个据说是因为code generation里runtime library选的不一样造成的,把half.cpp加进project可以,不过这不算解决吧
    参考链接:
    Compiling woes on windows
    [Solution] OpenVDB 3.0 for Win 7 64-bit / VS2010
    Why should one not derive from c++ std string class?
    A Pragmatic Look at Exception Specifications

    ps: 这可能是和project dependency有关,假设project A(.exe) 需要用到project B (static lib)里的某个lib, 但是A不知道要去B的lib里找那个symbol
    Flexible Project-to-Project References

  • 错误
    13>  PyAlembicOpenGL.cpp
    13>D:\source\test\alembic-1_05_08\python\PyAbcOpenGL\Foundation.h(39): fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
    13>  main.cpp
    13>C:\local\boost_1_55_0\boost/python/detail/wrap_python.hpp(50): fatal error C1083: Cannot open include file: 'pyconfig.h': No such file or directory
    

    添加python include目录

  • 13>C:\local\boost_1_55_0\boost/config/auto_link.hpp(365): fatal error C1004: unexpected end-of-file found
    

    未解决

  • 错误
    d:\xxx\include\openexr\IexBaseExc.h(171): warning C4275: non dll-interface class 'Iex_2_2::BaseExc' used as base for dll-interface class 'Iex_2_2::TypeExc'
    

    未解决 [Openexr-devel] OpenEXR v2.1.0 released

  • https://github.com/openexr/openexr/issues/86
    How to dllexport a class derived from std::runtime_error?相关参考:
    [Openexr-devel] Strange issue with half and _toFloat array.
    HowTo: Export C++ classes from a DLL

尝试3:
使用github上的alembic时遇到的错误:

    • fatal error LNK1104: cannot open file 'boost_python-vc110-mt-1_55.lib'
      

      加了BOOST_ALL_NO_LIB禁止autolinking, 应该这样么

    • unresolved external symbol WSAStartup referenced in function main
      

      这里乱搞 加

      #pragma comment(lib, "Ws2_32.lib")
      
    • 3>c:\localx\boost_1_55_0\boost/get_pointer.hpp(42): error C2995: 'T *boost::get_pointer(const std::shared_ptr<_Ty> &)' : function template has already been defined
      

      这个和ALEMBIC_LIB_USES_BOOST或者ALEMBIC_LIB_USES_TR1有关,Foundation.h注释中写道

      // if Alembic uses shared_ptr from boost, then we don't need this function because boost provides it
      // if Alembic uses shared_ptr from std, then we don't need this function because boost provides it since 1.53
      // if Alembic uses shared_ptr from tr1, then we do need this function
      

      在alembic/CmakeLists.txt里的判断似乎在win下不对
      CHECK_CXX_COMPILER_FLAG(“-std=c++11” COMPILER_SUPPORTS_CXX11)

      参考:
      Getting CMake CHECK_CXX_COMPILER_FLAG to work

  • 最后一次尝试,ilmbase用的static,pyilmbase用的dynamic,都没问题,但是alembic编译的时候有错误如下
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2019: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z) referenced in function "class boost::python::api::object __cdecl `anonymous namespace'::ConvertStrings(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &)" (?ConvertStrings@?A0x7a5a7d98@@YA?AVobject@api@python@boost@@AEBV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2001: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createFromRawArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)
    error LNK2019: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > * __cdecl PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >::createFromRawArray(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const *,unsigned __int64)" (?createFromRawArray@?$StringArrayT@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@PyImath@@SAPEAV12@PEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@_K@Z) referenced in function "public: static struct _object * __cdecl StringArraySampleToFixedArray<struct Alembic::Abc::v7::WstringTPTraits>::convert(class Alembic::Abc::v7::TypedArraySample<struct Alembic::Abc::v7::WstringTPTraits> const &)" (?convert@?$StringArraySampleToFixedArray@UWstringTPTraits@v7@Abc@Alembic@@@@SAPEAU_object@@AEBV?$TypedArraySample@UWstringTPTraits@v7@Abc@Alembic@@@v7@Abc@Alembic@@@Z)
    error LNK2019: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::createDefaultArray(unsigned __int64)" (?createDefaultArray@?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@SAPEAV12@_K@Z) referenced in function "class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > * __cdecl createArray<class PyImath::StringArrayT<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >(unsigned __int64)" (??$createArray@V?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@@@YAPEAV?$StringArrayT@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@PyImath@@_K@Z)
    error LNK2019: unresolved external symbol "public: static class PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > * __cdecl PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >::createDefaultArray(unsigned __int64)" (?createDefaultArray@?$StringArrayT@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@PyImath@@SAPEAV12@_K@Z) referenced in function "class PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > * __cdecl createArray<class PyImath::StringArrayT<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > >(unsigned __int64)" (??$createArray@V?$StringArrayT@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@PyImath@@@@YAPEAV?$StringArrayT@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@PyImath@@_K@Z)
    3>D:\source\github_mine\alembic_build\python\PyAlembic\Release\alembicmodule.dll : fatal error LNK1120: 4 unresolved externals
    
    

    dependency walker打开pyimath.dll里确实没有那个symbol,试了半天,看到PyImathStringArray.cpp里有这两行啊,

    template class PYIMATH_EXPORT StringArrayT<std::string>;
    template class PYIMATH_EXPORT StringArrayT<std::wstring>;
    

    乱搞把PYIMATH_EXPORT硬换成__declspec(dllexport),居然有了,然后发觉在PyImathExport.h里,PLATFORM_WINDOWS preprocessor没设,所以在
    cmakeLists.txt里加上了

    if(WIN32)
    	add_definitions(-DPLATFORM_WINDOWS)
    endif()
    

    这个为啥还要我自己加,是他们就根本没打算给windows的人用么?

    相关参考:
    Visual Studio dll export issue for class and function template instantiationsWhy can templates only be implemented in the header file?
    C++ Shared Library with Templates: Undefined symbols error
    C++ Super-FAQ – Why can’t I separate the definition of my templates class from its declaration and put it inside a .cpp file?

参考:
CMake and Visual Studio

和本贴无关,如果想在VS里用freeglut,可以用NuGet Package Manager-装
How do you install GLUT and OpenGL in Visual Studio 2012?
https://www.nuget.org/

Documenting Python using Doxygen

c++参考:
Throw() in Function Signature in C++

For this version of Visual C++ Use this compiler version
Visual C++ 4.x MSC_VER=1000
Visual C++ 5 MSC_VER=1100
Visual C++ 6 MSC_VER=1200
Visual C++ .NET MSC_VER=1300
Visual C++ .NET 2003 MSC_VER=1310
Visual C++ 2005 MSC_VER=1400
Visual C++ 2008 MSC_VER=1500
Visual C++ 2010 MSC_VER=1600
Visual C++ 2012 MSC_VER=1700
Visual C++ 2013 MSC_VER=1800
[/code
]

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: