Following Error occured when trying to compile a Dynamic Link Library (DLL)
I'm using build 5010 with the MinGW library included in the official release.
Tab: Build Log:
-------------- Build: Release in SampleHook ---------------
Compiling: main.cpp
In file included from C:\Programme\CodeBlocks\Projects\SampleHook\main.cpp:2:
C:\Programme\CodeBlocks\Projects\SampleHook\detours.h:611:8: warning: extra tokens at end of #endif directive
mingw32-g++.exe: /W3: No such file or directory
mingw32-g++.exe: /DBUILD_DLL: No such file or directory
mingw32-g++.exe: /Ox: No such file or directory
mingw32-g++.exe: /DNDEBUG: No such file or directory
mingw32-g++.exe: /MD: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 1 warnings
Tab: Build messages:
C:\Programme\CodeBlocks\Projects\SampleHook\detours.h|611|warning: extra tokens at end of #endif directive|
||=== Build finished: 0 errors, 1 warnings ===|
Well actually Code::Blocks just "compiles" the dll with a warning but in real it doesn't even create the dll which should be located at:
"C:\Programme\CodeBlocks\Projects\SampleHook\bin\Release"
The mingw32-g++.exe is located under : "C:\Programme\CodeBlocks\MinGW\bin" and the paths are all set in Code::Blocks.
The source of the program I try to compile (maybe it's my fault):
#include <windows.h>
#include "detours.h"
//#pragma comment(lib, "detours.lib")
int (__stdcall *InsertDateTime)(int x);
int (__stdcall *SetTitle)(LPCWSTR lpString1);
int MyInsertDateTime(int x)
{
MessageBox(NULL, "InsertDateTime Just Got Called", "InsertDateTime", MB_OK);
return InsertDateTime(x);
}
int MySetTitle (LPCWSTR lpString1)
{
return SetTitle((LPCWSTR)L"Hooked");
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call) //Decide what to do
{
case DLL_PROCESS_ATTACH: //On dll attach
{
InsertDateTime = (int (__stdcall*)(int))DetourFunction((PBYTE)0x01006F10, (PBYTE)MyInsertDateTime);
SetTitle = (int (__stdcall *)(LPCWSTR))DetourFunction((PBYTE)0x01002A55, PBYTE(MySetTitle));
break;
}
case DLL_THREAD_ATTACH: //On thread attach
break;
case DLL_THREAD_DETACH: //On thread detach
break;
case DLL_PROCESS_DETACH: //On process detach
{
DetourRemove((PBYTE)0x1006F10, (PBYTE)InsertDateTime);
DetourRemove((PBYTE)0x01002A55, (PBYTE)MySetTitle);
break;
}
}
return 1;
}
It works when using the Microsoft Visual C++ 2008 Express Edition - Compiler though. I would be happy to see this fixed or getting help :)!
CracKPod
Oke I created a completely new project and now I get the following error:
-------------- Build: Debug in Notepad Hook ---------------
Compiling: main.cpp
In file included from C:\Programme\CodeBlocks\Projects\Notepad Hook\main.cpp:2:
C:\Programme\CodeBlocks\Projects\Notepad Hook\detours.h:15: warning: ignoring #pragma comment
In file included from C:\Programme\CodeBlocks\Projects\Notepad Hook\main.cpp:2:
C:\Programme\CodeBlocks\Projects\Notepad Hook\detours.h:611:8: warning: extra tokens at end of #endif directive
Linking dynamic library: bin\Debug\Notepad Hook.dll
C:\Programme\CodeBlocks\MinGW\bin\ld.exe: cannot find -ldetours.lib
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 2 warnings
I guess it's my fault again, isn't it?... :lol:
"cannot find -ldetours.lib" well that's logically since there isn't any -ldetours.lib but a detours.lib... So probably Code::Blocks made an error there not placing a space betwenn -l and detours.lib? (-l detours.lib);
---
so litle bigs are fixed.
Is codeblocks dieng?
So you think Code::Blocks is "dieng" since there aren't enough bugs to fix?
"cannot find -ldetours.lib" well that's logically since there isn't any -ldetours.lib but a detours.lib... So probably Code::Blocks made an error there not placing a space betwenn -l and detours.lib? (-l detours.lib);
Try to test/check/google a little bit more elsewhere before guessing CodeBlocks made an error.
Taken from ld man pages :
-l library adds the specified library to the list of libraries to be linked with. In searching
for libraries (for example, with -lfoo), each library directory is first searched for
the UNIX-style archive name (that is, libfoo.a) and then for the Windows-style
library name (that is, foo.lib) in each library directory.
Try giving only "detours" to the list of libraries to link with your project in the configuration.