difficulties using 3rd party dll when creating an external

Are you developing tools to extend the LiveCode environment? This is the place to talk about the nuts and bolts of extending our nuts and bolts. If you want to use a LiveCode or third party Environment extension, visit the Using Evironment Extensions forum.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

difficulties using 3rd party dll when creating an external

Post by grodrig » Thu Mar 19, 2009 9:04 pm

Runtime Revolution Ltd Forum Index Runtime Revolution Ltd
Questions and answers about the Revolution product family.

FAQFAQ SearchSearch MemberlistMemberlist UsergroupsUsergroups
ProfileProfile You have no new messagesYou have no new messages Log out [ grodrig ]Log out [ grodrig ]
rss

Inbox Inbox Sentbox Sentbox Outbox Outbox Savebox Savebox

Reply to message Runtime Revolution Ltd Forum Index
Inbox :: Message
From: grodrig
To: grodrig
Posted: Thu Mar 19, 2009 8:00 pm
Subject: 3rd party dll external help Quote message
Hi,

I've been going at this for various days. I read the tutorials on externals posted in the revolution front page and also the visual basic example too. I also downloaded the SDK example. Still it is not clear to me how to put it all together. This is what I have done so far and work.


1) I followed the tutorial and created the rnaHello example. It work as expected. Note I used the "External Creator V1.rev" provided in the tutorial.


2) I created a separate project in C++ which uses a 3rd party DLL to communicates to an USB device (FTDI device if you are curious). The program is pretty simple. All it does is get the device ID. This program works fine and I'm able to see the device ID.

So far so good eh!!

This is the part that doesn't work

3) I took the rnaHello example and added a function. All this function does is call the same commands that worked on step 2 above. The difference is that the code is now copied to the same file as the rnaHello. That is to say, step #2 above was just a sanity check and has no relation to this step. Under the project properties I included the necessary libraries needed to talk to my usb device. This was the same step I took when doing step #2 above. I compile the project to make sure there where no errors. It compiled fine. However when hit the debug button and revolution opens I get the followoing error:

In rnaHelloExternalWrapper:revolution.exe - unable to locate Com...
"This application has failed to start because FTCJTAG.dll was not found. Re-installing the application may fix the problem."

--where FTCJTAG is the DLL that controls my USB device.

4) To make sure I'm doing things right, I comented out part of the code that calls on the offending DLL. I left the rest of the code alone just to see if can call other functions or at least this particular function. This step works.

I put all the code including the 3rd party lib and dll file under the src folder created by the project. That did not work. I then move them to various other folder like the _build\Debug folder where the external DLL produce by revolution resides and that did not help either. I can't get rid of this problem.

Any clues cause I can't figure it out. The funny part is that another colleague tried the same thing in a different machine using the same exact step and it worked. The only difference was that he had an evaluation media version of revolution where I have the studio version. What gives? and yes, I copied and used his setup without making any change and that did not work either.


my system setup:
1) revolution studio 3.0
2) windows XP professional SP2
3) using visual c++ express 2008
View user's profile

Reply to message All times are GMT
Jump to:


Powered by phpBB © 2001, 2005 phpBB Group

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Thu Mar 19, 2009 10:10 pm

Hi grodrig,

funny you post this. We ran into the same problem yesterday. Till now I have no clue what could be the problem, so I hope one of the experienced external writers chimes in.

Cheers,

Malte

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Post by Bernard » Fri Mar 20, 2009 10:00 pm

This may be from way off field.....

Try searching in the c:\Windows directory for this missing file (FTCJTAG.dll). I don't really use Windows much, and I have never built an external. BUT since it worked on your colleagues machine but not on yours even when you copied his setup, it suggests to me that the DLL may be in various places on his machine, and maybe not in those places on yours.

Don't rely on the 'Search' box on the windows start menu - as far as I remember it is programmed (stupidly in my opinion) to only search for files of a certain type. DLLs may not be in it's acceptable files list.

Equally I suppose it might be worth searching the registry too.

Just my 2p.

grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

Post by grodrig » Fri Mar 20, 2009 10:35 pm

No, I'm providing the DLL file myself so I know where it is. However, I am now trying a different approach. I am creating a static library in VC++ using that same DLL. I then create a test C++ file to call this library. Well, it turns out that this didn't work either. As a matter of fact I get the same exact error. Only when I create a project that access the DLL directly does it work. To me this means that there is a setting in VC++ that is not set properly or that I'm doing something that is not legal. In other words, I think the problem is in the C++ part and not in revolution since I can't access the DLL from VC++ either.

Note that I can make it work as long as I access the DLL directly. That is, use it in the same file and project that make the function calls. Once I try to access it as a library all hell breaks loose.

