1. Problems creating dll / preprocessor

Hallo

I started using the Euphoria Preprocessor feature. To get more specific i like to use the Jeremy Cowgar's dot4 preprocessor (it can be found here https://bitbucket.org/jcowgar/dot4/ )
The Preprocessor as a script-file (dot.ex) seems to work with Eu4.0.x and Eu4.1 (32bit and 64bit ).
I also can translate and compile it to dot.exe with all Versions of Euphoria I use.

What i can't do is, building a working dll of the preprocessor, they all fail for different reasons.

Okay, this is what i use:
Operatingsystem Win8 64bit.

C:\eu4neu\jcowgar-dot4-466834760c1b\src>ver 
 
Microsoft Windows [Version 6.3.9600] 

64bit Deevelopment:

C:\eu4neu\jcowgar-dot4-466834760c1b\src>c:\eu4.1-64\bin\euc 
Euphoria to C Translator v4.1.0 development 
   64-bit Windows, Using System Memory 
   Revision Date: 2014-03-03 19:34:37, Id: 6199:59b3bcba649a 
 
ERROR: Must specify the file to be translated on the command line 
 

C:\eu4neu\jcowgar-dot4-466834760c1b\src>gcc --version 
gcc (tdm64-1) 4.7.1 
Copyright (C) 2012 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 

The 64bit Version generates a dll. The dll can be loaded, but linking the c_func fails.

32bit Development:

C:\eu4neu\jcowgar-dot4-466834760c1b\src>gcc --version 
gcc (tdm-1) 4.7.1 
Copyright (C) 2012 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

C:\eu4neu\jcowgar-dot4-466834760c1b\src>c:\eu4.1-32\bin\euc 
Euphoria to C Translator v4.1.0 development 
   32-bit Windows, Using System Memory 
   Revision Date: 2014-03-03 19:34:37, Id: 6199:59b3bcba649a 
 
ERROR: Must specify the file to be translated on the command line 

C:\eu4neu\jcowgar-dot4-466834760c1b\src>c:\eu4.0-32\bin\euc 
Euphoria to C Translator v4.0.5 development 
   Windows, Using System Memory 
   Revision Date: 2014-06-09 15:57:20, Id: 6227:9cca399cbb74 
 
ERROR: Must specify the file to be translated on the command line 

The 32Bit Eu4.1 Version gives this Error Message:

C:\eu4neu\jcowgar-dot4-466834760c1b\src>c:\eu4.1-32\bin\euc -dll dot_dll.ex 
Build directory: build-232385\ 
Translating code, pass: 1 2 3 4 5 6 7 8 9 10 11  generating 
Compiling with GCC 
Compiling   2% init-.c 
Compiling  11% dot_dll.c 
Compiling  17% main-.c 
Compiling  22% dot_pp.c 
dot_pp.c:2761:8: error: conflicting types for '_2dot' 
In file included from dot_pp.c:3:0: 
main-.h:951:18: note: previous declaration of '_2dot' was here 
Couldn't compile file 'dot_pp.c' 
Status: 1 Command: gcc  -DEWINDOWS -fomit-frame-pointer -c -w -fsigned-char -O2 
-m32 -Ic:/EU4~2.1-3 -ffast-math dot_pp.c 

dot_pp.c:2761 
object _2dot(object _inFileName_11917, object _outFileName_11918, object _verbose_11919) 
 
main-.h:951 
object __stdcall _2dot(object, object, object); 

The 32bit 4.0 Version generates a dll. The dll can be loaded, but linking the c_func fails.

PE Explorer shows that the function is exported:

// _1preprocess@12; Index 535;		Information not available 

If i use this mangeld name i can succesfully link the function.

I use this little program for testing.

include std/dll.e 
include std/machine.e 
include std/os.e 
include std/console.e 
 
ifdef BITS64 then 
	constant tinlib= open_dll("dot_dll64.dll") 
elsedef 
	constant tinlib= open_dll("dot_dll.dll") 
end ifdef 
 
