How to get window main handle?

My code is as follows:


#include <Mstn\MdlApi\MdlApi.h>
#include <Mstn\cmdlist.r.h>
#include <Mstn\MdlApi\msnativewindow.h>
#include <windows.h>
#include <DgnPlatform\DgnFile.h>
#include <DgnPlatform\DgnFileIO\DgnFileIOApi.h>

extern "C" DLLEXPORT void MdlMain(int argc, WCharCP argv[])
{
             HWND hWnd = NULL;
             hWnd = (HWND)mdlNativeWindow_getMainHandle(0);


            return;

}

I can't able to resolve these build errors.

Parents
  • I can't able to resolve these build errors

    What is your colourful development environment?  Are you using bmake in the SDK command shell?

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    Its Visual Studio 2017. Opened Visual Studio 2017 using devenv command in SDK command shell.

    Regards

    Rajesh

  • Plus, start bmake manually from SDK shell to ensure Visual Studio does not filter anything out.

    To stick on Visual Studio GUI too much is counterproductive often: To be able to run the whole process manually is necessary knowledge and it often provides good insight where the problem can be.

    Regards,

      Jan

  • What is bmake output when something like this is used?

    bmake -a +dCcompOpts=-showIncludes hc_microstation

    You have not answered yet why windows.h is included and why do you need the window handle, but types redefinition is often cause by wrong header files order or using wrong header files.

    To analyze how header files are included into what source files, with knowledge of the project itself, should help you to solve the problem.

    Regards,

      Jan

  • Hi Jan,

    We used windows.h for using some of windows functionality such as STL, DATATYPES and also export functionality of dependent dll. 

    Now i have moved  windows.h to top of include. Now I am unresolved external symbols error.

     

    #include <windows.h>
    #include <Mstn\MdlApi\MdlApi.h>
    #include    <Mstn\MdlApi\msinputq.h>
    #include    <Mstn\cmdlist.r.h>
    //#include    <Mstn\MdlApi\cmdclass.r.h>
    #include	<Mstn\MdlApi\msnativewindow.h>
    
    #include <DgnPlatform\DgnFile.h>
    #include <DgnPlatform\DgnFileIO\DgnFileIOApi.h>
    
    extern "C" DLLEXPORT  void MdlMain(int argc, WCharCP argv[])
    {
    	if (WString::IsNullOrEmpty(argv[0])) return;
    	if (!_wcsicmp(argv[1], L"MS_INITAPPS"))
    	{
    		HWND hWnd = NULL;
    		hWnd = mdlNativeWindow_getMainHandle(0);
    		
    		mdlSystem_enterGraphics();
    		mdlInput_sendCommand(CMD_DIALOG_OPENFILE, L"STARTUP", MSInputQueuePos::INPUTQ_HEAD, NULL, 0);
    	}
    	return;	
    }

    Build output is as follows.

    1>------ Build started: Project: hc.microstation, Configuration: Release x64 ------
    1>Bentley Systems Make Utility. Version 10.00.00.26, Mar 15 2018
    1>Tue Mar 16 18:12:00 2021
    1>
    1>
    1>
    1>
    1>[== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\rscobj\hc_microstation.rsc, (D:\Repository\microstation_main\hc.microstation\hc_microstation.r) ==]
    1>rcomp @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
    1>MicroStation Resource Compiler 03.20.02
    1>
    1>[== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.h, (D:\Repository\microstation_main\hc.microstation\hc_microstation.r) ==]
    1>rcomp @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
    1>MicroStation Resource Compiler 03.20.02
    1>   Generating header file (C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.h) ... aborted.
    1>
    1>[== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj, (D:\Repository\microstation_main\hc.microstation\hc_microstation.cpp) ==]
    1>cl -IC:\PROGRA~1\Bentley\MICROS~2\include\ -IC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\    -fp:precise -GS- -EHc -GR -wd4345 -GF -favor:blend -D_X64_ -wd4701 -wd4244 -wd4564 -wd4840 -wd4702 -c -W4 -DBENTLEY_WARNINGS_HIGHEST_LEVEL -DWIN32 -DwinNT -MD -D__EXCEPTIONS -D_VISCXX -Gy -wd4996 -Ox -Oy- -Os -D_CONVERSION_DONT_USE_THREAD_LOCALE -D_SECURE_SCL=0 -DWIN32_LEAN_AND_MEAN  -DNTDDI_WIN7SP1=0x06010100 -we4692  -nologo -WX -MP -Zi -Zo -FdC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\objects.pdb    -EHs   -fp:precise -FoC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj D:\Repository\microstation_main\hc.microstation\hc_microstation.cpp
    1>hc_microstation.cpp
    1>
    1>[== Building "C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll", (C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj) ==]
    1>link -out:"C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll"  -WX   -Ignore:4087 -Ignore:4089 -Ignore:4199 -Ignore:4281 -MANIFESTUAC:NO -Release   -debug -incremental:no -fixed:no @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstationlink.rsp
    1>Microsoft (R) Incremental Linker Version 14.16.27044.0
    1>Copyright (C) Microsoft Corporation.  All rights reserved.
    1>
    1>-dynamicbase
    1>-dll
    1>"-out:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll"
    1>"-implib:C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib"
    1>"-pdb:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.pdb"
    1>-fixed:no
    1>C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj C:\PROGRA~1\Bentley\MICROS~2\library\bentley.lib C:\PROGRA~1\Bentley\MICROS~2\library\mdlbltin.lib C:\PROGRA~1\Bentley\MICROS~2\library\BentleyGeom.lib C:\PROGRA~1\Bentley\MICROS~2\library\DgnPlatform.lib C:\PROGRA~1\Bentley\MICROS~2\library\dgnview.lib C:\PROGRA~1\Bentley\MICROS~2\library\RmgrTools.lib C:\PROGRA~1\Bentley\MICROS~2\library\BentleyAllocator.lib D:\Repository\microstation_main\bin\x64\Release\hc.shield.lib D:\Repository\microstation_main\bin\x64\Release\hc.ui.lib gdi32.lib user32.lib kernel32.lib "C:\PROGRA~2\MICROS~3\2017\PROFES~1\VC\Tools\MSVC\14.16.27023\\lib\x64\msvcrt.lib"
    1>C:\PROGRA~1\Bentley\MICROS~2\library\mdlbltin.lib
    1>   Creating library C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib and object C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.exp
    1>hc_microstation.obj : error LNK2019: unresolved external symbol mdlNativeWindow_getMainHandle referenced in function MdlMain
    1>C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll : fatal error LNK1120: 1 unresolved externals
    1>command table not found in resource file - BMAKE: call trace
    1>    line:  414, C:\PROGRA~1\Bentley\MICROS~2\mki\dlmlink.mki
    1>    line:   83, D:\Repository\microstation_main\hc.microstation\hc_microstation.mke
    1>Tue Mar 16 18:12:03 2021, elapsed time: 0:03
    1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "bmake +a  hc_microstation.mke" exited with code 1.
    1>Done building project "hc.microstation.vcxproj" -- FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    

    "bmake -a +dCcompOpts=-showIncludes hc_microstation" - 

      Bentley Systems Make Utility. Version 10.00.00.26, Mar 15 2018
      Tue Mar 16 18:15:40 2021
      
      
      
      
      [== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\rscobj\hc_microstation.rsc, (D:\Repository\microstation_main\hc.microstation\hc_microstation.r) ==]
      rcomp @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
      MicroStation Resource Compiler 03.20.02
      
      [== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.h, (D:\Repository\microstation_main\hc.microstation\hc_microstation.r) ==]
      rcomp @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
      MicroStation Resource Compiler 03.20.02
         Generating header file (C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.h) ... aborted.
      
      [== Building C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj, (D:\Repository\microstation_main\hc.microstation\hc_microstation.cpp) ==]
      cl -IC:\PROGRA~1\Bentley\MICROS~2\include\ -IC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\    -fp:precise -GS- -EHc -GR -wd4345 -GF -favor:blend -D_X64_ -wd4701 -wd4244 -wd4564 -wd4840 -wd4702 -c -W4 -DBENTLEY_WARNINGS_HIGHEST_LEVEL -DWIN32 -DwinNT -MD -D__EXCEPTIONS -D_VISCXX -Gy -wd4996 -Ox -Oy- -Os -D_CONVERSION_DONT_USE_THREAD_LOCALE -D_SECURE_SCL=0 -DWIN32_LEAN_AND_MEAN  -DNTDDI_WIN7SP1=0x06010100 -we4692  -nologo -WX -MP -Zi -Zo -FdC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\objects.pdb    -EHs   -fp:precise -FoC:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj D:\Repository\microstation_main\hc.microstation\hc_microstation.cpp 
      hc_microstation.cpp
      
      [== Building "C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll", (C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj) ==]
      link -out:"C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll"  -WX   -Ignore:4087 -Ignore:4089 -Ignore:4199 -Ignore:4281 -MANIFESTUAC:NO -Release   -debug -incremental:no -fixed:no @C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstationlink.rsp
      Microsoft (R) Incremental Linker Version 14.16.27044.0
      Copyright (C) Microsoft Corporation.  All rights reserved.
      
      -dynamicbase 
      -dll 
      "-out:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll" 
      "-implib:C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib" 
      "-pdb:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.pdb" 
      -fixed:no 
      C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.obj C:\PROGRA~1\Bentley\MICROS~2\library\bentley.lib C:\PROGRA~1\Bentley\MICROS~2\library\mdlbltin.lib C:\PROGRA~1\Bentley\MICROS~2\library\BentleyGeom.lib C:\PROGRA~1\Bentley\MICROS~2\library\DgnPlatform.lib C:\PROGRA~1\Bentley\MICROS~2\library\dgnview.lib C:\PROGRA~1\Bentley\MICROS~2\library\RmgrTools.lib C:\PROGRA~1\Bentley\MICROS~2\library\BentleyAllocator.lib D:\Repository\microstation_main\bin\x64\Release\hc.shield.lib D:\Repository\microstation_main\bin\x64\Release\hc.ui.lib gdi32.lib user32.lib kernel32.lib "C:\PROGRA~2\MICROS~3\2017\PROFES~1\VC\Tools\MSVC\14.16.27023\\lib\x64\msvcrt.lib" 
      C:\PROGRA~1\Bentley\MICROS~2\library\mdlbltin.lib 
         Creating library C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib and object C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.exp
    hc_microstation.obj : error LNK2019: unresolved external symbol mdlNativeWindow_getMainHandle referenced in function MdlMain
    C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll : fatal error LNK1120: 1 unresolved externals
      command table not found in resource file - BMAKE: call trace
          line:  414, C:\PROGRA~1\Bentley\MICROS~2\mki\dlmlink.mki
          line:   83, D:\Repository\microstation_main\hc.microstation\hc_microstation.mke
      Tue Mar 16 18:15:42 2021, elapsed time: 0:02
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "bmake +a  hc_microstation.mke" exited with code 1.
    

    Regards

    Rajesh

  • Now i have moved  windows.h to top of include.

    Sorry, but it's not the real solution. It looks like "let's try to change something and let's hope it will work".

    Likely the problem was not solved, but just hidden or postponed, and will return back later.

    When there is conflict with types declarations, in parallel to how and what headers are used, it's important to use namespaces properly. I do not see anything like this in your code.

    Now I am unresolved external symbols error.

    And? Did you solve it? Did your learn what this error means? It's standard (and often received) C++ linker information.

    What MicroStation libraries do you link?

    Plus, when you will search this forum, this error was discussed many times already.

    "bmake -a +dCcompOpts=-showIncludes hc_microstation"

    It's weird, because I would assume that complete headers pre-processing list will be displayed. But maybe your makefile swallows the passed argument, because evidently it's not passed to cl.exe compiler.

    Regards,

      Jan

  • Hi ,

    1. Bmake Compile errors.  Do you have nativewindow.lib in your LINKER_LIBRARIES list in your project mke file?
    2. Visual Studio Compiler Warning (screen capt hilight).
      1. The MicroStation CONNECT SDK developer shell (currently) required Microsoft 8DOT3NAMES to be enabled.  This long standing requirement unfortunately is in direct conflict with Microsoft's IntelliSense current capabilities and is known to cause issues; like your warning and IntelliSense being able to perform: Peek/Go To Definitions/Declarations.  Since it is not likely Microsoft will add support for a legacy requirement like 8DOT3NAMES to IntelliSense, I am working towards:
        1. Updating the developer shell to provide IntelliSense unmangled (full path) names (shooting for next release - U16)
        2. Verify all required tools in our build chain work similarly
        3. Update all SDK Examples to build w/o 8DOT3NAME requirements, and lastly...
        4. Create a wiki on: How to Update Bentley Make Files and Remove 8DOT3NAME Requirements.
      2. Although there is another coding hack/work-around, it is probably best to simply choose to dismiss the IntelliSense compiler warning by:
        1. Go to your Visual Studio Project's - Error List
        2. Change - From: "Build + IntelliSense", To: "Build"

    HTH,
    Bob



  • C++ Standard Library

    We used windows.h for using some of windows functionality such as STL

     The Standard Template Library (STL) has nothing to do with Windows.  These days it's part of your C++ compiler installation.  This article may throw some light.

     
    Regards, Jon Summers
    LA Solutions

  • And? Did you solve it? Did your learn what this error means? It's standard (and often received) C++ linker information.

    What MicroStation libraries do you link?

    Hi Jan,

    No, I am still facing this issue. 

    #---------------------------------------------------------------------------------------+
    #
    #    $Source: hc_microstation.mke $
    # 
    #    $Copyright: (c) 2017 Bentley Systems, Incorporated. All rights reserved. $
    #
    #---------------------------------------------------------------------------------------+
    PolicyFile = MicroStationPolicy.mki
    
    appName     =  hc_microstation
    sAppName    =  hc_microstation
    
    MDLMKI = $(MSMDE)mki/
    mdlLibs = $(MSMDE)library/
    hc_out = D:/Repository/microstation_main/bin/x64/Release/
    
    dirToSearch = $(MDLMKI)
    
    genSrc = $(o)
    
    %include $(MDLMKI)mdl.mki 
    
    #--------------------------------------------------------------------------------------
    #    Create needed output directories in case they don't exist
    #--------------------------------------------------------------------------------------
    always:
        !~@mkdir $(o)
        !~@mkdir $(rscObjects)
        !~@mkdir $(reqdObjs)
    
    dirToSearch = $(o)
    %include cincapnd.mki
    
    #--------------------------------------------------------------------------------------
    #    Define macros specific to this example
    #--------------------------------------------------------------------------------------
    privateInc      = $(baseDir)
    langSpec        = $(baseDir)transkit/
    
    libRscs = \
        $(rscObjects)$(sAppName).rsc
    
    #--------------------------------------------------------------------------------------
    #    Create object files
    #--------------------------------------------------------------------------------------
    $(rscObjects)$(sAppName).rsc     : $(baseDir)$(sAppName).r
    
    $(o)$(sAppName).h                : $(baseDir)$(sAppName).r
    
    #--------------------------------------------------------------------------------------
    #    Set up to use dlmcomp.mki and dlmlink.mki
    #--------------------------------------------------------------------------------------
    
    DLM_NAME                = $(appName)
    DLM_DEST                = $(mdlapps)
    DLM_OBJECT_FILES        = $(o)$(appName)$(oext)
    DLM_OBJECT_DEST         = $(o)
    DLM_LIBDEF_SRC          = $(_MakeFilePath)
    DLM_SPECIAL_LINKOPT     = -fixed:no     # Notify linker this library does not require a fixed base address to load
    DLM_NO_DLS              = 1             # USE DLLEXPORT IN .CPP
    DLM_NO_DEF              = 1
    DLM_NOENTRY             = 1
    DLM_NO_MANIFEST         = 1             # If not set linker embeds your current (developer) patched MSVCRT version manifest in output dll.  This is not desirable and produces side-by-side CLIENT ERROR: 14001)
    DLM_NO_SIGN             = 1             # If not set and no certificate found, ERROR: 'singleton' is not recognized as an internal or external command
    DLM_NO_INITIALIZE_FUNCTION  = 1
    
    LINKER_LIBRARIES + $(mdlLibs)bentley.lib
    LINKER_LIBRARIES + $(mdlLibs)mdlbltin.lib
    LINKER_LIBRARIES + $(mdlLibs)BentleyGeom.lib
    LINKER_LIBRARIES + $(mdlLibs)DgnPlatform.lib
    LINKER_LIBRARIES + $(mdlLibs)dgnview.lib
    LINKER_LIBRARIES + $(mdlLibs)RmgrTools.lib
    LINKER_LIBRARIES + $(mdlLibs)BentleyAllocator.lib
    LINKER_LIBRARIES + $(hc_out)hc.shield.lib
    LINKER_LIBRARIES + $(hc_out)hc.ui.lib
    
    
    #--------------------------------------------------------------------------------------
    #    Compile the source files for the DLM
    #--------------------------------------------------------------------------------------
    $(o)$(appName)$(oext)       : $(baseDir)$(appName).cpp
    
    %include $(MDLMKI)dlmlink.mki
    
    #--------------------------------------------------------------------------------------
    #    Merge the dialog resources & MDL program file using rlib
    #--------------------------------------------------------------------------------------
    $(reqdObjs)$(appName).mi        : $(libRscs)
        $(msg)
        > $(o)make.opt
        -o$@
        $(libRscs)
        <
        $(RLibCmd) @$(o)make.opt
        ~time
    
    #--------------------------------------------------------------------------------------
    #    complete construction of the .ma
    #--------------------------------------------------------------------------------------
    libRscs = \
        $(reqdObjs)$(appName).mi
    
    $(mdlapps)$(appName).ma : $(libRscs)
            $(msg)
            > $(rscObjects)make.opt
            -o$@
            $(libRscs)
            <
            $(RLibCmd) @$(rscObjects)make.opt
            ~time

    I have gone through many forums but still i am stuck.

    Is there anything library need to include??

    Regards,

    Rajesh

  • Hi Robert,

    Bmake Compile errors.  Do you have nativewindow.lib in your LINKER_LIBRARIES list in your project mke file?

    Yes i have included our native window lib in mke file.


    Although there is another coding hack/work-around, it is probably best to simply choose to dismiss the IntelliSense compiler warning by:
    1. Go to your Visual Studio Project's - Error List
    2. Change - From: "Build + IntelliSense", To: "Build"

    I tried by changing Error list to Build only. But still i am facing unresolved  external symbol error.

    Regards

    Rajesh

  • Hi Rajesh,

    No, I am still facing this issue. 

    it's because you do not follow my and Bob's advises.

    • Me (general advice): What MicroStation libraries do you link?
    • Bob (specific advice): Bmake Compile errors.  Do you have nativewindow.lib in your LINKER_LIBRARIES list in your project mke file?
    Is there anything library need to include??

    It's C++ rule that for every function or class used, you have to ensure proper library will be linked. So when you use mdlNativeWindow_getMainHandle(), you have to link the proper library. And Bob already told you it's nativewindow.lib, but I do not see this library in your makefile.

    You do not share output from bmake process (not what Visual Studio shows you, but what bmake reports when started manually). Maybe you even do not try to understand what compiler and linker tell you? I can guess only, but I assume the linker complains in this way (output for another project and another missing lib):

    ElementsExampleQueryTool.obj : error LNK2001: unresolved external symbol 
    "protected: virtual void __cdecl Bentley::DgnPlatform::DgnElementSetTool::_ModifyAgendaEntries(void)"
    (?_ModifyAgendaEntries@DgnElementSetTool@DgnPlatform@Bentley@@MEAAXXZ)

    which tells exactly error id (so can be searched in this forum and on Internet) and also what class or method cannot be linked (so documentation can be consulted, or when the information is not found, tools like dllexp or dumpbin can be used to find the right library).

    but still i am stuck.

    I think the main problem that is that without proper C++ development skills (and C++ is known as not only complicated language, but also language with very complex requirement for build process) you try to start with MicroStation app development (which adds extra levels of complexity on top of C++), where to know all details how C++ works is mandatory.

    It's like to learn how to drive car after injury and surgery, without finished convalescence and physiotherapy, trying to learn traffic rules and legal context during driving, not before. Ignoring the process "one step after another" never leads do good and efficient results.

    My code is as follows:

    Now I have noticed ... did you think about your code?

    I have no idea what will happen, I do not think you will receive any valid handle before you switch MicroStation to graphics mode. Is there any "main windows" when MicroStation is not in graphics mode?

    Regards,

      Jan

  • the hack around of option b just gets rid of warning messages but won't make the project compile. The project still fails to compile.