Also, I did try creating a regular static library in VC++ that does not relies on the DLL in question. That worked fine. Are there any rules about DLLs that I don't know about?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Sat Mar 21, 2009 7:50 pm

...grasping at straws here a bit, but...

This *should* work properly. Since it doesn't, my guess is that it's a problem with paths. Is the dll registered on your system or just placed in a directory somewhere? Do you have a corresponding .lib file in your dependency list in VS?

Since you're trying to debug this from within VS, it's possible that you need to configure the debug options to look for the dll explicitly. I've had that happen before, although I've forgotten the details or why I had to do this in that case. If you want to try debugging without registering the dll with the system, then the proper dll location may be one of:

the location of your external dll
the location of the rev stack
the location of the rev engine
the Externals directory in the rev folder

grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

Post by grodrig » Tue Mar 24, 2009 11:18 pm

Well, I mange to make a library in VC++ and call a library from another VC++ program. The problem in the in this experiment was that I needed to put the DLL where the *.EXE file was.

That being done I went back to try revolution again but this time with the similar setups as the new eperiment program. Well, that won't even compile. The difference between this new program and the old one is that it tries to import a library that I created. Due to time I went back to the last working revolution external which still has that can't find DLL problem. I know the problem is that C++ can't find the DLL. That is, you are correct in that there is a path problem. Well, I went through each folder that was created using the RNAHELLO example that everybody seems so happy about. I put the DLL in every folder one by one. I would compile as before and still got the error. I went through each folder systematically putting the file in each one, try it and if it didn't work then remove it. None of the worked. It has to be some setup in the C++ side. Sme setup that is done by the external_creator_V1 that is affecting the results. I tried telling the compiler where to look for the necessary files but maybe I'm missing something. Note I only did it under the rnahello project. I did not touched libexternal project at all.

Somebody must know the proper way to set this thing. Note that this is the deal braker for me. If I can't communicate with the supplied DLL then everything else I have done so far in revolution is useless since the project revolves around this external device.

grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

problem solved

Post by grodrig » Wed Mar 25, 2009 7:56 pm

Finally I figure out the problem. I have to say it was extremely frustrating. Here is how I did it for future reference. For the sake of having an example I will cal my DLL file JUNK.DLL. Just substitute JUNK for whatever name your DLL happened to be called.

Issue #1 was the location of the JUNK.dll. I found two options. The easy way out of it is to put the 3rd party DLL (JUNK.dll)in the system32 folder (C:/windows/system32). The other option was to create a path to a specific folder but I though this would had been a bit extreme. You would have to right click your "my computer" icon and choose properties. Then click on the advance tab. Finally click on the Environment Variable button. When the new pop up window opens then select PATH and click edit. Add your path to that field following the format that's already there. I think is semi-column (;) separated. I though that was too much work so I just copied and pasted my JUNK.dll file to the system32 folder.

Issue #2 was setting the visual c++ environment properly. I had to run separate experiments to make this work. The thing is that my JUNK.dll file came with two other files called JUNK.h and JUNK.lib The first thing I did was to copy these 2 files (JUNK.h and JUNK.lib) into the same source folder (scr) revolution created. Back in VC++ I right clicked my project and in the menu it pop up I chose properties. When the new window opened I expanded the configuration Properties and withing that the Linker. Withing the linker I selected the General option and on the right side where it said Add Library Directory I added the path to where my JUNK.lib was. After that I selected the Input option under the Link. On the right hand side where it says Additional Dependencies I typed JUNK.lib. The final step was to include the JUNK.h (#include "JUNK.h") in my main file. That was it. After that it ran fine.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Wed Mar 25, 2009 9:08 pm

#2 - I thought we had determined earlier that you had the .lib file in your dependency list. Guess not. It's a PITA in Visual Studio, but it's gotta be done. You don't actually have to copy the .h and .lib files into a different directory, but I do that as well just to keep all the pieces together.

#1 - Putting a third-party dll in the system32 directory is a bad idea, for a number of reasons. Yes, it *will* work. At least on your system. For now. But if you're writing an app to run on other people's computers you may run into installation issues if they don't have proper permissions or if they're (shudder) running Vista. And what if another app comes along with a different or updated version of a dll with the same name?

The established way to have a third-party dll on a computer is to place it into an application directory and register it with the system. That creates a registry entry no matter where it is, and lets the operating system know that it exists. See the docs for regsvr32.exe.

grodrig
Posts: 7
Joined: Thu Mar 19, 2009 8:29 pm

Post by grodrig » Thu Mar 26, 2009 4:48 pm

I was not aware!!!. Thanks for the heads up. We should all follow standard programing practices to avoid unforeseen problems.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Thu Mar 26, 2009 5:22 pm

Congrats on getting your code working, though. That's great.

Post Reply

Return to “Making IDE Plugins”