Solved

simple debugging of a dll/activeX

Posted on 2000-03-23
10
447 Views
Last Modified: 2013-12-14
I have some C++ code that gets compiled into an ActiveX, and run from within a larger program.  My code needs debugging - what is the best way to ouput some logging information?  Is writing to an external file the simplest approach?  How would I do this?

I tried just doing
    cout << "The 'all' string: " << endl;
but got
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2872: 'cout' : ambiguous symbol

Why these errors?  My includes are
#include "stdafx.h"
#include <iostream>
#include <list>
#include <string>
#include<vector>
#include <ctype.h>
using namespace std;

Its probably better I output to a file anyway.  Or to a console?
I am using VC++6
0
Comment
Question by:abulka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2651864
>>  My code needs debugging
You aren't at the debugging stage, your code isn't even compiling.  First you have to make it compile, then if it doesn't run right, you have to debug it.  Right now it can'be run because it doesn't compile.

in

cout << "The 'all' string: " << endl;

you can't just have a single quote inside a string.  You must palce a \ character before the quote to signal the compiler that you want a single quote to appear in the string, like

cout << "The \'all\' string: " << endl;

If that doesn't fix the problem, you need to post more of the code.
0
 

Author Comment

by:abulka
ID: 2651970
Adjusted points from 20 to 25
0
 

Author Comment

by:abulka
ID: 2651971
The cout << .... code was just included as a potential way of generating debug output.  The question is about the best way of doing that given my context.  I'm happy to forget about using cout << ... and get some code which deals with writing to a file, for example.

P.s. Even
  cout << "got to this point" << endl;
doesn't compile e.g.
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2872: 'cout' : ambiguous symbol
Error executing cl.exe.

The point
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
tomkeane earned 25 total points
ID: 2652214
You can debug the dll directly.  Go to Project Settings->Debug tab.  In the field "Executable for debug session" put in the path to an executable that loads your dll.  The application can be any executable, it does not have to be a program you have source code to.  Set the breakpoints in your dll where you and hit F5.

HTH,

Tom
0
 

Author Comment

by:abulka
ID: 2652327
I'd love to debug 'live' - will this above technique work when my dll is an activeX?  The main app is a delphi app which loads some activeX's which then load my VC++ active X.

0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2652380
I can't think of any reason why it would not work.  It doesn't really matter what the exe is - as long as it loads your dll and makes calls into it.  It doesn't really matter whether it is loading your dll via implicit linking, by using LoadLibrary, or through a call to COM.

Tom
0
 

Author Comment

by:abulka
ID: 2652582
tomkeane - it worked - unbelievable.  thanks.  Just one last question before I accept:  When I exit my app I get an exception violation/crash at some address in my dll.  The source code does not come up for me though - so I'm in the dark as to where it is crashing... Any idea on getting the debugger to show me?

thanks
0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2652617
Hmmmmm.  Those can be tough.  The first thing I'd try would be setting breakpoints on functions in your dll that get called right at the end of its life.  For an ActiveX dll you could try any or all of the following: The Release method of your object, your COM object's destructor, your dll's DllCanUnloadNow() function, your dll's DllMain() function.
You also might want to take a look at any static or file scope objects you have, if any.
Is this something that only happens when you run it in the debugger, or does it also happen if you launch the program normally?  If it only happens in the debugger it may be that DevStudio and the Delphi runtime are disagreeing about something....

Tom
0
 

Author Comment

by:abulka
ID: 2655903
Thanks.

By the way, I also found a way to do debug logging:

#include <iostream>
#include <fstream>

    std::ofstream  zout("e:/debuglog.txt");
    zout << "Hello, world\n";
    zout << "RectWidth is " << RectWidth << "\n";
    zout << endl;
0
 
LVL 22

Expert Comment

by:nietod
ID: 2656418
>> I also found a way to do debug logging:
You might find that using OutputDebugString() is even better for this.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question