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.
Rajesh Varatharajan said: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,
in addition to Jon's question, why windows.h is included?
Did you analyze build log with a properly set verbosity, to see exactly what is included when?
I also do not understand:
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
One extra note: I asked you several times already to follow the forum best practices. When you want to share code snippets, use Insert > Insert code tool and set a used language, so the code is properly displayed and colorized.
Hi Jon,
Its Visual Studio 2017. Opened Visual Studio 2017 using devenv command in SDK command shell.
Regards
Rajesh
Rajesh Varatharajan said:Opened Visual Studio 2017 using devenv command in SDK command shell.
It's not what Jon asked about.
It's crucial to know whether you use bmake with mke file to build your application. It can be started manually from SDK shell or Visual Studio can be configured to call bmake instead of MSBuild.
If you compile the code without bmake, but using Visual Studio building process, it's your responsibility, because bmake is the only standard tool how to compile code.
It does not mean Visual Studio cannot be used to build the application, but to configure everything how it should be to produce the same code as bmakes does, requires very good knowledge of the compilation process, VS project configuration and all compiler and linker switches.
With regards,
Jan Ĺ legr said:It's crucial to know whether you use bmake with mke file to build your application. It can be started manually from SDK shell or Visual Studio can be configured to call bmake instead of MSBuild.
I have used bmake in visual studio to build my application.
Rajesh Varatharajan said:I have used bmake in visual studio to build my application.
In such case my previous advice is valid I guess: The error message is clear and using its identifier it's possible to find details about the problem (but "redefinition" is obvious I think).
Analyze detail compilation log (when necessary, switch compiler to produce as detail as possible output). Check what headers are included and types are defined twice.
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.
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.
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.