<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - Dll lookup error - Comments</title>
 <link>http://www.newlc.com/en/topic-17537</link>
 <description>Comments for &quot;Dll lookup error&quot;</description>
 <language>en</language>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-42123</link>
 <description>&lt;p&gt;Hello, juanaranda.&lt;br /&gt;
I&#039;m really sorry for the late reply. I hope you found the answer yourself already. Probably you have your interface declaration in a header file. Just include the .h file in CMyClassApp, and it will compile.&lt;/p&gt;</description>
 <pubDate>Mon, 08 Oct 2007 17:11:03 +0200</pubDate>
 <dc:creator>filio</dc:creator>
 <guid isPermaLink="false">comment 42123 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-41964</link>
 <description>&lt;p&gt;Hi.&lt;/p&gt;

&lt;p&gt;Thanks filio for reply my post, I appreciate your help a lot  &lt;img src=&quot;/sites/all/modules/smileys/packs/example/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt; .  I was trying to create a polymorphic dll. I followed your way to create it and I also found out more about it. I created an interface (abstract class with virtual methods) that I called CMyClassLib and there I defined the functions that the dll should have. I implemented the interface in the CMyClass class and I exported only one function:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;EXPORT_C CMyClass* NewPlugin()&lt;br /&gt;{&lt;br /&gt;return new (ELeave) CMyClass;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;I compiled everything and the dll file was created. But, when I was trying to call a dll’s function in other application (that I called CMyClassApp and is in a different project and folder) I got an error in the part where I’m casting the function returned by the Lookup(). For example:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;void CMyClassApp::HandleCommandL(TInt aCommand)&lt;br /&gt;{&lt;br /&gt;//MORE CODE HERE&lt;br /&gt;&lt;br /&gt; User::LeaveIfError(library.Load(aPluginName)); &lt;br /&gt;// Check second UID is as expected; leave if not&lt;br /&gt;if (library.Type()[1] != KDLLUidValue)&lt;br /&gt;{&lt;br /&gt;User::Leave(KErrGeneral);&lt;br /&gt;}&lt;br /&gt;TLibraryFunction entry=library.Lookup(1);&lt;br /&gt;if(entry)&lt;br /&gt;{&lt;br /&gt;// Call the function to create new CMyClass&lt;br /&gt;CMyClass* iMyClass=(CMyClass*) entry();&lt;br /&gt;.....&lt;br /&gt;delete iMyClass;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//MORE CODE HERE&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;The error I got was that CMyClass was undeclared. I don’t know if I have to copy the interface or dll’s class in the CMyClassApp’s directory and import them in the CMyClassApp’s cpp file. So if you can give a hint about what should I do, I appreciate it a lot.&lt;br /&gt;
&lt;/p&gt;</description>
 <pubDate>Mon, 01 Oct 2007 19:33:26 +0200</pubDate>
 <dc:creator>juanaranda</dc:creator>
 <guid isPermaLink="false">comment 41964 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-41880</link>
 <description>&lt;p&gt;Hi, juanaranda.&lt;br /&gt;
  I think you mixed things up a little bit. Is it a static or polymorphic DLL you are trying to create? &lt;br /&gt;
  If it is a static dll, there is no need to load the library like this. Just add the header file with the exported functions in your code, and then add the .lib (or .dso for GCCE) files in project, when the linker asks for them.&lt;br /&gt;
  If it is a polymorphic dll you have, here is the thing that works for me.  I think this is the right way to export your functions.&lt;br /&gt;
In your dll, there is only one function exported.&lt;/p&gt;

&lt;p&gt;EXPORT_C CMyClass* NewPlugin()&lt;br /&gt;
	{&lt;br /&gt;
	return new (ELeave) CMyClass;&lt;br /&gt;
	}&lt;br /&gt;
This is why you look for it at ordinal 1 when you want to use it.&lt;/p&gt;

&lt;p&gt;And you can load the library like this.&lt;/p&gt;

&lt;p&gt;		User::LeaveIfError(library.Load(aPluginName));	&lt;br /&gt;
		// Check second UID is as expected; leave if not&lt;br /&gt;
		if (library.Type()[1] != KDLLUidValue)&lt;br /&gt;
			{&lt;br /&gt;
			User::Leave(KErrGeneral);&lt;br /&gt;
			}&lt;br /&gt;
		TLibraryFunction entry=library.Lookup(1);&lt;br /&gt;
		if(entry)&lt;br /&gt;
			{&lt;br /&gt;
			// Call the function to create new CMyClass&lt;br /&gt;
			CMyClass* iMyClass=(CMyClass*) entry();&lt;br /&gt;
                        .....&lt;br /&gt;
			delete iMyClass;&lt;br /&gt;
			}&lt;/p&gt;

&lt;p&gt;Now you have your class exported. You can have whatever member functions you like in this class, and you can use them trough the iMyClass object.&lt;/p&gt;</description>
 <pubDate>Fri, 28 Sep 2007 09:46:27 +0200</pubDate>
 <dc:creator>filio</dc:creator>
 <guid isPermaLink="false">comment 41880 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-41874</link>
 <description>&lt;p&gt;Hi.&lt;/p&gt;

&lt;p&gt;I have a problem related with this topic but I&#039;m using s60 v3 SDK. I have a DLL which has a function that receives a TInt parameter and then sets a variable with that value. But, when I call the dll&#039;s function from another application and I send a TInt value, it receives an incorrect value. &lt;/p&gt;

&lt;p&gt;Here is the code for my dll&#039;s function where first it displays the received value in a global note and then it sets the variable. For example:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;EXPORT_C void CExampleDll::SetValue(TInt newValue)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _LIT(KListFormat, &amp;quot;%d&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TBuf&amp;lt;10&amp;gt; buf;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf.Format(KListFormat, newValue);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAknGlobalNote* note = CAknGlobalNote::NewLC();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; note-&amp;gt;SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TInt id = note-&amp;gt;ShowNoteL(EAknGlobalTextNote, buf);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; User::After(2000000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; note-&amp;gt;CancelNoteL(id);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CleanupStack::PopAndDestroy(note);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // HERE THE CODE TO SET THE VARIABLE&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Here is the code from the application to call the dll&#039;s function:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;RLibrary lib;&lt;br /&gt;lib.Load(_L(&amp;quot;functionslibrary.dll&amp;quot;));&lt;br /&gt;&lt;br /&gt;typedef void (*TMyFunc)(TInt);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;TMyFunc FSetValue = (TMyFunc)lib.Lookup(1);&lt;br /&gt;TInt y(5);&lt;br /&gt;FSetValue(y);&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;I tried to use the TLibraryEntry instead of create my own typedef function, but it didn&#039;t work too. I also tried to do an static cast to the value received in the dll&#039;s function, but it didn&#039;t work too.&lt;/p&gt;

&lt;p&gt;So, if you had a similar problem, would you tell me please what did you do to solve it?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;</description>
 <pubDate>Thu, 27 Sep 2007 22:40:27 +0200</pubDate>
 <dc:creator>juanaranda</dc:creator>
 <guid isPermaLink="false">comment 41874 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-37277</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;I tried all but it does not work. I will give more details: I use S60 v2 SDK. &lt;br /&gt;I create a dll using the carbide wizard for Microsoft Visual Studio (I tried: New Proyect-&amp;gt;Symbian OS DLL and Symbian OS EXEDLL)and I place de .dll obtained in the c folder of the emulator (C:\Symbian\7.0s\Series60_v20\Epoc32\wins\c).&lt;br /&gt;Then, in my project I do:&lt;br /&gt;RLibrary library;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (library.Load(_L(&amp;quot;dll2602.dll&amp;quot;)) != KErrNone)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TLibraryFunction theFunc = library.Lookup(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iEikonEnv-&amp;gt;InfoMsg(_L(&amp;quot;Open&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAknInformationNote* note = new (ELeave) CAknInformationNote;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;note-&amp;gt;ExecuteLD(_L(&amp;quot;Loaded&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAknInformationNote* note2 = new (ELeave) CAknInformationNote;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;note2-&amp;gt;ExecuteLD(_L(&amp;quot;Not Loaded&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;I do not call the function because the error is in the line:&lt;br /&gt;TLibraryFunction theFunc = library.Lookup(1);&lt;br /&gt;I tried calling the function as Paul explained( typedef TInt (*TMyFunc)(TReal);&lt;br /&gt;TLibraryFunction theFunc = library.Lookup(1);&lt;br /&gt;TInt aux = theFunc()&lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt; but it does not worked, any idea. &lt;br /&gt;Thanks for all&lt;/div&gt;</description>
 <pubDate>Mon, 26 Feb 2007 21:37:40 +0100</pubDate>
 <dc:creator>hibelow</dc:creator>
 <guid isPermaLink="false">comment 37277 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-37276</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;DLL exports (oridinals) start and 1 and not 0.&lt;br /&gt;&lt;br /&gt;Secondly the code is blatently wrong.&lt;br /&gt;&lt;br /&gt;typedef TInt (*TMyFunc)(TReal);&lt;br /&gt;TLibraryFunction theFunc = library.Lookup(1);&lt;br /&gt;TInt aux = theFunc();&lt;br /&gt;&lt;br /&gt;should read&lt;br /&gt;&lt;br /&gt;TMyFunc theFunc = (TMyFunc)library.Lookup(1);&lt;br /&gt;TInt aux = theFunc(1.032);/ / or what ever the real is&lt;/div&gt;</description>
 <pubDate>Tue, 06 Feb 2007 16:27:33 +0100</pubDate>
 <dc:creator>paul</dc:creator>
 <guid isPermaLink="false">comment 37276 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537#comment-37275</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;First of all, you did not specify which SDK you&amp;#039;re using. It might be important as as of Platform Security a DLL does not have to have an E32Dll function.&lt;br /&gt;&lt;br /&gt;Second, even in pre-PlatSec world the aforementioned E32Dll did not have to be &lt;b&gt;exported&lt;/b&gt;. You simply had to use GLDEF_C (and/or maybe GLREF_C). See examples in your SDK.&lt;br /&gt;&lt;br /&gt;Finally, I think your dll should have only one exported method at ordinal &lt;b&gt;0 (zero)&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Hope this helps,&lt;br /&gt;&lt;br /&gt;Tote&lt;/div&gt;</description>
 <pubDate>Tue, 06 Feb 2007 14:20:02 +0100</pubDate>
 <dc:creator>tote</dc:creator>
 <guid isPermaLink="false">comment 37275 at http://www.newlc.com</guid>
</item>
<item>
 <title>Dll lookup error</title>
 <link>http://www.newlc.com/en/topic-17537</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/en/topic-17537&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/en/topic-17537#comments</comments>
 <category domain="http://www.newlc.com/en/forums/symbian-c">Symbian C++</category>
 <pubDate>Mon, 05 Feb 2007 23:36:50 +0100</pubDate>
 <dc:creator>hibelow</dc:creator>
 <guid isPermaLink="false">17062 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
