none
Unable to create snmpdemo.exe RRS feed

  • Question

  • I have just downloaded Net-SNMP and compiled using VC 2017. Now I am trying to write my own C Application as provided here.

    I am a Unix guy and have created a .c file named snmpdemo.c - now I need compile and link to create a snmpdemo.exe in Windows. I am using Visual Studio for same.

    I crated the following makefile.txt - out by looking into existing makefiles:

    PROGNAME=snmpdemo
    LINKTYPE=static
    Output_Directory=.\release
    CFLAGS=/D WIN32 /D _BIND_TO_CURRENT_VCLIBS_VERSION /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\tools\netsnmp\net-snmp-5.8\c_api\$(Output_Directory)\ /FdC:\tools\netsnmp\net-snmp-5.8\c_api\$(Output_Directory)\$(PROGNAME).pdb /FoC:\tools\netsnmp\net-snmp-5.8\c_api\$(Output_Directory)\ /I C:\tools\netsnmp\net-snmp-5.8\include /I C:\OpenSSL-Win64\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2 
    LDFLAGS=/libpath:C:\OpenSSL-Win64\lib\VC /FS
    
    # Set to 1 to allow the building using the DLL version of SNMPLIB.
    ALLOW_DLL=1
    
    CPP=cl.exe
    CPP_PROJ=/I.. /I..\..\include $(CFLAGS)
    snmpdemo.obj::
       $(CPP) $(CPP_PROJ) $(PROGNAME).c
    
    RSC=rc.exe
    LINK32=link.exe
    LINK32_FLAGS=netsnmp.lib advapi32.lib ws2_32.lib kernel32.lib user32.lib /nologo /subsystem:console /pdb:"C:\tools\netsnmp\net-snmp-5.8\c_api\$(PROGNAME).pdb" /out:"C:\tools\netsnmp\net-snmp-5.8\c_api\$(PROGNAME).exe" /libpath:"../lib/$(INTDIR)" $(LDFLAGS)
    LINK32_OBJS= "$(PROGNAME).obj"
    
    

    But when I try to compile the code I get below issue:

    MINGW64 /c/tools/netsnmp/net-snmp-5.8/c_api
    $ "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
    **********************************************************************
    ** Visual Studio 2017 Developer Command Prompt v15.8.7
    ** Copyright (c) 2017 Microsoft Corporation
    **********************************************************************
    [vcvarsall.bat] Environment initialized for: 'x64'
    
    MINGW64 /c/tools/netsnmp/net-snmp-5.8/c_api
    $ nmake -f makefile.txt
    
    Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            cl.exe /I.. /I..\..\include /D WIN32 /D _BIND_TO_CURRENT_VCLIBS_VERSION /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\ /FdC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\snmpdemo.pdb /FoC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\ /I C:\tools\netsnmp\net-snmp-5.8\include /I C:\OpenSSL-Win64\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2 snmpdemo.c
    snmpdemo.c
    C:\tools\netsnmp\net-snmp-5.8\include\net-snmp/net-snmp-includes.h(14): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64\cl.exe"' : return code '0x2'
    Stop.
    

    How can I build the executable?


    Tuesday, June 11, 2019 4:04 PM

