World: r4wp
[#Red] Red language group
older newer | first last |
DocKimbel 23-Aug-2012 [1201x2] | BTW, we can also decide that C-like hex format is more important than pair! syntax and find another literal form for pairs, but that would push us further away from REBOL (and clones) compatibility. |
Pekr: from my little experience with lexers, I found it surprizingly difficult to design a set of consistent rules for a simple and readable syntax. If I had to design a new language syntax from scratch, this would probably be the hardest part. Carl did a fantastic job when designing REBOL syntactic rules (even if it's not 100% perfect, R3 did fix a lot of those issues). | |
Pekr 23-Aug-2012 [1203] | Ok then ... I think we have more iportant things to solve/design :-) |
Rebolek 23-Aug-2012 [1204] | How do I generate DLL? I added #export but it stills create .EXE file. Should I just rename it, or is there some compiler switch? |
DocKimbel 23-Aug-2012 [1205] | You need to use the WinDLL target: -t WinDLL |
Rebolek 23-Aug-2012 [1206] | Thanks. |
DocKimbel 23-Aug-2012 [1207] | Note that currently your exported function will have cdecl calling convention forced on them. I'll change the #export syntax today to allow optional convention to be specified (default will still be cdecl). |
Rebolek 23-Aug-2012 [1208] | So I build my first Red/System DLL, but R2 refuses to load it with: ** Access Error: Cannot open builds/temp.dll as library. |
Pekr 23-Aug-2012 [1209] | It is probably not related, but you might try with secure none, but I does not seem to be problem of REBOL's security or licence missing ... |
Rebolek 23-Aug-2012 [1210] | secure none doesn't help. |
DocKimbel 23-Aug-2012 [1211x5] | Let me test if there's no regression in last commits... |
Works fine here. I'm testing with: Red/System [ ] i: 56 foo: func [a [integer!] return: [integer!]][a + 1] #export [foo i] | |
You're sure that you're in `dyn-lib-emitter` branch? | |
(just in case) | |
If you still can't make it work, send me a copy of your DLL, I'll see what's wrong with it. | |
Rebolek 23-Aug-2012 [1216x4] | Yes, I'm in dyn-lib-emitter branch, otherwise compiler throws #export directive not found (or something like that) |
My DLL is almost same as your example ('i is missing and function is called 'f1 instead of 'foo but otherwise it exactly same :) | |
RED/System[ Title: "RED/System inline compilator test" ] f1: func [a [integer!] return: [integer!]] [a + 1] #export [f1] | |
(FYI: I'm trying to implement your make-native example) | |
DocKimbel 23-Aug-2012 [1220] | Your code works fine here (REBOL 2.7.6): >> lib: load/library %builds/test.dll >> f1: make routine! [a [integer!] return: [integer!]] lib "f1" >> f1 123 == 124 |
Rebolek 23-Aug-2012 [1221] | Hm, I'll try with 2.7.6, I'm using 2.7.8 this may be the problem. |
DocKimbel 23-Aug-2012 [1222x2] | Works here from 2.7.8 too. Try from a freshly cloned repo. |
Or just send me a copy of your DLL at [nr-:-red-lang-:-org], I should be able to quickly see what's wrong. | |
Rebolek 23-Aug-2012 [1224] | The DLL is here: http://box.lebeda.ws/~rebolek/temp.dll source is here: http://box.lebeda.ws/~rebolek/temp.reds But I guess it's just some stupid mistake on my side. |
DocKimbel 23-Aug-2012 [1225x4] | Let see that... |
Works fine here: >> lib: load/library %builds/temp.dll >> f1: make routine! [a [integer!] return: [integer!]] lib "f1" >> f1 123 == 124 | |
Are you running it under Windows XP? | |
(I wonder if it's not an OS compatibility issue) | |
Rebolek 23-Aug-2012 [1229] | No, W7. I will try this under virtual XP |
DocKimbel 23-Aug-2012 [1230x3] | I'm running it under W7 too, should be ok. |
Mystery deepens...:-) | |
Are you preloading other DLL in your REBOL session before loading temp.dll? | |
Rebolek 23-Aug-2012 [1233x2] | Same under WXP (virtual) with both 2.7.6 and 2.7.8 . It's probably some bad day :) >> lib: load/library %temp.dll ** Access Error: Cannot open temp.dll as library ** Near: lib: load/library %temp.dll |
No, clear session | |
DocKimbel 23-Aug-2012 [1235x5] | hmm... |
Try with following C executable: http://static.red-lang.org/tmp/loadlib.exe (or .zip if you have issue downloading the exe). Put it in the same folder as temp.dll and run it from DOS shell, you should have something like: C:\Dev\Red\red-system\builds>loadlib error: 0 hModule: 268435456 ;-- library handler error: 0 &f1: 10001a85 ;-- f1 function address 124 ;-- f1(123) error: 0 | |
If it works, the DLL should be ok and the issue would be with your REBOL instances. | |
This is the source code for loadlib.exe: https://gist.github.com/3435800 | |
Also, if someone else could test loading Rebolek's temp.dll lib, that would help. | |
Rebolek 23-Aug-2012 [1240] | Guess what. That works: c:\code\Red\red-system\builds>loadlib.exe temp.dll error: 0 hModule: 268435456 error: 0 &f1: 10001a85 124 error: 0 So it's probably really a bad day here for coding/testing :) |
DocKimbel 23-Aug-2012 [1241x2] | :-) |
The only cause I can think of is because the DLL produced by Red/System are not (yet) relocatable, they can be conflicting with other loaded DLLs (but shouldn't happen with a fresh REBOL session), or are triggering something in anti-virus or Windows security sub-systems. | |
Pekr 23-Aug-2012 [1243x2] | One thing - between some versions, there was change in syntax of "renturn". One version used the colon, the other did not. Just an idea ... |
but if the same code works for Doc, problem is elsewhere ... | |
Rebolek 23-Aug-2012 [1245] | Petr, can you please try loading the DLL I provided, so we're sure it's just som eproblem with my setup? |
Endo 23-Aug-2012 [1246] | I've successfully loaded the temp.dll, R2 2.7.8 on XP/Pro. |
DocKimbel 23-Aug-2012 [1247] | It's strange that it didn''t work for Rebolek even on its WinXP virtual image...do you have an antivirus installed there? |
Endo 23-Aug-2012 [1248x3] | I have Avast on my PC. |
Rebolek: if you have a antivirus, can you disable it and try? | |
Can it be msvcrt.dll version? | |
older newer | first last |