473,480 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
Nov 17 '05 #1
3 2581
"Gawel" <ga*****@SPAMIKgazeta.pl> wrote in message news:<u4**************@TK2MSFTNGP10.phx.gbl>...
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
....
....
Then If I use object of Terrain class I get
LNK2001: unresolved external symbol "public: __thiscall
Terrain::Terrain(int,int)".

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
Nov 17 '05 #2
> 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


Nov 17 '05 #3
"Gawel" <ga*****@SPAMIKgazeta.pl> wrote in message news:<OB**************@TK2MSFTNGP10.phx.gbl>...
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.


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
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1676
by: .NET developer | last post by:
Hi, I am trying to compile my VC6 application on VC++7. It give following linker error. __declspec(dllimport) public: class ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned...
5
2024
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After...
5
2203
by: Jason W | last post by:
I have a C# class that I wan't to be able to use in VB6 and VBA applications. To do this I was trying to use a mixed managed VC++ dll and export a function. Doing this I get an error "The memory...
2
2400
by: .NET developer | last post by:
Hi , While upgrading my application from vc6 to vc7 I got followin linking errors : __declspec(dllimport) public: class ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class...
1
546
by: hsharsha | last post by:
Consider the below code: extern __declspec(dllimport) int myvariable; template<const int *p> class MyClass{ public: static void myfunction(){ } };
3
12410
by: majestik666 | last post by:
Hi, i'm bulding a multi platform app under windows/linux/osx an i have a bit of trouble exporting c++ symbols from a dynamic library... Under windows, i compile a dll exporting symbols using :...
2
5106
by: Luis | last post by:
Hello... How can I do an exported function in Visual Basic.Net? In Visual C++ the source is the next... but I need the same in VB.Net Thank you /* This is an example of an exported...
1
7271
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
9
8190
by: jjones7947 | last post by:
Am doing a JNI wrap on a C++ API, am using VC7 and Eclipse. In preparation, I created a C++ executable which mimicked the flow of the JNI, i.e. a driver file which called methods in file with methods...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6886
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.