我正在尝试为 Autodesk 的软件编译插件示例。
这是Makefile
##############################################################################
# Makefile for use by API developers #
# #
# NOTE: "vcvarsall amd64" must be run before attempting to compile the API #
# examples. Please see the API documentation for information. #
# #
##############################################################################
#
# If the location of the Alias libraries and header files are
# different from $ALIAS_LOCATION, set it here.
#
ALIAS_LOCATION=C:\Program Files\Autodesk\AliasSurface2023.0
CPPEXAMPLES = cppCube.exe
EXAMPLES = $(CPPEXAMPLES)
CC = cl.exe
CPLUSPLUS = cl.exe
LINK = link.exe
INCLUDES = /I. /I"$(ALIAS_LOCATION)\ODS\Common\include" /I"C:\Program Files\Windows Kits\10\Include\10.0.22621.0\ucrt" /I"C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include"
#
# Dynamic Linking.
#
EXTRA_LFLAGS = /LIBPATH:"$(ALIAS_LOCATION)\lib";"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64" /VERBOSE
EXTRA_CFLAGS =
LFLAGS = /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB:LIBC.LIB $(EXTRA_LFLAGS) /STACK:0xa00000
#
# Required libraries.
#
LIBS = libalias_api.lib
STD = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib \
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
odbc32.lib odbccp32.lib comctl32.lib netapi32.lib \
version.lib ws2_32.lib
CLIBS = $(LIBS) $(STD)
CFLAGS = /nologo /MD $(INCLUDES) $(COPIOUS_OUTPUT) $(EXTRA_CFLAGS)
CPLUSPLUSFLAGS = $(CFLAGS)
#
# Rules for building.
#
.SUFFIXES: .c .c++ .obj .cpp
.cpp.obj:
$(CPLUSPLUS) -c $(CPLUSPLUSFLAGS) $*.cpp
.c.obj:
$(CC) -c $(CFLAGS) $*.c
#
# Build all the examples.
#
default: $(EXAMPLES)
#
# Copy all the source files for the examples.
#
copy:
copy "$(ALIAS_LOCATION)\ODS\OpenModel\examples\*.cpp" .
copy "$(ALIAS_LOCATION)\ODS\OpenModel\examples\*.c" .
copy "$(ALIAS_LOCATION)\ODS\Common\examples\*.cpp" .
copy "$(ALIAS_LOCATION)\ODS\Common\examples\*.c" .
copy "$(ALIAS_LOCATION)\ODS\Common\examples\*.h" .
#
# Clean up.
#
clean:
del *.obj *.exp *.lib $(EXAMPLES)
#
# Rules for building the executables.
cppCube.exe: cppCube.obj
$(LINK) $(LFLAGS) /out:$@ cppCube.obj $(CLIBS)
问题是,当我尝试运行
nmake
时,它找不到提到的目录中存在的文件:
$ nmake
Microsoft (R) Program Maintenance Utility Version 14.37.32825.0
Copyright (C) Microsoft Corporation. All rights reserved.
link.exe /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB:LIBC.LIB /LIBPATH:"C:\Program Files\Autodesk\AliasSurface2023.0\lib";"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64" /STACK:0xa00000 /VERBOSE /out:cppCube.exe cppCube.obj libalias_api.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib netapi32.lib version.lib ws2_32.lib
Starting pass 1
Processed /DEFAULTLIB:MSVCRT
Processed /DEFAULTLIB:OLDNAMES
LINK : fatal error LNK1181: cannot open input file 'libalias_api.lib'
NMAKE : fatal error U1077: 'link.exe /nologo /SUBSYSTEM:CONSOLE /NODEFAULTLIB:LIBC.LIB /LIBPATH:"C:\Program Files\Autodesk\AliasSurface2023.0\lib";"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64" /STACK:0xa00000 /VERBOSE /out:cppCube.exe cppCube.obj libalias_api.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib netapi32.lib version.lib ws2_32.lib' : return code '0x49d'
Stop.
我跑
$ "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64
收到此消息[vcvarsall.bat] Environment initialized for: 'x64'
。
我已安装 Visual Studio 工具并从管理员开发人员命令提示符运行。
错误只是抱怨“libalias_api.lib”吗?或者也适用于 kernel32.lib?它的措辞含糊不清。
这是我遵循的指南: https://help.autodesk.com/view/ALIAS/2023/ENU/?guid=GUID-D9756922-3960-4FC6-AFFC-940A0A5E8C7F
不确定在哪里找到或运行
vcvarsall
嗯,这就是问题所在。该批处理文件设置环境变量,以便 Visual Studio 组件可以找到彼此。在这种情况下,链接器找不到 SDK。
批处理文件位于 Visual Studio 安装目录内。也可以通过开始菜单以及从 Visual Studio IDE 内部访问它。