All replies

  • Hi DeveloperProgrammer,

    Welcome to MSDN forum.

    As the error, the error U1077 often means that the exe could not run in the correct environment, it may cause the include file could not be found directly. So please change the running environment as "x86", then re-build your application.

    Any feedback will be expected.

    Best Regards,

    Dylan


     


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, June 12, 2019 8:16 AM
  • I am not sure but do not feel the issue is with environment:

    $ "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86
    **********************************************************************
    ** Visual Studio 2017 Developer Command Prompt v15.8.7
    ** Copyright (c) 2017 Microsoft Corporation
    **********************************************************************
    [vcvarsall.bat] Environment initialized for: 'x86'
    
    MINGW64 /c/tools/netsnmp/net-snmp-5.8/c_api
    $ nmake -f makefile.txt
    
    Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            cl.exe /I.. /I..\..\include /D WIN32 /D _BIND_TO_CURRENT_VCLIBS_VERSION /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\ /FdC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\snmpdemo.pdb /FoC:\tools\netsnmp\net-snmp-5.8\c_api\.\release\ /I C:\tools\netsnmp\net-snmp-5.8\include /I C:\OpenSSL-Win64\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2 snmpdemo.c
    snmpdemo.c
    C:\tools\netsnmp\net-snmp-5.8\include\net-snmp/net-snmp-includes.h(14): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64\cl.exe"' : return code '0x2'
    Stop.

    I suspect issue with my makefile as I have created by looking at other makefile - however the error states that 'stdio.h' header file is missing - probably some include path needs to be added but what path?

    Following files are created but I do not see snmpdemo.exe:

    MINGW64 /c/tools/netsnmp/net-snmp-5.8/c_api
    $ ls -lR
    .:
    total 56
    -rw-r--r-- 1 developer 1049089  1247 Jun 11 21:35 makefile.txt
    drwxr-xr-x 1 developer 1049089     0 Jun 12 18:52 release/
    -rw-r--r-- 1 developer 1049089  1557 Jun 11 21:25 snmpdemo.c
    -rw-r--r-- 1 developer 1049089 11264 Jun 11 21:08 snmpdemo.idb
    -rw-r--r-- 1 developer 1049089 36864 Jun 11 21:08 snmpdemo.pdb
    
    ./release:
    total 48
    -rw-r--r-- 1 developer 1049089 11264 Jun 12 18:52 snmpdemo.idb
    -rw-r--r-- 1 developer U333641 1049089 36864 Jun 12 18:52 snmpdemo.pdb
    
    
    
    
    



    Wednesday, June 12, 2019 1:25 PM
  • When you run vcvarsall.bat in the Bash shell, cmd.exe is started to run the batch file. The batch file then defines environment variables in the cmd.exe process, which exits soon afterwards and the environment variables never propagate to your Bash shell process. You need to start cmd.exe yourself, run vcvarsall.bat from there, and then also run the compiler from there. Or figure out a way to copy the environment variables to the Bash shell process.

    Wednesday, June 12, 2019 5:16 PM
  • Thanks - it did solved issue of stdio.h inclusion path - but now the command ends gracefully but still I do not see the executable:

    Makefile.txt

    PROGNAME=snmpdemo
    LINKTYPE=static
    Output_Directory=.\release
    CFLAGS=/D WIN32 /D _BIND_TO_CURRENT_VCLIBS_VERSION /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\netsnmpSSL\net-snmp-5.8\c_api\$(Output_Directory)\ /FdC:\netsnmpSSL\net-snmp-5.8\c_api\$(Output_Directory)\$(PROGNAME).pdb /FoC:\netsnmpSSL\net-snmp-5.8\c_api\$(Output_Directory)\ /I C:\netsnmpSSL\net-snmp-5.8\include /I C:\OpenSSL\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2 
    LDFLAGS==/libpath:C:\OpenSSL\lib\VC
    
    # Set to 1 to allow the building using the DLL version of SNMPLIB.
    ALLOW_DLL=1
    
    CPP=cl.exe
    CPP_PROJ=/I.. /I..\..\include $(CFLAGS)
    snmpdemo.obj::
       $(CPP) $(CPP_PROJ) $(PROGNAME).c
    
    RSC=rc.exe
    LINK32=link.exe
    LINK32_FLAGS=netsnmp.lib advapi32.lib ws2_32.lib kernel32.lib user32.lib /nologo /subsystem:console /pdb:"C:\tools\netsnmp\net-snmp-5.8\c_api\$(PROGNAME).pdb" /out:"C:\tools\netsnmp\net-snmp-5.8\c_api\$(PROGNAME).exe" /libpath:"../lib/$(INTDIR)" $(LDFLAGS)
    LINK32_OBJS= "$(PROGNAME).obj"

    And

    Compilation:

    c:\netsnmpSSL\net-snmp-5.8\c_api>"C:\Program Files (x86)\Microsoft Visual Studio
    \2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
    
    
    c:\netsnmpSSL\net-snmp-5.8\c_api>nmake -f makefile.txt
    
    Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            cl.exe /I.. /I..\..\include /D WIN32 /D _BIND_TO_CURRENT_VCLIBS_VERSION
    /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _
    WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\netsnmpSSL\net-snmp-5.8\c_api\.\r
    elease\ /FdC:\netsnmpSSL\net-snmp-5.8\c_api\.\release\snmpdemo.pdb /FoC:\netsnmp
    SSL\net-snmp-5.8\c_api\.\release\ /I C:\netsnmpSSL\net-snmp-5.8\include /I C:\Op
    enSSL\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2 snmpdemo.c
    snmpdemo.c
    
    c:\netsnmpSSL\net-snmp-5.8\c_api>

    And files created are:

    c:\netsnmpSSL\net-snmp-5.8\c_api>dir /r
     Volume in drive C is OS
     Volume Serial Number is 5822-2BB6
    
     Directory of c:\netsnmpSSL\net-snmp-5.8\c_api
    
    06/13/2019  11:00 AM    <DIR>          .
    06/13/2019  11:00 AM    <DIR>          ..
    06/13/2019  11:03 AM             1,220 makefile.txt
    06/13/2019  11:12 AM    <DIR>          release
    06/13/2019  07:17 AM             1,557 snmpdemo.c
                   2 File(s)          2,777 bytes
                   3 Dir(s)   6,876,016,640 bytes free
    
    c:\netsnmpSSL\net-snmp-5.8\c_api>cd release
    
    c:\netsnmpSSL\net-snmp-5.8\c_api\release>dir
     Volume in drive C is OS
     Volume Serial Number is 5822-2BB6
    
     Directory of c:\netsnmpSSL\net-snmp-5.8\c_api\release
    
    06/13/2019  11:12 AM    <DIR>          .
    06/13/2019  11:12 AM    <DIR>          ..
    06/13/2019  11:22 AM           355,328 snmpdemo.idb
    06/13/2019  11:22 AM            22,720 snmpdemo.obj
    06/13/2019  11:22 AM           118,784 snmpdemo.pdb
    06/13/2019  11:22 AM         3,467,197 snmpdemo.sbr
                   4 File(s)      3,964,029 bytes
                   2 Dir(s)   6,876,016,640 bytes free
    
    c:\netsnmpSSL\net-snmp-5.8\c_api\release>

    Still why no snmpdemo.exe is not created?

    Thursday, June 13, 2019 6:00 AM
  • Hi friend,

    Thank you for feedback.

    I have escalated this issue. And if there is any update information, it will be posted here. I will appreciate that your patience with it.

    Thank you for understanding.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, June 13, 2019 9:12 AM
  • I am not sure but I modified the Makefile script like below:

    PROGNAME=snmpdemo
    LINKTYPE=static
    CFLAGS=/D WIN64 /D _BIND_TO_CURRENT_VCLIBS_VERSION /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\netsnmpSSL\net-snmp-5.8\c_api\ /FdC:\netsnmpSSL\net-snmp-5.8\c_api\$(PROGNAME).pdb /FoC:\netsnmpSSL\net-snmp-5.8\c_api\ /I C:\netsnmpSSL\net-snmp-5.8\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD  /D NDEBUG /O2
    
    
    # Set to 1 to allow the building using the DLL version of SNMPLIB.
    ALLOW_DLL=1
    
    CPP=cl.exe
    CPP_PROJ=/I.. /I..\..\include $(CFLAGS)
    
    
    RSC=rc.exe
    LINK32=link.exe
    LINK32_FLAGS=C:\netsnmpSSL\net-snmp-5.8\win32\lib\debug\netsnmp.lib advapi32.lib ws2_32.lib kernel32.lib user32.lib /nologo /subsystem:console /pdb:"C:\netsnmpSSL\net-snmp-5.8\c_api\$(PROGNAME).pdb" /out:"C:\netsnmpSSL\net-snmp-5.8\c_api\$(PROGNAME).exe" /libpath:"../lib/$(INTDIR)" $(LDFLAGS)
    LINK32_OBJS= "$(PROGNAME).obj"
    
    snmpdemo.obj::
       $(CPP) $(CPP_PROJ) $(PROGNAME).c
       $(LINK32) $(LINK32_FLAGS) $(LINK32_OBJS)

    Now I get the below error -

    c:\netsnmpSSL\net-snmp-5.8\c_api>nmake -f makefile.txt
    
    Microsoft (R) Program Maintenance Utility Version 14.15.26730.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            cl.exe /I.. /I..\..\include /D WIN64 /D _BIND_TO_CURRENT_VCLIBS_VERSION
    /D _CONSOLE /D _CRT_NONSTDC_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D _MBCS /D _
    WINSOCK_DEPRECATED_NO_WARNINGS /EHsc /FD /FRC:\netsnmpSSL\net-snmp-5.8\c_api\ /F
    dC:\netsnmpSSL\net-snmp-5.8\c_api\snmpdemo.pdb /FoC:\netsnmpSSL\net-snmp-5.8\c_a
    pi\ /I C:\netsnmpSSL\net-snmp-5.8\include /c /W3 /Zi /nologo /wd4244 /wd4267 /MD
      /D NDEBUG /O2 snmpdemo.c
    snmpdemo.c
            link.exe C:\netsnmpSSL\net-snmp-5.8\win32\lib\debug\netsnmp.lib advapi32
    .lib ws2_32.lib kernel32.lib user32.lib /nologo /subsystem:console /pdb:"C:\nets
    nmpSSL\net-snmp-5.8\c_api\snmpdemo.pdb" /out:"C:\netsnmpSSL\net-snmp-5.8\c_api\s
    nmpdemo.exe" /libpath:"../lib/"  "snmpdemo.obj"
    LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
    se /NODEFAULTLIB:library
    
    c:\netsnmpSSL\net-snmp-5.8\c_api>
    How can I resolve this linking issue?


    Thursday, June 13, 2019 10:56 AM