Reply Children
  • The project still fails to compile

    Incorrect!  His project compiles OK.

    Building a C++ project takes several steps...

    1. Compile MicroStation resources (command tables, dialogs, message lists etc)
    2. Compile Windows resources (message lists, version info etc)
    3. C++ pre-processor
    4. Compile C++ code
    5. Link

    Examine his build log to see this...

         Creating library C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib and object C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.exp
    hc_microstation.obj : error LNK2019: unresolved external symbol mdlNativeWindow_getMainHandle referenced in function MdlMain
    C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll : fatal error LNK1120: 1 unresolved externals
    

    The log is telling you that function mdlNativeWindow_getMainHandle() is used, but the linker can't find its implementation.  The implementation is in a library (*.lib) file, but that's not specified in his bmake file.

     
    Regards, Jon Summers
    LA Solutions

  • The project still fails to compile.

    It is not clear what you mean by "the project", because the discussion is nearly year old.

    But if you mean the discussed project, discussed by Rajesh, I agree with Jon: The compilation was ok, because the error message was not reported by compiler, but by linker.

    Do you understand the whole application build process (well described by Jon)?

    Unfortunately, this old discussion stopped in a middle, and no requested information was shared, so I guess no final conclusion was done at this time.

    "Unable to find/link library" and "Unable to find external symbol" are one from the most often reported C/C++ code build errors in my opinion, when to know and analyze complete environment is usually required.

    With regards,

      Jan