错误在x64中编译openCTM

时间:2014-08-23 14:47:09

标签: c++ 64-bit msvc12

我试图在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

请指出我如何解决这个问题的正确方向。

1 个答案:

答案 0 :(得分:0)

好的,我发现了问题:

  1. 我安装了适用于Windows的Microsoft Visual Studio Express 2013。安装Microsoft Visual Studio Express 2013 for Desktop解决了vc12_x64问题

  2. setenv.bat文件中有对x86库的引用。正确的文件是:

  3.   

    @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\x64\;^
    C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x64\;
    
    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\x64\;^
    C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x64\;
    
    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;^
    C:\Program Files (x86)\MSBuild\12.0\Bin\amd64;
    
    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