if tinlib then 
    puts(1,"DLL linked ..."&"\n") 
else 
    puts(1,"DLL linking failed ..."&"\n") 
    -- abort(1) 
end if 
 
 
constant preproc=define_c_func(tinlib,"_1preprocess@12",{E_SEQUENCE,E_SEQUENCE,E_SEQUENCE},E_INTEGER) 
-- constant preproc=define_c_func(tinlib,"preprocess",{E_SEQUENCE,E_SEQUENCE,E_SEQUENCE},E_INTEGER) 
if preproc>0 then 
    puts(1,"Function linked ..."&"\n") 
else 
    puts(1,"Function preprocess linking failed ..."&"\n") 
    -- abort(1) 
end if 
 
any_key() 

Maybe someone knows what I'am are doing wrong. btw. All Versions of Euphoria i use are build with the above shown Compiler. I regulary use the translator but didn't used it for creating dll's for a longer time.

Andreas

new topic     » topic index » view message » categorize

2. Re: Problems creating dll / preprocessor

Hi

I worked a little on my problem, but still got no solution.

i still can't produce working dll's on Windows using gcc (i tried WIn8.1 64bit and WinXP 32bit)

Okay, it's not completly correct i can produce very simple dll's using Eu4.0.x and Eu 4.1 64bit.

 
-- This is the dll code 
 
global function add(integer a, integer b) 
 
	return a+b 
 
end function 
 
 
-- This is the calling code 
 
include std/dll.e 
include std/console.e 
 
 
 
constant tinlib= open_dll("simpledll.dll") 
 
if tinlib then 
    puts(1,"DLL linked ..."&"\n") 
else 
    puts(1,"DLL linking failed ..."&"\n") 
    abort(1) 
end if 
 
atom preproc=define_c_func(tinlib,"_1add",{E_INTEGER,E_INTEGER},E_INTEGER) 
 
puts(1,sprintf("%d",preproc)&"\n") 
 
puts(1,"now calling\n") 
 
?c_func (preproc,{5,2}) 
 
puts(1,"done\n") 
 
wait_key() 
 
 

This code above is the most i could get working using gcc (it's the 64bit Version, for 32bit the functionname is _1add@8).

As soon as i add a sequence, object or atom the dll crashes. Using Eu4.1 32bit it will not even compile, if there is an include file in the dll.

So now I'am really not sure, but i really want to know...

a.) Is this only my problem (no one cares about dll's on Windows)
b.) It works for everybody else (I'am just to stupid to setup gcc)
c.) Creating dll's on Windows is broken with gcc but ... see a.)

btw. everything works fine with Eu4.0.x compiled with OpenWatcom, I can even use this dll's with Eu4.1 32bit.
The problem is, the OpenWatcom installer does not work on Win8.1.

On the otherhand using gcc breaks also the pre-processor in OpenEuphoria as preproc.e only looks for a function called 'preprocess' in the supported dll.
Not for something like '_1preprocess˛ or '_1preprocess'.

Maybe someone has an answer

Andreas

new topic     » goto parent     » topic index » view message » categorize

3. Re: Problems creating dll / preprocessor

andi49 said...

Hi

I worked a little on my problem, but still got no solution.

i still can't produce working dll's on Windows using gcc (i tried WIn8.1 64bit and WinXP 32bit)

Okay, it's not completly correct i can produce very simple dll's using Eu4.0.x and Eu 4.1 64bit.

 
-- This is the dll code 
 
global function add(integer a, integer b) 
 
	return a+b 
 
end function 
 
 
-- This is the calling code 
 
include std/dll.e 
include std/console.e 
 
 
 
constant tinlib= open_dll("simpledll.dll") 
 
if tinlib then 
    puts(1,"DLL linked ..."&"\n") 
else 
    puts(1,"DLL linking failed ..."&"\n") 
    abort(1) 
end if 
 
atom preproc=define_c_func(tinlib,"_1add",{E_INTEGER,E_INTEGER},E_INTEGER) 
 
puts(1,sprintf("%d",preproc)&"\n") 
 
