我正在尝试在 x64 中使用 VC12 编译 openCTM。OpenCTM 下载自:openctm-1.0.3-src.zip
为了编译,我运行:nmake /f Makefile.msvc
要设置环境,我使用以下 bat 文件:
@rem Setting environment for using Microsoft Visual Studio x86/x64 tools.
@echo off
@if "%1"=="vc11_x86" goto set_vc11_x86
@if "%1"=="vc11_x64" goto set_vc11_x64
@if "%1"=="vc12_x64" goto set_vc12_x64
@if "%1"=="" goto error
:set_vc11_x86
@echo Setting environment for using Microsoft Visual Studio 2011 x86 tools.
set INCLUDE=^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;^
C:\Program Files (x86)\Windows Kits\8.1\Include\um;^
C:\Program Files (x86)\Windows Kits\8.1\Include\shared;^
C:\Program Files (x86)\Windows Kits\8.1\Include\WinRT;
set LIB=^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\;^
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\;^
C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x86\;
set PATH=^
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;^
%SystemRoot%\system32;^
%SystemRoot%;^
%SystemRoot%\System32\Wbem;^
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;^
C:\MinGW\bin\;^
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;^
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;^
C:\Qt\Qt5.3.1\5.3\msvc2013_64_opengl\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;^
C:\Program Files (x86)\Windows Kits\8.1\bin\x86\;
goto test_bin_locations
:set_vc11_x64
@echo Setting environment for using Microsoft Visual Studio 2011 x64 tools.
set INCLUDE=^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;^
C:\Program Files (x86)\Windows Kits\8.1\Include\um;^
C:\Program Files (x86)\Windows Kits\8.1\Include\shared;^
C:\Program Files (x86)\Windows Kits\8.1\Include\WinRT;
set LIB=^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\;^
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\;^
C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x86\;
set PATH=^
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;^
%SystemRoot%\system32;^
%SystemRoot%;^
%SystemRoot%\System32\Wbem;^
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;^
C:\MinGW\bin\;^
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;^
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;^
C:\Qt\Qt5.3.1\5.3\msvc2013_64_opengl\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\;^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\;^
C:\Program Files (x86)\Windows Kits\8.1\bin\x64;
goto test_bin_locations
:set_vc12_x64
@echo Setting environment for using Microsoft Visual Studio 2012 x64 tools.
set INCLUDE=^
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include;^
C:\Program Files (x86)\Windows Kits\8.1\Include\um;^
C:\Program Files (x86)\Windows Kits\8.1\Include\shared;^
C:\Program Files (x86)\Windows Kits\8.1\Include\WinRT;
set LIB=^
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64\;^
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\;^
C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x86\;
set PATH=^
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;^
%SystemRoot%\system32;^
%SystemRoot%;^
%SystemRoot%\System32\Wbem;^
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;^
C:\MinGW\bin\;^
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;^
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;^
C:\Qt\Qt5.3.1\5.3\msvc2013_64_opengl\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\;^
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\;^
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\;^
C:\Program Files (x86)\Windows Kits\8.1\bin\x64;
goto test_bin_locations
:test_bin_locations
@echo on
where nmake
where cl.exe
where link.exe
@echo off
goto:eof
:error
@echo Usage: setenv.bat [vc11_x86^|vc11_x64^|vc12_x64]
goto:eof
使用vc11_x86环境编译生成openctm.dll。
但是在使用 vc11_x64 或 vc12_x64 环境时会失败。
vc12_x64 主要错误:
link /MACHINE:X64 /nologo /out:openctm.dll /dll /implib:openctm.lib /def
:openctm-msvc.def openctm.obj stream.obj compressRAW.obj compressMG1.obj com
pressMG2.obj Alloc.obj LzFind.obj LzmaDec.obj LzmaEnc.obj LzmaLib.obj openct
m.res
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'
vc11_x86 主要错误:
Alloc.obj : error LNK2001: unresolved external symbol free
openctm.obj : error LNK2019: unresolved external symbol free referenced in funct
ion ctmFreeContext
stream.obj : error LNK2001: unresolved external symbol free
compressMG1.obj : error LNK2001: unresolved external symbol free
compressMG2.obj : error LNK2001: unresolved external symbol free
Alloc.obj : error LNK2001: unresolved external symbol malloc
openctm.obj : error LNK2019: unresolved external symbol malloc referenced in fun
ction ctmNewContext
请指出我如何解决这个问题的正确方向。