Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

Problem with __declspec(dllexport)/__declspec(dllimport) in mixed assembly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gawel - 23 Jun 2004 00:56 GMT
Hajo,
I have two dlls, both of them are compiled with /clr switch.
In first dll project I have managed and unmanaged classes.
One of the unmanaged I would like to use outside therefore
I marked it as follows:
class __declspec(dllexport) Terrain
{
   public:
       void foo(){}
};

In sceond dll projcet I added refrenece to the first dll and
included header like this:
class __declspec(dllimport) Terrain
{
   public:
       void foo();
};

Then If I use object of Terrain class  I get
LNK2001: unresolved external symbol "public: __thiscall
Terrain::Terrain(int,int)".

Any idea ?

thanks in advance

Gawel

--
Gawel
-------------------------------
Pierwszy ?yk z pucharu nauk przyrodniczych czyni ateist?, ale na dnie
pucharu czeka B?g.
Werner Heisenberg
Vinayak Raghuvamshi - 23 Jun 2004 16:08 GMT
> Hajo,
> I have two dlls, both of them are compiled with /clr switch.
[quoted text clipped - 7 lines]
>
> Any idea ?

when you built your first dll, visual studio linker would have
generated a .lib file as well.. you need to include this in your
second dll through the project-settings->linker->input->additional
dependencies

hth.
-Vinayak
Gawel - 23 Jun 2004 16:49 GMT
> when you built your first dll, visual studio linker would have
> generated a .lib file as well.. you need to include this in your
> second dll through the project-settings->linker->input->additional
> dependencies

Thanks, it works.
But I have two more questions.
If I add *.lib file to additonal dependencies then __declspec( dllimport )
in the second project
isn't needed any more.  What's more If I have *.lib file I don't need *.dll
file of first project.
It seems that your solution bases on static library not on dynamic one.
I am glad that you solved my problem but I am still curious how to get
the same effect but with dlls.

Once again thanks

Gawel
Vinayak Raghuvamshi - 28 Jun 2004 01:58 GMT
> > when you built your first dll, visual studio linker would have
> > generated a .lib file as well.. you need to include this in your
[quoted text clipped - 7 lines]
> isn't needed any more.  What's more If I have *.lib file I don't need *.dll
> file of first project.

That is not correct. Why don't you try deleting the .dll and then see
if your application still launches?

> It seems that your solution bases on static library not on dynamic one.

Just because a file is a .lib does not mean you are using "static
linkage".

the .lib in this instance is just a skeleton that defines the entry
points that the loader will then load from the dll at runtime.

I would suggest that you read up on fundamentals of dlls, libs and how
they work. MSDN has a few good links that you can pursue....

-Vinayak

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.