puts(1,"now calling\n") 
 
?c_func (preproc,{5,2}) 
 
puts(1,"done\n") 
 
wait_key() 
 
 

This code above is the most i could get working using gcc (it's the 64bit Version, for 32bit the functionname is _1add@8).

As soon as i add a sequence, object or atom the dll crashes. Using Eu4.1 32bit it will not even compile, if there is an include file in the dll.

So now I'am really not sure, but i really want to know...

a.) Is this only my problem (no one cares about dll's on Windows)
b.) It works for everybody else (I'am just to stupid to setup gcc)
c.) Creating dll's on Windows is broken with gcc but ... see a.)

btw. everything works fine with Eu4.0.x compiled with OpenWatcom, I can even use this dll's with Eu4.1 32bit.
The problem is, the OpenWatcom installer does not work on Win8.1.

On the otherhand using gcc breaks also the pre-processor in OpenEuphoria as preproc.e only looks for a function called 'preprocess' in the supported dll.
Not for something like '_1preprocess˛ or '_1preprocess'.

Maybe someone has an answer

Andreas

Andreas
Have you tried creating DLL with borland compiler
Every compiler creates exports a little different.
Bernie

new topic     » goto parent     » topic index » view message » categorize

4. Re: Problems creating dll / preprocessor

BRyan said...

Have you tried creating DLL with borland compiler

This is not supported.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Problems creating dll / preprocessor

andi49 said...

Hi

I worked a little on my problem, but still got no solution.

i still can't produce working dll's on Windows using gcc (i tried WIn8.1 64bit and WinXP 32bit)

Okay, it's not completly correct i can produce very simple dll's using Eu4.0.x and Eu 4.1 64bit.

 
-- This is the dll code 
 
global function add(integer a, integer b) 
 
	return a+b 
 
end function 
 

One problem here is that you're trying to export a function with the same name as a backend function. I'm not sure how we can solve this sort of conflict. If you tried this under Linux, you'd get a linker error similar to:

/usr/local/lib/euso.a(be_runtime.o): In function `add': 
be_runtime.c:(.text+0x137): multiple definition of `add' 

The translator code doesn't attempt to alias function names on Windows, however (we used a different way of naming exports under Watcom). That needs to be fixed. I could import the function using "_1add@8" under Windows, but was still getting machine errors. I suspect this is happening in the C calling code, but I haven't gotten that far yet.

Matt

new topic     » goto parent     » topic index » view message » categorize

6. Re: Problems creating dll / preprocessor

Hi

mattlewis said...
andi49 said...

Hi

I worked a little on my problem, but still got no solution.

i still can't produce working dll's on Windows using gcc (i tried WIn8.1 64bit and WinXP 32bit)

Okay, it's not completly correct i can produce very simple dll's using Eu4.0.x and Eu 4.1 64bit.

 
-- This is the dll code 
 
global function add(integer a, integer b) 
 
	return a+b 
 
end function 
 

One problem here is that you're trying to export a function with the same name as a backend function. I'm not sure how we can solve this sort of conflict. If you tried this under Linux, you'd get a linker error similar to:

/usr/local/lib/euso.a(be_runtime.o): In function `add': 
be_runtime.c:(.text+0x137): multiple definition of `add' 

The translator code doesn't attempt to alias function names on Windows, however (we used a different way of naming exports under Watcom). That needs to be fixed. I could import the function using "_1add@8" under Windows, but was still getting machine errors. I suspect this is happening in the C calling code, but I haven't gotten that far yet.

Matt

I can confirm this partly, but i got no linking error on Win32 or Win64. This simple dll above just works as it it should.

global function add(atom a, atom b) 
 
	return a+b 
 
end function 

But this one crashes silently if i call it with floatingpoint values (not with integer values).

I think there is a problem with gcc and dll's on Windows.

For now it is okay for me as i got OpenWatcom working on Win8.1 64bit. So i can use Eu4.0.x and everything works just fine.

I'am now heading for holydays :)

Andreas

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu