Link to home
Start Free TrialLog in
Avatar of mativare
mativare

asked on

make DLL

Little help needed.
Using  C++ 40  Win NT
Failure to build DLL file
----
#include <windows.h>
#include <ole2.h>
#include <sql.h>
#include <sqlext.h>

#ifdef _WIN32
  #define CCONV _stdcall
  #define NOMANGLE
#else
  #define CCONV FAR PASCAL _export
  #define NOMANGLE EXTERN_C
  #include <stdlib.h>
  #include <compobj.h>    
  #include <dispatch.h>
  #include <variant.h>
  #include <olenls.h>  
#endif

NOMANGLE LONG CCONV PassByte ()
{
RETCODE rs;
HENV henv;
rs=SQLAllocEnv(&henv);
rs=SQLFreeEnv(henv);
return      rs;
}
-----------------------------def, file
LIBRARY vb4dll

CODE      PRELOAD MOVEABLE DISCARDABLE
DATA      PRELOAD MOVEABLE

EXPORTS
      PassByte      @1
-----------
Error message LNK1141
Failure durning bulild of export file

Please give a clue.

mativare@i-2000.com
Please make corrections to code and post , then every
beginner(like me) can see it on a net.
Matt
Avatar of msmits
msmits

Is the file a .c file or a .cpp. When .cpp you must use:

extern "C" {
...
}

or just use a .c file.
This will disable the name mangling so the linker can find the right function.

Avatar of mativare

ASKER

filenames were  vb4dll.c
and vb4dll.def
Unfortunately question remains unanswered.
Thanks  for a attempt.
Matthew
except for the SQL stuff I could generate your DLL fine. I use Borland C++ 5.02 on win95 at the moment.

Um,
you have a real strange problem.

I just compiled your dll, the .cpp and the .def file on MSVC++ 4.0 Standard on Win95 and if compiled flawlessly.  

Perhaps you set up the project wrong, and instead of just a pure dll you set up an app wizard mfc dll?  Or maybe perhaps you didn't do a full install with msvc and are missing some of the header files needed for the ole/sql?
I used "pure dll Option". It compiled too, but building(linking) went wrong
Messages LNK 4044, LNK1181,  LNK1141
Still hoping
Matthew
Are you sure you included all of the database support options when you installed MSVC 4.0?  It seems very odd that you are having this trouble, as I said, I just cut and pasted your code, and it worked flawlessly...
Along with LNK1181 error must come a name of a file linker could not find. What is it?
fatal error LNK1181: cannot open input file "Files\DevStudio\BIN\link.exe"
Good man you solved it, because my Dev Studio is located in
"Program Files."
Seems I need to do reinstallment of VC++, if you have any other hints
how to "tell" compiler where are files, let me know.
 I know there are files  like
setup .ini and...
Thanks a lot.
Matt
Matthew


ASKER CERTIFIED SOLUTION
Avatar of Seeker092397
Seeker092397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial