|
Hi Stuart,
I have tried that if I only mark dllexport on class and not on methods, the methods could not be found during link process.
So, I think we have to mark both. Could you have a try please?
regards,
George
|
|
|
|
|
I have an awful lot of deployed code that uses this mechanism - here's a sample:
#if!defined(COMMONLIB_API)
#ifdef COMMONLIB_EXPORTS
#define COMMONLIB_API __declspec(dllexport)
#else
#define COMMONLIB_API __declspec(dllimport)
#endif
#endif
namespace MyAppLibrary {
class MessageReporter {
public:
COMMONLIB_API MessageReporter();
COMMONLIB_API static void AddReportFunction(ReportFnPtr func);
COMMONLIB_API static void SetReporterLevel(Level lev, bool on);
COMMONLIB_API static void AllLevelsOn() {repLevels=~0;}
COMMONLIB_API static void AllLevelsOff() {repLevels=0;}
};
};
Is it possible you haven't exported necessary constructors?
|
|
|
|
|
But if you only expose class not expose methods, the methods could not be found when linking the client of the DLL (link error, unresolved symbols related to the methods).
Could you have a try? I have tried.
regards,
George
|
|
|
|
|
DLL interface defined in a.h
a.h
#if !defined(__A_H__)
#define __A_H__
#if!defined(A_API)
#ifdef A_EXPORTS
#define A_API __declspec(dllexport)
#else
#define A_API __declspec(dllimport)
#endif
#endif
class A_API A
{
public:
A();
A(int a);
void DoSomething(int b);
int Result() const;
private:
int a_;
};
#endif // !defined(__A_H__)
DLL implemented in a.cpp and built with cl -EHsc -LD a.cpp
a.cpp
#include <windows.h>
#define A_EXPORTS
#include "a.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
A::A() : a_(0) {}
A::A(int a) : a_(a) {}
void A::DoSomething(int b) { a_ += b; }
int A::Result() const { return a_; }
DLL used in b.cpp, built with cl -EHsc b.cpp a.lib :
b.cpp
#include <iostream>
#include "a.h"
int main(int argc, char** argv)
{
A a(argc);
a.DoSomething(3);
std::cout << a.Result() << std::endl;
}
Builds fine, runs OK and even produces the right result...which is nice.
modified on Saturday, December 20, 2008 6:19 AM
|
|
|
|
|
Cool, Stuart!
regards,
George
|
|
|
|
|
You've got two issues:
- In
main.cpp , you want to declare CFoo as __declspec(dllimport) . The way I do that is to put something like this in foo.h :
#if !defined(FOO_DLL)
#define FOO_EXP __declspec(dllimport)
#else
#define FOO_EXP __declspec(dllexport)
#endif
class FOO_EXP CFoo { ... };
You would define FOO_DLL when building the DLL using, for example, #define FOO_DLL in every source file in the DLL before #includ ing foo.h . You need do nothing in main.cpp>/code>, as that's what the default case caters for. - As other replies have said, you would need to export
CFoo foo; from the DLL.
|
|
|
|
|
|
I have created a SDI application with a Form view. In the form view ihave inserted a property sheet like this...
void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
m_PropSheet.AddPage(&m_Page1);
m_PropSheet.AddPage(&m_Page2);
m_PropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0);
m_PropSheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
m_PropSheet.ModifyStyle( 0, WS_TABSTOP );
m_bViewInitiated = true;
}
I wanted the property sheet to span the whole area of the form view, so i have written few line for that as...
void CMyFormView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
if(m_bViewInitiated)
{
m_PropSheet.SetWindowPos((CWnd*)this, 0, 0, cx, cy,SWP_NOZORDER | SWP_NOACTIVATE );
}
}
But the property sheet is not behaving as i expected. Its size remains same as the property pages sizes given at the creation time.
Can you help me with this...
Thank you
Tritva
modified on Monday, December 15, 2008 5:33 AM
|
|
|
|
|
Hi,
I am writing an utility dll like dependency walker. I have no idea how to get dependent dll. Any idea about this.
Thanks
|
|
|
|
|
manish rastogi wrote: I am writing an utility dll like dependency walker. I have no idea how to get dependent dll.
It looks like a good kick off!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Have a look at Process Viewer[^]. It contains almost everything you want.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
You can find out what DLL's are implicitly linked to the DLL or EXE by reading the PE import table.
Thanks & Regards,
K. Sushilkumar.
|
|
|
|
|
Hi All
I am useing VISTA and Marking try to set required Privileges Using an Application Manifest.I am useing Manifestthis.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86" name="AdminApp" type="win32"/>
<description>Description of your application</description>
<!-- Identify the application security requirements. -->
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
<ms_asmv2:security>
<ms_asmv2:requestedPrivileges>
<ms_asmv2:requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</ms_asmv2:requestedPrivileges>
</ms_asmv2:security>
</ms_asmv2:trustInfo>
</assembly>
I add this file in debug folder with the same name of exe.But it's not effect on application.So plz help me how i add this Manifest in application.
|
|
|
|
|
What version of visual studio are you using?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
|
|
|
What about documentation [^]?
BTW: you possibly need conversion to wchar_t * (not to char * ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi, thanks for replying
I've looked through that before, but it doesn't seem to touch on much about my case though. Yeah, wchar_t* seems more convenient, but I'm actually linking these to other DLL files, and the only input type to those is const char*, this I can't change. You have any idea about this conversion code?
|
|
|
|
|
rukawa84 wrote: wchar_t* seems more convenient, but I'm actually linking these to other DLL files, and the only input type to those is const char*, this I can't change. You have any idea about this conversion code?
If the DLL 's functions accept only ASCII strings you're lost: how can you pass Chinese characters?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hmm, sorry I'm not too good in this area. You mean const char* type can only store ASCII? I've tried like declaring const char* variables, initialised them to some chinese words and sent them in and it works fine. I'm not sure how the other DLL works as it's not created by me, but if I find a way to convert the jstring input to char*, I'm sure it'll work out.
|
|
|
|
|
This page [^] has some examples.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the link, I'll take a look and try again.
|
|
|
|
|
Hi all,
I need a help relatd to removing the part of string
std::string bDesc ="hi how(Temp) are(Temp) you.i am(Temp) Great"
int p=bDesc.find("(",0);
int j=bDesc.find(")",0);
if(p>0 && j>0)
{
bDesc.erase(p,j);
}
from above string i want to remove (Temp) but i am able to remove only once .. do i need to loop through each character.....
can some body help me...
vikas da
|
|
|
|