c++visual-studiomakefilecompiler-errors

Makefile won't find *.lib but path is declared


I am trying to compile a plugin example for a software from autodesk.

here is the 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)

problem is that when I try to run nmake, it doesn't find the file that instead are present in the directories mentioned:

$ 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.

I run $ "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 getting this message [vcvarsall.bat] Environment initialized for: 'x64' .

I have isntalled Visual Studio Tools and running from a Administrator Developer Command Prompt.

is the errror only complaining of 'libalias_api.lib'? or also for kernel32.lib? it is phrased in an ambiguous way.

Here is the guide that I followed: https://help.autodesk.com/view/ALIAS/2023/ENU/?guid=GUID-D9756922-3960-4FC6-AFFC-940A0A5E8C7F

--- UPDATE 1 --- After installing Windows SDK and still get LINK error


Solution

  • So I figured that the Makefile was just trying to put together two CLI commands.

    So I put together the two commands, and after some investigation on how to correct the syntax, I finally managed to compile everything with the following CLI commands:

    cl /c /I “C:\Program Files\Autodesk\AliasSurface2023.0\ODS\Common\include” cppView.cpp /link “C:\Program Files\Autodesk\AliasSurface2023.0\lib”;“C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64”
    
    link /LIBPATH:"C:\Program Files\Autodesk\AliasSurface2023.0\lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64" /out:cppView.exe cppView.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