Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Issue with "Plugin.vcxproj"

Dec
39
0
I downloaded the latest SDK (from https://jpsoft.com/downloads/sdk/sdk.zip)
trying to use the built x64\Release\Plugin.dll for anything. It does not work since
all public functions are exported with C++names!

Here is the output from dumpbin -exports x64\Release\Plugin.dll:

1 0 00001060 ?GetPluginInfo@@YAPEAUPLUGININFO@@XZ
2 1 000010D0 ?InitializePlugin@@YAHXZ
3 2 000010D0 ?ShutdownPlugin@@YAHH@Z
4 3 0000112C ?UNKNOWN_CMD@@YAHPEA_W@Z
5 4 000010F0 ?_hello@@YAHPEA_W@Z
6 5 000010D4 ?f_reverse@@YAHPEA_W@Z
7 6 00001144 ?key@@YAHPEAUKEYINFO@@@Z
8 7 00001114 ?remark@@YAHPEA_W@Z

The provided Plugin.def is not used by Plugin.vcxproj as far I can see.

So I created a simple GNU-makefile (targeting cl or clang-cl) instead. Attached.

But IMHO using both a .def-file and __declspec(dllexport) is like wearing both a belt
and braces.
 

Attachments

Is the DEF file named here, in the project's properties?

1734272987040.webp


I only use __declspec(dllexport) for a KEYHANDLER (if I have one). For "normal" plugins I use the likes of this. This in is 4UTILS.H, included by everything else.

Code:
typedef INT (WINAPI _PLUGIN)(LPWSTR);

__declspec(dllexport) INT WINAPI KEYHANDLER(LPKEYINFO lpKeyInfo);

_PLUGIN    f_AVG        ;
_PLUGIN f_BERNOULLI    ;
_PLUGIN f_BINOMIAL    ;

And in the function's definition ... (for example)

Code:
INT f_BERNOULLI(LPWSTR psz) // return 1 with probability p, 0 with probability (1-p)
{
   ...
}

If the compiler complains about type conversions, use WCHAR* instead of LPWSTR.
 
Is the DEF file named here, in the project's properties?

Yes. Although I hate Visual-Studio (and do not use it), it's named in Plugin.vcxproj as:
<ModuleDefinitionFile>plugin.def</ModuleDefinitionFile>

But it's not used during the msbuild.exe -nologo -p:Configuration=Release -p:Platform="x64" Plugin.vcxproj step:
Link:
f:\gv\VC_2022\VC\Tools\MSVC\14.43.34618\bin\Hostx64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"x64\Release\PlugIn.dll" /VERSION:"33"
/INCREMENTAL:NO /NOLOGO TakeCmd.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 /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"x64\Release\Plugin.pdb" /SUBSYSTEM:WINDOWS /OPT:REF
/OPT:ICF /LTCG:incremental /LTCGOUT:"x64\Release\Plugin.iobj" /TLBID:1 /DYNAMICBASE /IMPLIB:"x64\Release\Plugin.lib" /MACHINE:X64 /DLL
x64\Release\PlugIn.obj
Creating library x64\Release\Plugin.lib and object x64\Release\Plugin.exp
Generating code
Previous IPDB not found, fall back to full compilation.
All 12 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
Finished generating code
Plugin.vcxproj -> F:\gv\4NT\tcc\SDK\x64\Release\Plugin.dll


Why not?

Besides, the SDK seems to ass-u-me everything is compiled as C++. No #ifdef __cplusplus in
TakeCmd.h. It should perhaps cause an #error ... if cl -TC was used.
 
I always use the IDE. But I used your msbuild command line with my project name and I got undecorated exports.

Code:
msbuild.exe -nologo -p:Configuration=Release -p:Platform="x64" 4utils.vcxproj

Code:
c:\users\vefatica\desktop\4utils\x64\release> dumpbin /exports 4utils64.dll
Microsoft (R) COFF/PE Dumper Version 14.41.34123.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file 4utils64.dll

File Type: DLL

  Section contains the following exports for 4utils64.dll

    00000000 characteristics
    FFFFFFFF time date stamp
        0.00 version
           1 ordinal base
         126 number of functions
         126 number of names

    ordinal hint RVA      name

          1    0 00006278 CD
          2    1 00002558 CLOCK
          3    2 00002768 CMDTIMER
 
I looked at the plugin.vcproj file for the most recent SDK I have. In the x64/release linker section it had this.

Code:
      <ModuleDefinitionFile>
      </ModuleDefinitionFile>

It doesn't seem to specify a DEF file. It is specified for the debug build.
 
I downloaded the latest SDK (from https://jpsoft.com/downloads/sdk/sdk.zip)
trying to use the built x64\Release\Plugin.dll for anything. It does not work since
all public functions are exported with C++names!

Not surprising since Take Command & Plugin.dll are written in C++.

The .DEF file isn't used anymore because everything is exported with DLLExports.
 
The .DEF file isn't used anymore because everything is exported with DLLExports.
But the names are decorated and TCC can't load the DLL.

Code:
TCC: (Sys) The specified procedure could not be found.
 "InitializePlugin"
 
No need for TakeCmd.def when I use PureBasic.

PureBasic Code example from a plugin source...
Code:
ImportC "takecmd.lib"
  Command_(*lpszString, nReserved) As "Command"
  Evaluate_(*lpszString) As "Evaluate"
  SetEVariable_(*lpszString) As "SetEVariable"
EndImport

This compiles and works with the PellesC backend compiler,
and the FASM backend compiler.

Joe
 
Back
Top