www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Problem compiling DLL

reply =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
Hi, I have a problem compiling a DLL. The C files all compile without  
any problems to OBJ files. I than use the following line to create my  
DLL (I have obmitted mist OBJ files to keep the posting short):

--- BEGIN

link alter.obj analyze.obj ... where.obj  
kernel32.lib,myvaluedriver.dll,,,myvaluedriver.def
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

OPTLINK : Error 180: No Match Found for Export/ENTRY -  :  
activate_cerod
OPTLINK : Warning 148: USE16/USE32 Mismatch : DGROUP
OPTLINK : Warning 174: 32-bit Segments Inappropriate for 16-bit  
Segmented output
OPTLINK : Error 81: Cannot EXPORT : activate_cerod
alter.obj(alter)
  Error 35: Cannot Reach TARGET from FRAME at Relative 0000CH  from
  Segment _TEXT
  FRAME  = Frame of Group FLAT 0000
  TARGET = External Symbol _value_text 39D91H
  FIXUPP Type = 32-bit Conditional JMP
--- errorlevel 3

---END

The function ACTIVATE_CEROD has been declared as:
	extern void activate_cerod(const char*);

And defined as:
	int _export activate_cerod(const char *text){...


My DEF file looks like this:
LIBRARY myvaluedriver
EXETYPE WINDOWS
DATA SINGLE MOVEABLE
EXPORTS
activate_cerod


Can someone please tell me what I'm doing wrong? Thanks a lot.


-- 
Robert M. Münch
Management & IT Freelancer
http://www.robertmuench.de
Oct 30 2006
parent reply =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Mon, 30 Oct 2006 09:45:00 +0100, Robert M. Münch  
<robert.muench robertmuench.de> wrote:

 Hi, I have a problem compiling a DLL. The C files all compile ...
Can no one help me with this one? :-( Robert
Nov 06 2006
parent reply Arjan Knepper <arjan ask.me.to> writes:
Robert M. Münch wrote:
 On Mon, 30 Oct 2006 09:45:00 +0100, Robert M. Münch 
 <robert.muench robertmuench.de> wrote:
 
 Hi, I have a problem compiling a DLL. The C files all compile ...
Can no one help me with this one? :-( Robert
Can you post the exact compiler and linker commandlines used to create the obj files and the link command to create the dll? What exactly are you trying to achive? A simple C linkable DLL or more sophisticated uses of the dll. Arjan
Nov 06 2006
parent reply =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Mon, 06 Nov 2006 23:58:10 +0100, Arjan Knepper <arjan ask.me.to>  
wrote:

 Can you post the exact compiler and linker commandlines used to  
 create the obj files and the link command to create the dll?
I use the following compiler flags: CFLAGS = -mnw -W -DSQLITE_HAS_CODEC=1 -DSQLITE_ENABLE_CEROD=1 -DSQLITE_DLL=1 And for linking: link <all .OBJ files> kernel32.lib, myvaluedriver.dll
 What exactly are you trying to achive? A simple C linkable DLL or  
 more sophisticated uses of the dll.
Just a simple C linkable DLL. Nothing fancy, just plain standard DLL. Thanks a lot so far. -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Nov 10 2006
parent reply Arjan Knepper <arjan ask.me.to> writes:
Robert M. Münch wrote:
 On Mon, 06 Nov 2006 23:58:10 +0100, Arjan Knepper <arjan ask.me.to> wrote:
 
 Can you post the exact compiler and linker commandlines used to create 
 the obj files and the link command to create the dll?
I use the following compiler flags: CFLAGS = -mnw -W -DSQLITE_HAS_CODEC=1 -DSQLITE_ENABLE_CEROD=1 -DSQLITE_DLL=1 And for linking: link <all .OBJ files> kernel32.lib, myvaluedriver.dll
 What exactly are you trying to achive? A simple C linkable DLL or more 
 sophisticated uses of the dll.
Just a simple C linkable DLL. Nothing fancy, just plain standard DLL. Thanks a lot so far. --Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
0.) Is the compiler option "-mnw" is really needed? 1.) The compiler option -W should be -WD when building a dll and -WA in all other win32 cases. 2.) the link line something like this: link /CO /NOPACKF /DEBUGLI /NOI /DE /XN /ENTRY:_DllMainCRTStartup /IMPLIB:"bar.lib" "<bar objs>" , "bar.dll" ,, user32.lib kernel32.lib , "bar.def" 3.) the bar.def file should be something like this: LIBRARY "bar.dll" DESCRIPTION 'bar Library' EXETYPE NT SUBSYSTEM WINDOWS CODE EXECUTE READ DATA READ WRITE HTH Arjan Knepper
Nov 10 2006
next sibling parent =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Fri, 10 Nov 2006 13:44:25 +0100, Arjan Knepper <arjan ask.me.to>  
wrote:

 0.) Is the compiler option "-mnw" is really needed?
