Archive: ExDll example doesn't produce DLL file?


ExDll example doesn't produce DLL file?
Hi,

Since I got a lot of comments about the (big) size of my NSIS plugins created in Delphi, I'm trying to convert them to Visual C++. But when I build the ExDLL C sample DLL it doesn't generate a DLL file. Only an OBJ- and a LIB-file. Does anybody know what I'm doing wrong?

I use Visual C++ .NET 2003 and I loaded the supplied .dsw file. It asks if I want to convert it to the new format. I do this and select "Build ExDLL". Then I get a 'release' directory, but it doesn't include a DLL file, only some other files.


have you checked the output path in the project?

the examples in the distro normally will output the plugin into the '\plugins' folder so you will see the obj and lib files in the 'release' folder or whatever it has been called where the source is but the dll will be created elsewhere.

best to check the plugins folder for the file times is what i can suggest

hope that helps

-daz


Originally posted by DrO
have you checked the output path in the project?

best to check the plugins folder for the file times is what i can suggest
You're right! I feel pretty n00b :)

I didn't check the linker output path, which is set to "../../Plugins/exdll.dll". The DLL was located in the plugins folder.

Thanx again!

I've got a new problem. When I add my own code to the exdll example I get the following errors:

exdll.obj : error LNK2019: unresolved external symbol _rand referenced in function _GetRandom
exdll.obj : error LNK2019: unresolved external symbol _srand referenced in function _GetRandom
exdll.obj : error LNK2019: unresolved external symbol _time referenced in function _GetRandom
exdll.obj : error LNK2001: unresolved external symbol __fltused
exdll.obj : error LNK2019: unresolved external symbol __ftol2 referenced in function _GetRandom
../../Plugins/exdll.dll : fatal error LNK1120: 5 unresolved externals

I've already looked at MSDN and Google, but couldn't find the solution. It seems there's something wrong with the linked libraries. To make the srand(), rand() and time() functions work I included stdlib.h and time.h, but that didn't solve the problem.

When I create a simple console application my code works perfectly, so the problem must be easily to solve...

Does anybody know what might be the problem? Here's the full source code of my exdll.c file:

#include <windows.h>
#include <stdlib.h>
#include "exdll.h"
#include "time.h"

HINSTANCE g_hInstance;

HWND g_hwndParent;

int myatoi(char *s);

void __declspec(dllexport) GetRandom(HWND hwndParent, int string_size,
char *variables, stack_t **stacktop)
{
g_hwndParent=hwndParent;

EXDLL_INIT();

// do your stuff here
{
int range;
int val;
char buf[1024];

// Pop range from stack
popstring(buf);
range = myatoi(buf);

// Seed the random number generator with the current time
srand( (unsigned)time( NULL ) );

// The following code was taken from this website:
// http://www.delorie.com/djgpp/v2faq/faq22_23.html
// int random_number =
// low + (double)rand () * (high - low + 1) / RAND_MAX;

val = ((double) rand() * range / RAND_MAX);

wsprintf(buf,"%d",val);

pushstring(buf);
}
}



BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
g_hInstance=hInst;
return TRUE;
}

// This function was copied from AdvSplash plugin
int myatoi(char *s)
{
unsigned int v=0;
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
{
s+=2;
for (;;)
{
int c=*s++;
if (c >= '0' && c <= '9') c-='0';
else if (c >= 'a' && c <= 'f') c-='a'-10;
else if (c >= 'A' && c <= 'F') c-='A'-10;
else break;
v<<=4;
v+=c;
}
}
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
{
s++;
for (;;)
{
int c=*s++;
if (c >= '0' && c <= '7') c-='0';
else break;
v<<=3;
v+=c;
}
}
else
{
int sign=0;
if (*s == '-') { s++; sign++; }
for (;;)
{
int c=*s++ - '0';
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) return -(int) v;
}
return (int)v;
}

It's because the ExDLL project doesn't include default libraries. Add LIBC.LIB to the list of library modules.

Please attach large files next time.


Originally posted by kichik
It's because the ExDLL project doesn't include default libraries. Add LIBC.LIB to the list of library modules.
Thanx, I will try that when I get home.
Please attach large files next time.
I tried that at first, but the forum didn't accept .c files. I had to press "back" in my browser and I also lost all the text that I had typed. So I added it in-line with the text.

Rename it to .txt then.


Originally posted by kichik
Rename it to .txt then.
OK OK... I will do that next time :p