Dll - error in file MyDll.def

Discussions related to Visual Prolog
Post Reply
Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Dll - error in file MyDll.def

Unread post by Vitaly Markov » 15 Mar 2013 20:37

Hi
Is key word "EXPORT" obsolescent may be?
The second compilation of project MyDLL is terminated with an error (VIP7.401):
MyDll.def
error lnk2537 : Error 2537: 'c:\documents and settings\mydoc\visual prolog examples\dll\mydll\mydll.def' - Incorrect definition file syntax of token '' at line 1.
The cursor points on the first letter of word "EXPORT".
The content of file:
EXPORT
touch

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 16 Mar 2013 14:55

It is no longer necessary to use .def files (has not been for a long time), and since I can't really remember the details about them I will rather support the "new" way.

You use the #export to export a class. Which means that all predicates declared in that class are exported with the link name you have given them in the "as" part of the declaration:

Code: Select all

#export myExports   class myExports   predicates     entry : (integer X) -> integer Y language stdcall as "Entry".   end class myExports
Regards Thomas Linder Puls
PDC

Kari Rastas
Active Member
Posts: 83
Joined: 4 Mar 2000 0:01

Unread post by Kari Rastas » 16 Mar 2013 17:23

The keyword in the *.def file is EXPORTS not EXPORT.

The old def file style works still perfectly with DLLs produced with the present version. I have in one DLL project about 270 exported predicates. So far I have been to lazy to "teach" myself the new style. :-)

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Re:

Unread post by Vitaly Markov » 17 Mar 2013 18:30

Thomas Linder Puls wrote:You use the #export to export a class. Which means that all predicates declared in that class are exported with the link name you have given them in the "as" part of the declaration:...
Thanks.
How to connect dll to dlluser-project statically?
Visual Prolog Example static "dll" is not correct.

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 18 Mar 2013 9:11

The dll\myDllUser project works fine for me. What problem do you have?

Basically you declare the same predicates/class (without the #export) and then you link with the corresponding lib.

Also notice the toyIDE example and the article Encapsulating.htm in that directory.
Regards Thomas Linder Puls
PDC

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Re:

Unread post by Vitaly Markov » 18 Mar 2013 17:57

Thomas Linder Puls wrote:The dll\myDllUser project works fine for me. What problem do you have?
Yes, this project works fine for me also. But I want to modify VIP-project example myDll+myDllUser.
I created new function "sum" in class myDll:

Code: Select all

class myDll predicates     touch : (string String) -> string Touched procedure (i) language stdcall as "touch".     sum : (integer, integer) -> integer  procedure (i,i) language stdcall as "sum". end class myDll   implement myDll clauses     touch(String) = string::concat(String, ", touched!").     sum(X,Y) = X+Y. end implement myDll
Building is Ok.
Then I try to call function "sum" in myDllUser.pro:

Code: Select all

implement myDllUser clauses     run() :-         console::write(myDll::sum(2,3)),console::nl,         console::write(myDll::touch("Hello World")). end implement myDllUser
Building is Ok
Run in Window terminated with error, matter of course:
Obj\myDllUser.5F8AA354.obj
error lnk2525 : Error 2525: 'Obj\myDllUser.5F8AA354.obj' - undefined name 'sum'
What must I do now?
I should use "#export myDll" in file myDll.cl ?

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 18 Mar 2013 19:03

Apparently, myDll uses the old strategy with a .def file.

So either you have to update the .def file, or delete it and then add #export myDLL (I would add it to the file that contains the goal).

I will update the myDLL (for some future release) examples, and if you like I can post the result here, but for a more flexible structure I would follow the ideas from toyIDE instead.
Regards Thomas Linder Puls
PDC

Kari Rastas
Active Member
Posts: 83
Joined: 4 Mar 2000 0:01

Unread post by Kari Rastas » 19 Mar 2013 7:30

I made a test with Markov Vitaly's example. Seems that the DEF-file's encoding must be ANSI, not UTF-8. Adding the new predicate (sum in this case) using VIP7.4 changes the encoding to UTF-8 and then in linking the system complains of an error on line 1. After changing the format to ANSI no problems in building the project and using the result through MyDllUser.

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov » 19 Mar 2013 17:02

Thanks Thomas, thanks Kari
I collect examples for school-book.
If the structure of dll-project will be modified, then example about dll-project be excluded from content.
:(

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 20 Mar 2013 9:37

In any case, I have updated the dll examples, currently they look like the attachment.

(And they may of course change more in the future).

Thanks to Kari for revealing the utf-8/linker problem, which we will of course look into.
Attachments
dll.zip
DLL example updated
(29.08 KiB) Downloaded 273 times
Regards Thomas Linder Puls
PDC

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov » 21 Mar 2013 18:32

I have updated the dll examples
Thomas, you tried to repeat creation of this example in a Prolog7.4?
The structure of the created dll-project and the structure of a dll-example are not identical.
Main differences are:
- different file structure of the projects
- "#export export" is arranged in the file without the goal.

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 22 Mar 2013 11:55

There are lots of ways to organize such programs.

The reason that I have moved the #export directives to the "goal" file is because then this file defines the entries to the dll, i.e. the goal and the exported entries.

But the #export directives could be placed "anywhere", as long as they are part of the DLL projects, but not part of the DLL-user projects.
Regards Thomas Linder Puls
PDC

User avatar
Thomas Linder Puls
VIP Member
Posts: 2361
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 4 Jun 2013 7:54

This is fixed in Build 7402. IDE: Web -> Check for updates...
Regards Thomas Linder Puls
PDC

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov » 21 Jun 2013 13:41

The creation of dll-project mydll is terminated with an error (VIP7.402):
fatal error lnk2505 : Fatal error 2505: Cannot create file 'c:\Documents and Settings\\ \mydll\Lib\mydll.lib', errno=2
"Bug is set" :shock: :D
I use Windows XP.
Must I use Windows7?

Vitaly Markov
Active Member
Posts: 67
Joined: 30 Nov 2003 0:01

Unread post by Vitaly Markov » 26 Jul 2013 10:21

Must I use Windows7?
Yes!
I installed Windows7-64 and dll-project is created!
Thanks.

Post Reply