|
|
I have 3 projects in workspace.I use VC 6.0.
project DipApi is a win32 static Library
They are all functions.
project CDib is MFC extension DLL,and use DibApi.lib
It will export a class.These is the header file Dib.h of the class,below
#include "..\DibApi\DIBAPI.H"
class AFX_EXT_CLASS CDib : public CObject
{
DECLARE_SERIAL(CDib) //serialization
......
export dll is ok.
CDibEx also is a MFC extension DLL project,use DibApi.lib too,and the upper class.
It will export a class too.These is the header file DibEx.h of the class,below
#include "..\dibapi\dibapi.h"
#include "..\cdib\Dib.h"
//This is the upper header file.I do not know whether to change it.
#define EFFECT_SCANDOWN 1
#define EFFECT_SCANUP 2
#define EFFECT_SCANRIGHT 3
class AFX_EXT_CLASS CDibEx : public CDib
{
DECLARE_SERIAL(CDibEx) //serialization
... ...
but ,when building,VC show:
Creating library Debug/CDibEx.lib and object Debug/CDibEx.exp
DibEx.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass
CDib::classCDib" (?classCDib@CDib@@2UCRuntimeClass@@A)
Debug/CDibEx.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Look for AFX_EXT_CLASS in MSDN.In Export and Import Using AFX_EXT_CLASS,it has
"For example, the DECLARE_DYNAMIC macro is defined as follows when building an extension
DLL:
#define DECLARE_DYNAMIC(class_name) \
protected: \
static CRuntimeClass* PASCAL _GetBaseClass(); \
public: \
static AFX_DATA CRuntimeClass class##class_name; \
virtual CRuntimeClass* GetRuntimeClass() const; \
The line that begins with static AFX_DATA is declaring a static object inside of your
class. To export this class correctly and access the run-time information from a client
executable, you must export this static object. Because the static object is declared with
the modifier AFX_DATA, you only need to define AFX_DATA to be __declspec(dllexport) when
building your DLL and define it as __declspec(dllimport) when building your client
executable. Because AFX_EXT_CLASS is already defined in this way, you just need to
redefine AFX_DATA to be the same as AFX_EXT_CLASS around your class definition.
For example:
#undef AFX_DATA
#define AFX_DATA AFX_EXT_CLASS
class CExampleView : public CView
{
DECLARE_DYNAMIC()
// ... class definition ...
};
#undef AFX_DATA
#define AFX_DATA
"
I am sorry for knowing unclearly,so I did know whether it relate to my problem.
Actually,I want to make two class to dlls respectively.
But I don't know where I was wrong.Please tell me ,thanks a lot!
begtostudy
|
|
|
|
|
http://msdn.microsoft.com/library/en-us/vccore/html/_core_Mutual_Imports.asp
I solved by myself!
|
|
|
|
|
Hello,
I'm don't receive any packet with winsock program.
My code is:
SOCKET RecvSocket,SendSocket;
int ReceiverAddrSize = sizeof(RecvAddr);
RecvSocket = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
SendAddr.sin_family = AF_INET;
SendAddr.sin_port = htons(Port);
SendAddr.sin_addr.s_addr = htonl(INADDR_ANY);
length = recvfrom(RecvSocket, SendBuf, BufLen, 0, (SOCKADDR *) &RecvAddr, &ReceiverAddrSize);
if (length == -1) {
printf("ERRO - RECVFROM\n");
exit(1);
}
Can you help me?
thanks
|
|
|
|
|
I have a multithreaded dll which reads and writes to files. For debugging purposes I would like to switch between multithreaded and singlethreaded from my main app. So I placed the following in the dll code
#ifdef _DLLNOUSETHREAD
LoadMonthThread();
#else
_handle = (HANDLE)_beginthreadex(NULL,0,LoadMonth,this,0,&_threadID);
if (!_handle)
ShowError();
#endif
I was hoping to simple be able to define _DLLNOUSETHREAD in the main exe to be able to switch, but it isn't working like that. The dll always fires a thread. What did I do wrong here?
|
|
|
|
|
are you rebuilding the DLL when you change the #define ?
|
|
|
|
|
What (the other) Chris is trying to say is that preprocessor directives like #ifdef modify how the code is compiled, they do not exist in the final binary (exe or dll).
So, in your example, when you compile the dll _either_ the LoadMonthThread() _or_ the _handle = ... code will be compiled into the dll, not both.
If you replace the: #ifdef, #else, #endif, with: if( SomeDllVar ) {}, else {} then your main app could change SomeDllVar.
... however, you state this is to aid in debugging, i have never seen anyone do this.
Either you need the MT, in which case suck it up (in a friendly sort of way ) and debug the MT dll, or it doesn't need to be MT.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
hello,
i want to extract message number 1800(for example) from xpsp2res.dll (c:\windows\system32\)
the problem is in findsource ;
this is my code
HANDLE handle = NULL;
HRSRC hrsrc;
HRSRC hResLoad;
DWORD dwLongBuff;
char Buffer[MAX_BUFFER_SIZE];
handle=LoadLibrary("C:\\windows\\System32\\xpsp2res.dll");
if (handle==NULL) printf("failure to load"); else printf ("loading ok\n");
hrsrc=FindResource((HMODULE)handle,MAKEINTRESOURCE(1800),RT_MESSAGETABLE);
if (hrsrc==NULL) printf("failure to load2"); else printf ("loading ok2\n");
|
|
|
|
|
I use VC++ 2005 and created a Win32 console application. I got the error messages:
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib
Error 2 fatal error LNK1120: 1 unresolved externals C:\C++ Projects\ImageStore\Debug\ImageStore.exe 1
Here is the code. Thanks in advance!
//Imagestore.cpp
#using <system.dll>
#using <system.data.dll>
using namespace System;
using namespace System::Collections::Generic;
using namespace System::Text;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::IO;
namespace ImageStore
{
private ref class Class1
{
public:
static int Main(array<system::string^> ^args)
{
int errorCode = 0;
Class1 ^oMain = gcnew Class1();
System::String ^sConStr = "Data Source=YANG;Initial Catalog=NorthWind;Integrated Security = True";
int iUserID = Convert::ToInt32(args[0]);
System::String ^sRequestTime = args[1];
System::String ^sImageType = args[2];
System::String ^sFilePath = args[3];
FileInfo ^fi = gcnew FileInfo(sFilePath);
FileStream ^oImg;
BinaryReader ^oBinaryReader;
array<system::byte> ^oImgByteArray;
if (fi->Exists)
{
try
{
oImg = gcnew FileStream(sFilePath, FileMode::Open, FileAccess::Read);
oBinaryReader = gcnew BinaryReader(oImg);
oImgByteArray = oBinaryReader->ReadBytes(safe_cast<int>(oImg->Length));
oBinaryReader->Close();
oImg->Close();
oMain->SaveImage(sConStr, iUserID, sRequestTime, sImageType, oImgByteArray);
}
catch (Exception ^e)
{
Console::WriteLine(e->Message);
}
}
else
{
errorCode = 2;
}
return errorCode;
}
void SaveImage(System::String ^sConnectionString, int iUserID, System::String ^sRequestTime, System::String ^sImageType, array<system::byte> ^oImage)
{
SqlConnection ^oConn = gcnew SqlConnection();
try
{
oConn->ConnectionString = sConnectionString;
oConn->Open();
SqlCommand ^oCmd = gcnew SqlCommand("dbo.qp_SaveImage", oConn);
oCmd->CommandType = CommandType::StoredProcedure;
oCmd->Parameters->Add(gcnew SqlParameter("@iUserID", SqlDbType::Int));
oCmd->Parameters->Add(gcnew SqlParameter("@vcRequestTime", SqlDbType::VarChar, 100));
oCmd->Parameters->Add(gcnew SqlParameter("@vcImageType", SqlDbType::VarChar, 50));
oCmd->Parameters->Add(gcnew SqlParameter("@imImageFile", SqlDbType::Image, 2147483647));
oCmd->Parameters["@iUserID"]->Value = iUserID;
oCmd->Parameters["@vcRequestTime"]->Value = sRequestTime;
oCmd->Parameters["@vcImageType"]->Value = sImageType;
oCmd->Parameters["@imImageFile"]->Value = oImage;
oCmd->ExecuteNonQuery();
}
catch (Exception ^e)
{
Console::WriteLine(e->Message);
}
finally
{
if (oConn->State == ConnectionState::Open)
{
oConn->Close();
}
}
}
};
}
-- modified at 13:02 Friday 18th August, 2006
|
|
|
|
|
If this is managed code, you might try here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I got the same error, LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup, when working on a directx program using VisDev.net (2003). Your version of Visual Dev may be a little different. This worked for me, I hope it helps you.
Going into the project Properties and select the Linker folder then then select Sysem.
See SubSystem option, if it is Console, (/SUBSYSTEM:CONSOLE) try changing it to
Windows (/SUBSYSTEM:WINDOWS).
-
If this doesn’t work you should set it back. Good Luck.
People can be divided into two groups, those with something to learn and fools.
|
|
|
|
|
Hello,
I am trying to send serial port a double value as 8 sets of uint8 by means of union and receiving in the same manner.
For that, im calling read and write functions from an external '.cpp'file through class-object implementation as you see in my code.I use that implementation seperately in transmit and receive functions.
int transmit (double x)
{ union ifas
{
double d;
unsigned char u8value[8]; //uint8
};
union ifas member;
CSyncSerialComm *ObjectCSyncSerialComm; //Object in class from ext.file
ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8");
member.d = x;
printf("\nmember.d=%f\n",member.d);
ObjectCSyncSerialComm.WriteFile(m_hSerialComm, member.u8value, 8, &dwNumberOfBytesWritten, NULL);
delete ObjectCSyncSerialComm ;
return (int) member.u8value;
}
double receive(unsigned char)
{
union aachen
{ double c;
unsigned char u8value[8];
};
union aachen team;
CSyncSerialComm *ObjectCSyncSerialComm;
ObjectCSyncSerialComm = new CSyncSerialComm("0x3F8");
ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
delete ObjectCSyncSerialComm ;
return (double)team.c ;
}
int main(int argc, char* argv[])
{
double var;
unsigned char z;
scanf("%lf",&var);
transmit(var);
receive(z);
return 0;
}
What i want to ask you is, in writing and reading commands i'm receiving syntax errors. If I type both in reading and writing (bold lines),
ObjectCSyncSerialComm.ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
Error==> On the left side of the structure . or .* is required
If I type as follows,
ObjectCSyncSerialComm.*ReadFile(m_hSerialComm, &szBuf, 10, &dwIncommingReadSize, NULL);
Error==> Invalid pointer used.
By the way, im using C++ Builder 6.0 Compiler.
What could be the problem? Any other problem can cause this? I could not find any solution.
Any comment and/or suggestion will be appreciated.Thank you.
Regards,
Cahit
-- modified at 12:01 Friday 18th August, 2006
|
|
|
|
|
ObjectCSyncSerialComm->ReadFile
cje
|
|
|
|
|
I am using Roger Allen Print Preview extension dll to have my print preview screen.
I don't know how to change the orientation of my preview to Landscape.
If Have many pages to show, I don't know how to pass from one page to another. When I clic on next button on the Print Preview screen It's only on the same page.
What to do? to go through pages clicking on next and previous buttons
I learn my self
-- modified at 13:12 Friday 18th August, 2006
|
|
|
|
|
I have a variable of type char*.
How can I convert it to OLECHAR* ??
|
|
|
|
|
An OLECHAR is an unsigned short .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
And how does it answer my question at all??
|
|
|
|
|
Try:
char *name = "Hello";
OLECHAR *ole = A2OLE(name);
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
THANK YOU!!!!!!!!
HAVE A WONDERFUL LIFE!
|
|
|
|
|
|
what about
OLESTR
Tanvon
Tanvon
the brain behind ...
|
|
|
|
|
Hello,
How to retrieve the interface (ethernet) index on windows with winsock?
In Linux i use ioctl function, but in windows i use ioctlsocket, with this code
u_long iMode = 0;
if (ioctlsocket(s, FIONBIO, &iMode) == -1) {
printf("ERROR in ioctlsocket\n");
exit(1);
}
Can you help me?
thanks
-- modified at 11:24 Friday 18th August, 2006
|
|
|
|
|
I am breaking my project up into dlls. Now I have 1 class which I would like to turn into a dll, but there is a little problem. In my origional code, I pass the class a pointer to another class (simply to control a progress bar on the main window). If I do this in the dll I would need to include all the source files for the second class.
Now I only need 3 functions from the second class, what is the best way to go around this problem?
|
|
|
|
|
waldermort wrote: If I do this in the dll I would need to include all the source files for the second class.
It would just need to have the header file for the class included in the area you are using it, and the DLL that is trying to use the other DLL will need to be linked to it.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I already tried that without success. I have 2 classes ClassA and ClassB. ClassA is in the main exe which creates an instance of ClassB which is in the dll. ClassB needs a pointer to classA so that it can adjust a progress bar.
When I include the header file for ClassA, I get unresolved external symbols for the three functions the dll uses (located in the main exe).
|
|
|
|
|