<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Creating dll which links another dll' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Creating dll which links another dll' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 19:36:25 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 19:36:25 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Creating dll which links another dll</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/356052/356052/creating-dll-which-links-another-dll/</link>
      <description>Hi, I'm trying to create a dll which uses a class defined in another dll.&lt;br /&gt;
&lt;br /&gt;
I'm using dev-cpp 4.9.9.2 with the default compiler.&lt;br /&gt;
I can use the dll when I'm building an exe file but i'm unable to link this dll when building an dll file.&lt;br /&gt;
&lt;br /&gt;
I've added the library in the linker window in the project options, and included the header file. But in the compiler log I can't find any reference to the library.&lt;br /&gt;
&lt;br /&gt;
log&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Sideshore\Desktop\programmeren\c++\New BoardDesign\dll-generalfunctions\Makefile.win"
Executing  make clean
rm -f Functions.o  GNRFunctions.dll
g++.exe -c Functions.cpp -o Functions.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -DBUILDING_DLL=1  
Functions.cpp: In function `double Interpolated2d(double**, int, double, int, int, bool)':
Functions.cpp:70: warning: passing `double' for converting 1 of `int abs(int)'
Functions.cpp: In function `int Round(double)':
Functions.cpp:133: warning: converting to `int' from `double'
Functions.cpp:135: warning: converting to `int' from `double'
Functions.cpp: In function `double** GetFrame(double**, int, double**, int, double**, int, double**, int, double**, int, double**, int, double**, int, double**, int, double, int)':
Functions.cpp:295: error: `CBSpline' undeclared (first use this function)
Functions.cpp:295: error: (Each undeclared identifier is reported only once for each function it appears in.)
Functions.cpp:295: error: expected `;' before "Curve"
Functions.cpp:296: error: `Curve' undeclared (first use this function)
Functions.cpp: In function `double** GetFrameSimple(double**, int, double**, int, double**, int, double**, int, double**, int, double**, int, double, int)':
Functions.cpp:537: error: `CBSpline' undeclared (first use this function)
Functions.cpp:537: error: expected `;' before "Curve"
Functions.cpp:538: error: `Curve' undeclared (first use this function)
make.exe: *** [Functions.o] Error 1
Execution terminated
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I also tried to use Loadlibrary but that doesn't work neither&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
HMODULE hMod = LoadLibrary("Curves.dll");
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/356052/356052/creating-dll-which-links-another-dll/</guid>
      <pubDate>Thu, 15 Mar 2007 04:47:19 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Creating dll which links another dll</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/356052/356073/re-creating-dll-which-links-another-dll/#356073</link>
      <description>I'm no gcc expert, but at least I can tell you that LoadLibrary should work. What do you mean with "doesn't work", do you get an incorrect return value or...? Further, it returns HINSTANCE and not HMODULE, but I suspect they are pretty much the same, so it should work even though a C++ compiler should give you typecast warnings.&lt;br /&gt;
&lt;br /&gt;
Btw those long function prototypes are really ugly. If you wrote the DLL source you should replace them with a pointer to a struct. That will not only make the code readable but also increase the performance of the program since you don't have to slaughter the stack at every function call.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/356052/356073/re-creating-dll-which-links-another-dll/#356073</guid>
      <pubDate>Thu, 15 Mar 2007 07:48:18 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Creating dll which links another dll</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/356052/356117/re-creating-dll-which-links-another-dll/#356117</link>
      <description>Thank you for your reply!&lt;br /&gt;
&lt;br /&gt;
Well loadlibrary does load the dll but I wasn't able to use the class from the dll. Yesterday I found this page: &lt;a href="http://www.codeproject.com/dll/classesexportedusingLL.asp"&gt;http://www.codeproject.com/dll/classesexportedusingLL.asp&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
It explains how to use classes from a dll with loadlibrary. But it also warns about it's use because it sort of a hack.&lt;br /&gt;
&lt;br /&gt;
I much rather link the library implicitly it's much cleaner (in the code) and easier (if it works &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt; ).&lt;br /&gt;
But as said earlier I think dev-cpp doesn't add link the dll in the commandline for the compiler. I think it has something to do with the DBUILDING_DLL=1  option.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I'm not very familiar with structs until now I just made my programs with classes and functions. Just started to use dll's. Can you give an example of a pointer to a struct? (or maybe a link)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/356052/356117/re-creating-dll-which-links-another-dll/#356117</guid>
      <pubDate>Fri, 16 Mar 2007 04:02:53 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Creating dll which links another dll</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/356052/356240/re-creating-dll-which-links-another-dll/#356240</link>
      <description>: Thank you for your reply!&lt;br /&gt;
: &lt;br /&gt;
: Well loadlibrary does load the dll but I wasn't able to use the class from the dll. Yesterday I found this page: &lt;a href="http://www.codeproject.com/dll/classesexportedusingLL.asp"&gt;http://www.codeproject.com/dll/classesexportedusingLL.asp&lt;/a&gt;&lt;br /&gt;
: &lt;br /&gt;
: It explains how to use classes from a dll with loadlibrary. But it also warns about it's use because it sort of a hack.&lt;br /&gt;
: &lt;br /&gt;
: I much rather link the library implicitly it's much cleaner (in the code) and easier (if it works &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt; ).&lt;br /&gt;
: But as said earlier I think dev-cpp doesn't add link the dll in the commandline for the compiler. I think it has something to do with the DBUILDING_DLL=1  option.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: I'm not very familiar with structs until now I just made my programs with classes and functions. Just started to use dll's. Can you give an example of a pointer to a struct? (or maybe a link)&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I don't know how to link it implicitly in gcc but if you wrote the code yourself you could perhaps link it as a .lib instead.&lt;br /&gt;
&lt;br /&gt;
Classes inside dll:s are probably painful since dll:s were invented before C++. I don't have any experience about that myself, but somekind of wrapper function to access the class sounds safer and cleaner than hackish, inline asm. Also note that the example from Codeproject is using non-standard inline asm. Correct syntax in C++ is&lt;br /&gt;
&lt;br /&gt;
asm ("NOP");&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
Not sure what you are after when it comes to structs, but here is an example of structs and pointers:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct
{
  int x;
  double y;
} MyStruct;

...

MyStruct ms;
MyStruct* ptr = &amp;amp;ms;

ptr-&amp;gt;x = something;  // access the element pointed at by the struct

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The main difference is that a pointer-to-struct uses the -&amp;gt; operator rather than the . operator. In C++, structs are allowed to use constructors, operator overloading etc making them similar to public classes, though not backwards-compatible with C.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/356052/356240/re-creating-dll-which-links-another-dll/#356240</guid>
      <pubDate>Mon, 19 Mar 2007 05:18:48 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>