|
Good Morning Niklas
I tried deleting and re-adding the files but it made no difference.
Thanks for the suggestion.
I also used to be able to fix this type of problem in VS6. But seems to be difficault to fix in VS2008. Theres probley a simple answer out there somewhere.
Desmond Mardle
|
|
|
|
|
Hello folks!
Do you happen to know any method of dumping the call stack to the output window of VS or maybe to a log file during runtime (only in a debug run with debugger present of course)? I mean, somethging like, placing a __DUMP_CALL_STACK_HERE__ macro in a method of a class dumping the callstack whenever it is called or such? It would be very useful sometimes, i doubt it is possible, but i thought i ask the more experienced people. (Ah, and another thing, we are using VS2003 (v7.1))
Thanks in advance,
Code-o-mat
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
This message[^] will point you to a resource that'll help you get the call stack. You can then dump that as you want.
Alternatively, I'm pretty sure this CP article[^] has stack trace code in it as well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, i'll check these out.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
In my project, I have an .cpp file which contains a set of utility functions like TrimMyString() etc which could be called a lot of times.
I have made these functions global and included the .cpp file in places where I call these utility functions.
When I call these global methods from another function in my user defined class (say I want to trim a character array in one of my user defined class functions), I am getting a linking error
"fatal error LNK1169: one or more multiple defined symobls found".
However, when I make them global and static by including the static keyword, then this error no longer exists and every thing works perfectly.
How do i make this a non-static global function because this is what the current requirment is?
Thanks.
|
|
|
|
|
Comp_Users wrote: I have an .cpp file which contains a set of utility functions like TrimMyString() etc which could be called a lot of times.
I assume you have declared its prototypes in a header file, and are using it wherever that function in needed , isn't it ?
|
|
|
|
|
No. I am not.
I just have the global function body in the .cpp file and including this file in places where I am calling it.
|
|
|
|
|
Comp_Users wrote: I just have the global function body in the .cpp file and including this file in places where I am calling it.
You should not include cpp file in other files. Do , what I said in my first post.
|
|
|
|
|
Tried what you asked me to do.
Created a new .h file and added the function declarations in the global space in the .h file and in the utility .cpp file, included this newly created .h file.
Now in the .cpp file where i am calling these utility functions, I have included the newly added .h file. But the error still persists.
These are the exact error messages.
1>XMLLoader.obj : error LNK2005: "void __cdecl TrimString(wchar_t *)" (?TrimString@@YAXPA_W@Z) already defined in UtilityFunctions.obj
1>Output/Sample.dll : fatal error LNK1169: one or more multiply defined symbols found
|
|
|
|
|
Did you put include guards[^] in your header file ? Otherwise it will be included multiple times.
|
|
|
|
|
Comp_Users wrote: I just have the global function body in the .cpp file and including this file in places where I am calling it.
You really need a good C tutorial.
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]
|
|
|
|
|
Could you please tell me as to what is causing this to happen?
Is it the way I am calling an global function?
Pls help.
|
|
|
|
|
Comp_Users wrote: Could you please tell me as to what is causing this to happen?
The linker is telling you exactly what the problem is.
You need to put the function declarations in a .h file like:
#if !defined(ABC123)
#define ABC123
#pragma once
int TrimMyString();
int PaintMyHouse();
int SellMyStock();
#endif You need to put the function definitions in a .cpp file. Make sure both files are added to the project. Then in any file that will be using those functions, simply #include the .h file near the top.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Others have beaten you over the head with it, so I'll join in. You DON'T include cpp files - you include headers.
Try:
extern CString TrimMyString (CString s);
#include "stdafx.h"
#include "TrimMyString.h"
CString TrimMyString (CString s)
{
do stuff with the string...
return s;
}
#include "stdafx.h"
#include <some.h>
#include "Other.h"
#include "TrimMyString.h"
BOOL SomeFunction ()
{
s = " Hello ";
s = TrimMyString (s);
return TRUE;
}
</some.h>
I hope that made a little sense,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I have done exactly the same.
But inspite of this, I keep getting the same link error.
I am using VC++ project.
|
|
|
|
|
Problem solved.
It was the exact problem that you guys had rigthly pointed out.
Thanks a lot.
|
|
|
|
|
Hi there.
I have a DLL that was being created in C#.net with an exported class/functions.
Now, I want to call exported class/functions mentioned above from my code C++ code.
Just an add-on, Can I access all the c# exported classes in C++ console application? If Yes, the please provide pointers/sample code on this.
Thanks and Regards
PanB
modified on Tuesday, February 10, 2009 8:26 AM
|
|
|
|
|
PankajB wrote: Can I access all the c# exported classes in C++ console application?
No. However you can use a .NET class library assembly from a Managed or Mixed Mode C++/CLI project. CodeProject has an entire forum on the subject called Managed C++/CLI
|
|
|
|
|
|
UpdateAllViews() will update all views.
How to update single view?
|
|
|
|
|
Me think you will need to have a pointer of some sort to that view in order to update it.
or you could iterate (see CDocument::GetFirstViewPosition and CDocument::GetNextView and CView::OnUpdate ) the views in your application and decide if one view needs updating.
The way you decide if a view needs to be updating is up to you and not framework dependent (AFAIK).
This signature was proudly tested on animals.
|
|
|
|
|
KASR1 wrote: UpdateAllViews() will update all views.
How to update single view?
This function does not do any updating. It merely calls the OnUpdate() member function for each of the document’s views except the sending view, passing pHint and lHint . You need to specify a specific lHint value so that the single view will know it needs to update itself.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello,
my Name is Harry Diel and I’m a Software-Engineer (Development) here in Germany.
A couple of years ago (2000-2005) I developed for a Medical-Assosiation under Windows XP and Server 2003 with MFC und Visual C 6.0 a LAN-Manager System with some RPC-programs, which where running as services on several clients, in a large System-LAN environment with more than 1500 installed workstations (NT/XP), Printern and over 200 Servers with Windows 2003 / NT. everything was OK, until now the first Windows Vista will be used.
The Time has come to upgrade to Windows Vista !!!!
Now I updated my C-Programs to Visual C++ 9.0 and VS 2008. The functionalities of the program were still the same, nothing changed. But now I get from the StartServiceCtrlDispatcher Function always the Error-Code “1063” =
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. (Only when the service starts on Windows Vista).
I need help, what can I do. I tried everything, but nothing works and helps realy.
Enclosed you will find a piece of my Program-Code of the C++ program, when the service should start working. But it stops!!!!
Maybe you can send me an example for Windows Vista how it would work.
I am waiting for an answer. Thank you.
regards
harry Diel,
47475 Kamp-Lintfort, Germany
E-Mail: harry.diel@t-online.de
1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 int Win_RemComServiceMain (void)
3 { ///////////////////////////////////////////////////////////////////////////////
4 sprintf (szOpenFName,"%s","C:\\Temp\\RemComLogDatei.log");
5 hOpenF = CreateFile (szOpenFName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,
6 NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
7
8 if (hOpenF == (HANDLE)ERROR)
9 { hOpenF = NULL;
10 }
11 ///////////////////////////////////////////////////////////////////////////////
12 _GetDateAndTime();
13 sprintf(sWrkBuff,"%.6s | %s\tWin_RemComServiceMain\t: LogFile gestartet.%s",ActDatum, sCurrTime, EOR);
14 WriteErrorText_2 (sWrkBuff);
15 ///////////////////////////////////////////////////////////////////////////////
16 // Register the service control handler
17 g_hstatus = RegisterServiceCtrlHandler(REMC_SERVICENAME, ServiceCtrl);
18 if (g_hstatus == 0)
19 return FALSE;
20
21 // Setzen einiger Service-Standard Status-Values
22 g_ServiceMode = TRUE;
23 SetProcessShutdownParameters(0x100, 0);
24
25 // Erstelle einen Service Tabellen-Eintrag
26 SERVICE_TABLE_ENTRY dispatchTable[] =
27 { {REMC_SERVICENAME, (LPSERVICE_MAIN_FUNCTION) RemComDoService},
28 {NULL, NULL}
29 };
30 ///////////////////////////////////////////////////////////////////////////////
31 _GetDateAndTime();
32 sprintf(sWrkBuff,"%.6s | %s\tStartServiceCtrlDispatcher\t%s%s",ActDatum, sCurrTime, REMC_SERVICENAME, EOR);
33 WriteErrorText_2 (sWrkBuff);
34
35 // Aufrufen des Service-Control-Dispatcher mit unserem Tabellen-Eintrag
36 bRetc = StartServiceCtrlDispatcher(dispatchTable);
37 if (bRetc == TRUE)
38 { return TRUE;
39 }
40 SvcError = GetLastError();
41 if (SvcError == ERROR_SERVICE_ALREADY_RUNNING)
42 return TRUE;
43 else
44 { _GetDateAndTime();
45 sprintf(sWrkBuff,"%.6s | %s\tStartServiceCtrlDispatcher\tFehler = %d%s",ActDatum, sCurrTime, SvcError, EOR);
46 WriteErrorText_2 (sWrkBuff);
47 return FALSE;
48 }
49 }
50
51 ///////////////////////////////////////////////////////////////////////////////////
52 // RemComService Main-Routines
53 ///////////////////////////////////////////////////////////////////////////////////
54 BOOL WINAPI RemComDoService (DWORD argc, char **argv)
55 {
56 // Setzen einiger Service-Standard Status-Values
57 g_srvstatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS;
58 g_srvstatus.dwServiceSpecificExitCode = 0;
59 // Give this status to the SCM
60
61 if (!ReportStatus (SERVICE_START_PENDING, NO_ERROR, 15000))
62 { ReportStatus (SERVICE_STOPPED, g_error, 0);
63 return FALSE;
64 }
65
66 hRemCThread = CreateThread (&SecAttributes, NULL,
67 (LPTHREAD_START_ROUTINE) RemComServiceThread,
68 NULL,
69 NULL,
70 &dwThreadId);
71 ///////////////////////////////////////////////////////////////////////////////
72 _GetDateAndTime();
73 sprintf(sWrkBuff,"%.6s | %s\tRemComDoService\tCreateThread OK.%s",ActDatum, sCurrTime, EOR);
74 WriteErrorText_2 (sWrkBuff);
75 return TRUE;
76 }
77
78 ///////////////////////////////////////////////////////////////////////////////////
79 // Service Start-Routine - Thread that calls WinVNCAppMain
80 ///////////////////////////////////////////////////////////////////////////////////
81 BOOL RemComServiceThread (void *arg)
82 {
83 g_servicethread = GetCurrentThreadId();
84
85 bRetc = ReportStatus (SERVICE_RUNNING, NO_ERROR, 0);
86 if (bRetc != TRUE)
87 return FALSE;
88
89 ///////////////////////////////////////////////////////////////////////////////
90 _GetDateAndTime();
91 sprintf(sWrkBuff,"%.6s | %s\tRemComServiceThread\tgestartet: Service_Running -> Call DoModal()%s",ActDatum, sCurrTime, EOR);
92 WriteErrorText_2 (sWrkBuff);
93
94 // The Service should start the Dialog !
95 AfxEnableControlContainer();
96 pRemCService->DoModal();
97
98 // Wir laufen nicht mehr ....
99 g_servicethread = NULL;
100
101 ReportStatus (SERVICE_STOPPED, g_error, 0);
102 return TRUE;
103 }
104
105 ///////////////////////////////////////////////////////////////////////////////
106 ///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
what privileges do you run the application with....
You should be an Admin...Vista has some issues that are to be dealt with regarding the admin privileges and running applications under it
Did you try running the service when you are logged in as a local admin?
****************Also check the firewall..... on the Vista Machine
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Tuesday, February 10, 2009 6:59 AM
|
|
|
|
|
Hello,
thank you for your E-Mail.
But I checked everything. My account has all administrator-rights.
When the service starts, it starts under the system-account and this is always an admin.
I checked the firewall and the program is already configured, to go thru.
I think, there's some mistake in the Vista System-Control-Manager.
It works correctly under XP and NT and 2003.
Thank you.
regards
Harry Diel
|
|
|
|
|