|
You have a exported class, right?
Are you sure you included the header of that class in the test app?
- ns ami -
|
|
|
|
|
I am really sorry for the basics. Could you please tell me how to export and necessary include statements...also if any other settings has to be changed for dll file
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: I am really sorry for the basics
You should study some basics for dll class exporting.
#ifdef DLL_EXPORT
#define DLL_IMPORTEXPORT __declspec(dllexport)
#else
#define DLL_IMPORTEXPORT __declspec(dllimport)
#endif
class DLL_IMPORTEXPORT CMyClass
{
};
And you have to specify the "DLL_EXPORT" in Project > Settings > "Preprocessor definitions"
And in the test app you can just include the header and use. Also you need to specify the lib file of dll. It is available in the Link(tab), Input(catagory) of the project settings. Give the path to the lib in the "Additional library path"
- ns ami -
|
|
|
|
|
When I try to compile the exe project it through an error
fatal error C1083: Cannot open include file:
When I specify the library file of the dll in the exe project, is it the same path as my ...dll_project/debug folder?
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: fatal error C1083: Cannot open include file:
Check yourself the file path and existance of the file.
himangshuS wrote: When I specify the library file of the dll in the exe project, is it the same path as my ...dll_project/debug folder?
Yes, path where your dll's .lib file exists.
- ns ami -
|
|
|
|
|
still the same error...i checked the file existence...it exist in the dll project folder...not in debug,(but dll' main_application folder)....Do i need to copy paste the header files into the application project workspace..I hope not..
I am using vc++ 6 version.
my trest appplication is mfc, and dll is win32 dll
Regards,
Himangshu
modified on Monday, February 2, 2009 5:24 AM
|
|
|
|
|
You have to set the include path in Test App's Project settings > Preprocessor(catagory) > "Additional include directories"
Eg: "../DllProjectFolder/" or "D:/DllProjectFolder/"
And in the source, you can include the header like
#include <dllmyclas.h>
- ns ami -
|
|
|
|
|
Thanks a lot ns ami
It worked,...But, here is another problem exist..
I had to make my class methods as public.(it was giving the error)..And I made it also...Now when I compiled my dll and then compiled the test application its giving error...
error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall <<b>class_name>::<<b>method_name>(void)" (__imp_?method_name@class_name@@QAEHXZ)
Debug/testing.exe : fatal error LNK1120: 1 unresolved externals
I am a learner Always
|
|
|
|
|
I think, the lib is not properly included to the test app project.
- ns ami -
|
|
|
|
|
I have included the path ".....dllproject/Debug"
in the additional library path...
Is there anything else I need to do?
Regards,
Himangshu
I am a learner Always
|
|
|
|
|
i got it right....
I gave/specified the library/module name also...
Thanks a lot anyway...
But here is another problem....My dll uses an another dll...when i run my test application it says" the application failed to initialize properly...." is it the problem of my 3rd party dll?...or what it could be...
Thanks a lot ns ami
I am a learner Always
|
|
|
|
|
Doesn't the message say the module that is missed?
Check the dependencies using "C:\Program Files\Microsoft Visual Studio\COMMON\Tools\DEPENDS.EXE"
If anything is missing then you can identify that.
- ns ami -
|
|
|
|
|
sorry ns ami,
As I said am a beginner. I did not understand dependencies.
What I found out is that it allows me to create a object of a class of dll, but it rises that error when i try to call a method using the object
thanks
I am a learner Always
|
|
|
|
|
You have to check what is done in that function first, before I can help you. Try to debug the code also.
- ns ami -
|
|
|
|
|
Hi again,
If I try to create an object of a class fo dll in my application , no probs. But if I call a member function it shows...
"application failed to initialize properly.click ok to terminate the application"
please help me
Thanks
I am a learner Always
|
|
|
|
|
himangshuS wrote: But if I call a member function it shows
Please read my previous post.
- ns ami -
|
|
|
|
|
Hi ns ami
please help me with. I am not able to go ahead beacuse of that. Could you please give me the steps for the same.
Thanks
I am a learner Always
|
|
|
|
|
Judging by the conversation, you are asking "I have a screwdriver, please tell me how to build a house".
Your question is too big for somebody to type an answer - It would cover pages.
Have look at the following article about DLLs:
http://www.codeproject.com/KB/DLL/dll.aspx[^]
There are many good articles in that category too.
Assuming VS6 (I presume it is similar in later versions) what I would do is:
1/ Make an empty workspace.
2/ Make an exe project in that workspace - but in a subdirectory. Do not compile.
3/ Make an dll project in that workspace - but in a subdirectory. Do not compile.
4/ Make the dll a dependency of the exe.
5/ Go into the project settings of each sub project, and set the output directory to a common directory.
Now compile!
So, I normally have my project settings like this:
Intermediate files (obj's, etc): "Debug"
Output files: (exe's, dll's): "..\Debug"
I hope that gives you enough material to help you google things! I have not given you a magic answer that will solve everything for you in two minutes with no work or research.
Good luck, and please come back with any more specific questions (it will help if you say what version of C++ you are using)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: "I have a screwdriver, please tell me how to build a house"
Iain Clarke wrote: Your question is too big for somebody to type an answer - It would cover pages.
True, I am almost out...
- ns ami -
|
|
|
|
|
ns ami wrote: True, I am almost out...
I noticed it turning into "why?" "why?" "why?" like a chat with a 6yr old skeptic.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I was wondering if there's a way to take a vector of any type into the argument of a function somehow?
So instead of:
showVectorSizeAndContents ( vector<int> v ) it can be of any type, not just int?
Thanks alot
gvanto
[CODE]
/*
* 4_VectorDemo2_InsertDelete.cpp
*
* Created on: 2/02/2009
* Author: pacific
*/
//Vector basics:
#include <iostream>
#include <vector>
using namespace std;
void showVectorSizeAndContents(vector<int> v) { // here i'd like a vector of any type to be passed ...?
unsigned int i = 0;
cout << "Current contents:\n";
cout << "Size = " << v.size() << endl;
// display contents of vector
for(i=0; i<v.size();> cout << v[i] << " ";
}
cout << endl;
cout << endl;
return;
}
int main() {
vector<char> v;
unsigned int i;
for(i = 0; i < 10; i++) {
v.push_back('A' + i);
}
//cant call the show method since it takes vector<int>
}
[/CODE]
|
|
|
|
|
gvanto wrote: I was wondering if there's a way to take a vector of any type into the argument of a function somehow?
Pass the vector as reference or pointer. Check the prototype of showVectorSizeAndContents as follows.
void showVectorSizeAndContents(vector& v)
Read Stephen's answer.
modified on Monday, February 2, 2009 1:21 AM
|
|
|
|
|
Naveen wrote: void showVectorSizeAndContents(vector& v)
Wrong. vector is a template.
- ns ami -
|
|
|
|
|
ns ami wrote: Wrong. vector is a template.
I forgot. Corrected now
Thanks for pointing
|
|
|
|
|
I assume you mean std::vector . If so then try something like this:
template <typename T>
inline void SomeFunction(std::vector<T> &vec)
{
}
Steve
|
|
|
|