1. Euphoria Wrapper Problem
- Posted by Icy_Viking Jun 02, 2015
- 1945 views
Hello,
I am having the following issue while trying to make an example program. The error says bad routine number (-1).
--Example program without warning include std/machine.e include std/filesys.e --include std/misc.e include EuSDL2.ew include EuSDL2TTF.ew include flags.e atom dummy dummy = SDL_Init(SDL_INIT_VIDEO) if dummy = -1 then puts(1,"Could not initialize SDL2!\n") abort(0) end if dummy = TTF_Init() --error comes from here atom win = SDL_CreateWindow("Font Win",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,640,480,SDL_WINDOW_SHOWN) atom ren = SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED) integer run = 1 atom key = 0 while run = 1 do SDL_PumpEvents() key = SDL_GetKeyboardState(key) if (peek(key+SDL_SCANCODE_ESCAPE) > 0) then run = 0 end if SDL_RenderClear(ren) SDL_RenderPresent(ren) end while SDL_DestroyWindow(win) SDL_DestroyRenderer(ren) free(key) SDL_Quit()
//TTF_Font.h extern DECLSPEC int SDLCALL TTF_Init(void);
--Wrapper code public constant xTTF_Init = define_c_func(ttf,"TTF_Init",{},C_INT) public function TTF_Init() return c_func(xTTF_Init,{}) end function
I've tried looking at all the different files, but I can't see anything wrong or why it would come up with a bad routine error. Am I declaring something wrong, is the DLL I'm using bad? When I run the wrapper file, which is .ew, it runs fine, no errors or anything. However, when I try to run an actual program using the wrapper, I get the bad routine error. Any help is greatly appericated.
2. Re: Euphoria Wrapper Problem
- Posted by jimcbrown (admin) Jun 03, 2015
- 1908 views
Hello,
I am having the following issue while trying to make an example program. The error says bad routine number (-1).
I've tried looking at all the different files, but I can't see anything wrong or why it would come up with a bad routine error. Am I declaring something wrong, is the DLL I'm using bad? When I run the wrapper file, which is .ew, it runs fine, no errors or anything. However, when I try to run an actual program using the wrapper, I get the bad routine error. Any help is greatly appericated.
Try modifying your wrapper like this:
--Wrapper code if ttf = 0 then puts(2, "Load of Library ttf failed!\n") end if public constant xTTF_Init = define_c_func(ttf,"TTF_Init",{},C_INT) if xTTF_Init = 0 then puts(2, "Load of function TTF_Init failed!\n") end if public function TTF_Init() return c_func(xTTF_Init,{}) end function
And let us know what the output is.
3. Re: Euphoria Wrapper Problem
- Posted by Icy_Viking Jun 03, 2015
- 1906 views
Hello,
I am having the following issue while trying to make an example program. The error says bad routine number (-1).
I've tried looking at all the different files, but I can't see anything wrong or why it would come up with a bad routine error. Am I declaring something wrong, is the DLL I'm using bad? When I run the wrapper file, which is .ew, it runs fine, no errors or anything. However, when I try to run an actual program using the wrapper, I get the bad routine error. Any help is greatly appericated.
Try modifying your wrapper like this:
--Wrapper code if ttf = 0 then puts(2, "Load of Library ttf failed!\n") end if public constant xTTF_Init = define_c_func(ttf,"TTF_Init",{},C_INT) if xTTF_Init = 0 then puts(2, "Load of function TTF_Init failed!\n") end if public function TTF_Init() return c_func(xTTF_Init,{}) end function
And let us know what the output is.
I tried it like this
if ttf = 0 then puts(2,"Failed to open SDL2_tff.dll!\n") --abort(0) end if
It appears it failed to load the DLL. I also tried it like this.
if ttf = -1 then puts(2,"Failed to open SDL2_tff.dll!\n") --abort(0) end if public constant xTTF_Init = define_c_func(ttf,"TTF_Init",{},C_INT) if xTTF_Init = 0 then puts(2,"Failed to load function TTF_Init()") end if
No error came up when I tried that. So I suspect it is failing to load the DLL for whatever reason. However, I can't see why as the previous SDL DLLs all loaded fine.
4. Re: Euphoria Wrapper Problem
- Posted by petelomax Jun 03, 2015
- 1938 views
puts(2,"Failed to open SDL2_tff.dll!\n")
So I suspect it is failing to load the DLL for whatever reason. However, I can't see why as the previous SDL DLLs all loaded fine.
I would run procmon and see where it was trying to load that dll from, and what errors it got. Be warned it may collect thousands if not hundreds of thousands of events, so first make sure you are ready to have it fail, then start procmon and click OK to start capturing events, run your app and immediately switch back to procmon and stop capture (third icon, looks like a cotton wool toffee apple). Then use right click menus to exclude what you safely can, especially anything from your browser/av/svchost/lsass/taskhost/services/csrss/conhost/DllHost/etc. Another possibly easier way to set filters is start capture and exclude (by Process Name) everything that appears before you run your app, which you start once you've got procmon down to a blank screen. Either way it is far easier the second time you use procmon, as it remembers all your filters. One word of warning: if you leave capture running your pc will grind to a halt before very long, so always turn it off as soon as you can.
if that did not solve I would try dependency walker and see what that said.
Pete
5. Re: Euphoria Wrapper Problem
- Posted by ghaberek (admin) Jun 03, 2015
- 1910 views
and if that did not solve I would try dependency walker and see what that said.
Dependency Walker is a great tool for this.
-Greg
6. Re: Euphoria Wrapper Problem
- Posted by petelomax Jun 03, 2015
- 1868 views
Dependency Walker is a great tool for this.
My only gripe is it ain't so hot when analyzing a 32bit dll on a 64bit OS, or at least wasn't the last time I looked. It will behave itself after I've messed about with the directory orders, though.
Pete
7. Re: Euphoria Wrapper Problem
- Posted by Icy_Viking Jun 03, 2015
- 1907 views
and if that did not solve I would try dependency walker and see what that said.
Dependency Walker is a great tool for this.
-Greg
I ran dependencywalker, and it appears it is missing DLLs that are trying to load, but aren't there. These are the errors: Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
8. Re: Euphoria Wrapper Problem
- Posted by petelomax Jun 04, 2015
- 1836 views
I ran dependencywalker, and it appears it is missing DLLs that are trying to load, but aren't there. These are the errors: Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Can you quickly confirm there is no "Error: Modules with different CPU types were found"?
Taking two that I know are absolutely fine:
If I load C:\Windows\system32\kernel32.dll (the 64 bit one), it is fine.
If I load C:\Windows\syswow64\kernel32.dll (the 32 bit one), I get errors, until I select Options/Configure Module Search Order, and move syswow64 above system32.
That's with the latest 64-bit version 2.2, if I try the 32-bit version it quietly ignores several 32/64 bit errors.
If you like, select File/Save As, change the drop-down to .txt, and post the resulting file here.
Pete
9. Re: Euphoria Wrapper Problem
- Posted by ghaberek (admin) Jun 04, 2015
- 1831 views
My only gripe is it ain't so hot when analyzing a 32bit dll on a 64bit OS, or at least wasn't the last time I looked. It will behave itself after I've messed about with the directory orders, though.
There are separate versions for x86 and x86-64. I use both of them on 64-bit Windows 7, depending on the type of libraries I have to investigate.
-Greg
10. Re: Euphoria Wrapper Problem
- Posted by petelomax Jun 04, 2015
- 1847 views
My only gripe is it ain't so hot when analyzing a 32bit dll on a 64bit OS, or at least wasn't the last time I looked. It will behave itself after I've messed about with the directory orders, though.
There are separate versions for x86 and x86-64. I use both of them on 64-bit Windows 7, depending on the type of libraries I have to investigate.
-Greg
I've tried that, also on 64-bit Windows 7, but the 32-bit version quietly ignores 32/64 bit errors, that you can see if you look carefully enough. To be fair, if it reports no errors when it is actually looking in error at a few 64-bit dlls, it probably means everything is OK, but I would still have to recommend tweaking the Directory Search Order until it is loading all the right (32-bit) ones, and there is less scope for error if you stick to the 64-bit one when your OS supports it.
As a quick example (using 32-bit dependency walker on a 64-bit OS):
[ ] c:\windows\syswow64\KERNEL32.DLL [ ] c:\windows\syswow64\API-MS-WIN-CORE-RTLSUPPORT-L1-1-0.DLL [ ] c:\windows\system32\NTDLL.DLL [ ] c:\windows\system32\KERNELBASE.DLLYou can see it has (quietly) loaded the 32-bit kernel32.dll and API-MS...dll, but the 64-bit ntdll.dll and kernelbase.dll, all without raising any alarms.
Pete
11. Re: Euphoria Wrapper Problem
- Posted by ghaberek (admin) Jun 04, 2015
- 1863 views
I've tried that, also on 64-bit Windows 7, but the 32-bit version quietly ignores 32/64 bit errors, that you can see if you look carefully enough. To be fair, if it reports no errors when it is actually looking in error at a few 64-bit dlls, it probably means everything is OK, but I would still have to recommend tweaking the Directory Search Order until it is loading all the right (32-bit) ones, and there is less scope for error if you stick to the 64-bit one when your OS supports it.
As a quick example (using 32-bit dependency walker on a 64-bit OS):
[ ] c:\windows\syswow64\KERNEL32.DLL [ ] c:\windows\syswow64\API-MS-WIN-CORE-RTLSUPPORT-L1-1-0.DLL [ ] c:\windows\system32\NTDLL.DLL [ ] c:\windows\system32\KERNELBASE.DLLYou can see it has (quietly) loaded the 32-bit kernel32.dll and API-MS...dll, but the 64-bit ntdll.dll and kernelbase.dll, all without raising any alarms.
I see what you mean. I never noticed that before. Thanks for pointing that out.
-Greg