main.cpp:
#include "main.h"
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
Build log:
-------------- Clean: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
Cleaned "example_mic_dyn - Release"
-------------- Build: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
cl.exe /nologo /MD /Ox /W3 /DBUILD_DLL /DNDEBUG /I"..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /c main.cpp /Foobj\Release\main.obj
main.cpp
link.exe /dll /nologo /LIBPATH:"..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /out:bin\Release\example_mic_dyn.dll user32.lib obj\Release\main.obj /INCREMENTAL:NO
Creating library bin\Release\example_mic_dyn.lib and object bin\Release\example_mic_dyn.exp
Output file is bin\Release\example_mic_dyn.dll with size 8.50 KB
Running target post-build steps
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
Execution of 'mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2' in 'C:\Users\lucao\Desktop\example_mic_dyn' failed.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
There is clearly written what the problem is:
QuoteExecution of 'mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2' in 'C:\Users\lucao\Desktop\example_mic_dyn' failed.
You have to find out why this fails...
I don't know how we can help with this problem.
Probably the mt.exe is not in the PATH?
Adding C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64 to compiler additional paths:
-------------- Clean: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
Cleaned "example_mic_dyn - Release"
-------------- Build: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
cl.exe /nologo /MD /Ox /W3 /DBUILD_DLL /DNDEBUG /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /I"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /I"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /c main.cpp /Foobj\Release\main.obj
main.cpp
link.exe /dll /nologo /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /out:bin\Release\example_mic_dyn.dll user32.lib obj\Release\main.obj /INCREMENTAL:NO
Creating library bin\Release\example_mic_dyn.lib and object bin\Release\example_mic_dyn.exp
Output file is bin\Release\example_mic_dyn.dll with size 8.50 KB
Running target post-build steps
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
bin\Release\example_mic_dyn.dll.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
Process terminated with status 31 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
what if you call this
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
from a command line inside your project folder?
Also, does the file "bin\Release\example_mic_dyn.dll.manifest" exists? If not you have your answer....
Where do these paths come from? I'm using the following Postcommand to embed the manifest into an exe:
mt.exe -manifest $exe_output.manifest -outputresource:$exe_output;1
I don't know what working directory CodeBlocks sets for the Postcommands, my output directory is the one with the project file and the macros evaluate to current directory in my case.
Quotewhat if you call this
Code: [Select]
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
from a command line inside your project folder?
How am I supposed to do that? I have 3 mt.exe in Windows Kits: an arm64, x64 and a x86 version. And no, there's no "bin\Release\example_mic_dyn.dll.manifest", but that doesn't explains why the file was not generated. Also, this is the standard dll project in Code::Blocks.
QuoteWhere do these paths come from?
they are coming from your input
Quotemt.exe -manifest $exe_output.manifest -outputresource:$exe_output;1
$exe_outputis expanded to this path.
This is a advanced compiler variable so you are messing with the advanced compiler settings? (Settings->Compiler->Global compiler settings->Other settings->Advanced options)
you have probably to set it like this
mt.exe -manifest $exe_name.manifest -outputresource:$exe_output;1and put your manifest file in the root project folder with the name "example_mic_dyn.manifest"
I have no idea what a manifest file does, and how the naming convention are... I am only guessing on the things you say, and you don't give many information...
Can you not use a post build step for this? So you could use normal variable expansion: http://wiki.codeblocks.org/index.php/Variable_expansion
so in the post build steps you have something like
mt.exe -manifest $exe_output.manifest -outputresource:$exe_output;1
QuoteAnd no, there's no "bin\Release\example_mic_dyn.dll.manifest", but that doesn't explains why the file was not generated.
They are not auto generated. You have to make them by your own...
QuoteHow am I supposed to do that? I have 3 mt.exe in Windows Kits: an arm64, x64 and a x86 version.
Obviously you use the application for your target architecture...
I know where MY paths are coming from, thanks, but i dont know where HIS paths are coming from ;). I am using the macros and they expand to the proper location for me. I guessed he hardcoded the paths to wrong values, because he is already using a very strange compiler setup with relative paths to compiler internal directories as you can see from the build log (and i remember him from another thread where he displayed his strange compiler setup).
And yes, you have to use the mt.exe from the SDK that you are linking against, and no, the manifest should get created automatically, at least thats what MSDN says. However it doesnt hurt to specify /MANIFEST explicit in the linker options to enable it. And the default name for it is indeed <full name with extension>.manifest, most important use of the manifest is to enable proper UI dlls or your application looks like Windows 3.1.
@sodev: sorry, i thought your response was from lbertolotti ::) I think you know more from this, i have no idea from the visual studio compiler so i am out :)
Quote from: lbertolotti on July 30, 2017, 07:31:07 PM
Running target post-build steps
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
Execution of 'mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2' in 'C:\Users\lucao\Desktop\example_mic_dyn' failed.
I think manifest files are only "useful" if you use GUI in the DLL, perhaps you do.
For targets with GUI and MSVC compiler I use the following in the Code::Blocks post build step
mt.exe /nologo /manifest $(TARGET_OUTPUT_FILE).manifest /outputresource:$(TARGET_OUTPUT_FILE);1Essentially linking the manifest data into the executable. The effect is that the Windows GUI uses the current theme etc.
In my case with MSVC2013 I find mt.exe in C:\Program Files (x86)\Windows Kits\8.1\bin\x64 so it must be in the path
Setting /MANIFEST in linker settings solved the problem:
Code::Blocks build log:
-------------- Clean: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
Cleaned "example_mic_dyn - Release"
-------------- Build: Release in example_mic_dyn (compiler: Microsoft VC 2017)---------------
cl.exe /nologo /MD /Ox /W3 /DBUILD_DLL /DNDEBUG /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86" /I"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /I"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /I"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /I"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /c main.cpp /Foobj\Release\main.obj
main.cpp
link.exe /dll /nologo /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86" /LIBPATH:"..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\atlmfc\include" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.25017\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\arm64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64" /out:bin\Release\example_mic_dyn.dll user32.lib obj\Release\main.obj /INCREMENTAL:NO /MANIFEST
Creating library bin\Release\example_mic_dyn.lib and object bin\Release\example_mic_dyn.exp
Output file is bin\Release\example_mic_dyn.dll with size 8.50 KB
Running target post-build steps
mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
Process terminated with status 0 (0 minute(s), 5 second(s))
0 error(s), 0 warning(s) (0 minute(s), 5 second(s))
Windows cmd:
C:\Users\lucao\Desktop\example_mic_dyn>PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64
C:\Users\lucao\Desktop\example_mic_dyn>mt.exe /nologo /manifest "bin\Release\example_mic_dyn.dll.manifest" /outputresource:"bin\Release\example_mic_dyn.dll";2
https://msdn.microsoft.com/en-us/library/windows/desktop/aa375365(v=vs.85).aspx
example_mic_dyn.dll.manifest:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>