Hi, no, I just followed the docs.
 1.) The compiler option -W should be -WD when building a dll and -WA  
 in all other win32 cases.
 2.) the link line something like this:
 link /CO /NOPACKF /DEBUGLI /NOI /DE /XN /ENTRY:_DllMainCRTStartup  
 /IMPLIB:"bar.lib" "<bar objs>"  , "bar.dll" ,, user32.lib  
 kernel32.lib , "bar.def"
 3.) the bar.def file should be something like this:

 LIBRARY      "bar.dll"
 DESCRIPTION  'bar Library'
 EXETYPE      NT
 SUBSYSTEM    WINDOWS
 CODE         EXECUTE READ
 DATA         READ WRITE
Ok, I have tried this. This brought me a big step further. The only thing now is, that I now get a SYMBOL UNDEFINED message in the linking step. Where the symbol mentioned is prefixed with an underscore, but the function is specified without the underscore in all source files. Any idea about this one? Thanks so far. -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Nov 10 2006
prev sibling parent reply =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Fri, 10 Nov 2006 13:44:25 +0100, Arjan Knepper <arjan ask.me.to>  
wrote:

Hi, so I made it to get a DLL with a good looking export section. No  
warning, errors or anything else. The only problem is, the DLL isn't  
working when compiled with DMC.

I have the same DLL done with MSVC and it works. Looking at the DLL  
structure I can see differences in the number of sections etc. And the  
DM version has a debug section, even I didn't specified any debug  
stuff, nor that I want to get a map file.

Any ideas how I can drill down the differences? IMO it can't be the  
code.

-- 
Robert M. Münch
Management & IT Freelancer
http://www.robertmuench.de
Nov 10 2006
parent reply Arjan Knepper <arjan ask.me.to> writes:
Robert M. Münch wrote:
 On Fri, 10 Nov 2006 13:44:25 +0100, Arjan Knepper <arjan ask.me.to> wrote:
 
 Hi, so I made it to get a DLL with a good looking export section. No 
 warning, errors or anything else. The only problem is, the DLL isn't 
 working when compiled with DMC.
 
 I have the same DLL done with MSVC and it works. Looking at the DLL 
 structure I can see differences in the number of sections etc. And the 
 DM version has a debug section, even I didn't specified any debug stuff, 
 nor that I want to get a map file.
 
 Any ideas how I can drill down the differences? IMO it can't be the code.
 
 --Robert M. Münch
 Management & IT Freelancer
 http://www.robertmuench.de
What isn't exactly working? How are you using the dll? In combination with dmc compiled exe's using a import lib or delayed/late binding? Arjan
Nov 13 2006
parent reply =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Mon, 13 Nov 2006 13:11:14 +0100, Arjan Knepper <arjan ask.me.to>  
wrote:

 What isn't exactly working? How are you using the dll?
 In combination with dmc compiled exe's using a import lib or  
 delayed/late binding?
Hi, I'm accessing the DLL from a scripting language using late binding. And my app works with the MSVC version but not the DM version. Calling the first function freezes my app. The DLL we are talking about is SQLite. Back in 2003 there was some feedback about a problem of DMC given to Walter. But I expect this one to be solved, but didn't cross-check it. -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Nov 17 2006
parent reply Arjan Knepper <arjan ask.me.to> writes:
Robert M. Münch wrote:
 On Mon, 13 Nov 2006 13:11:14 +0100, Arjan Knepper <arjan ask.me.to> wrote:
 
 What isn't exactly working? How are you using the dll?
 In combination with dmc compiled exe's using a import lib or 
 delayed/late binding?
Hi, I'm accessing the DLL from a scripting language using late binding. And my app works with the MSVC version but not the DM version. Calling the first function freezes my app. The DLL we are talking about is SQLite. Back in 2003 there was some feedback about a problem of DMC given to Walter. But I expect this one to be solved, but didn't cross-check it. --Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
I know DMC has a different way of handling the returning of floats from the dll which might cause problems. I'm not aware of other diffs. Do you have a idde prj file for the project or are you using make files? Arjan
Nov 17 2006
parent reply DarenW <darenw comcast.net> writes:
FWIW, I had the same initial problem with the Error 180 and all that.  Finally
solved that by adding CODE and DATA lines to my .def file.  Since the lines i
added differ from what was shown in this thread, others might want to see and
maybe explain what's going on.   (Although, i have yet to get as far as running
a
test app to use my DLL...)

LIBRARY wavescrawlcore INITGLOBAL
EXETYPE NT
CODE            PRELOAD DISCARDABLE
DATA            PRELOAD SINGLE

EXPORTS
 CreateWaveScrawler     1
 ....
Feb 01 2007
parent =?iso-8859-1?Q?Robert_M=2E_M=FCnch?= <robert.muench robertmuench.de> writes:
On Fri, 02 Feb 2007 06:13:13 +0100, DarenW <darenw comcast.net> wrote:

 FWIW, I had the same initial problem with the Error 180 and all  
 that.  Finally solved that by adding CODE and DATA lines to my .def  
 file.  Since the lines i added differ from what was shown in this  
 thread, others might want to see and maybe explain what's going  
 on.   (Although, i have yet to get as far as running a test app to  
 use my DLL...)

 LIBRARY wavescrawlcore INITGLOBAL
 EXETYPE NT
 CODE            PRELOAD DISCARDABLE
 DATA            PRELOAD SINGLE

 EXPORTS
  CreateWaveScrawler     1
  ....
Hi, thanks for the feedback. I'm going to try it out and let you all know. Robert
Feb 04 2007