Link to home
Start Free TrialLog in
Avatar of donfmorrison
donfmorrison

asked on

Unresolved External Symbols - HELP!

I am writting a managed c++ class to be packaged as a DLL for use in other applications (other c++ or VB.NET).  I have finnaly got most of the problems resolved, but am having diffulclty tracking down the following errors.  I think it is probably just a setting that is missing or set wrong, but am not sure where to find it. It seems related to my math functions from math.h that I used in the program... sqrt(), acos(), tan(), cos(), sin(), ceil().

Thanks to drichards that I have gotten this far!

-------------------------------------------------------------------------------
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl sqrt(double)" (?sqrt@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl acos(double)" (?acos@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl tan(double)" (?tan@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl cos(double)" (?cos@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl sin(double)" (?sin@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl ceil(double)" (?ceil@@$$J0YANN@Z)
ParametricWedge error LNK2001: unresolved external symbol "double __cdecl fabs(double)" (?fabs@@$$J0YANN@Z)
ParametricWedge fatal error LNK1120: 7 unresolved externals
-------------------------------------------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of drichards
drichards

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of donfmorrison
donfmorrison

ASKER

Thanks again.  I got the linking issues resolved now.

I now have a C++ .NET Class Library Project and when I compile and run it asks what .exe to use for the debug session.  what does that mean?  Or do I just simply need to compile this into a DLL now and then use it in my other projects?  How do I make it a DLL and use it in another project?

I really appreciate your help, is there anything you don't know about this language?

I will up the points for this question if you will help me setup the DLL to be used in another project (C++ is fine for now).  I will use this DLL to write a console app which will eventually be replaced by a VB.NET GUI.  Thanks again. I am going to keep this question open for the time being so I can raise the point value...

Don
> now have a C++ .NET Class Library Project and when I compile and run it asks what .exe to use for the debug session.  what does that mean?  
A library cannot run by itself, it does not have a 'main' entry point. It needs to be loaded by another exe.

>Or do I just simply need to compile this into a DLL now and then use it in my other projects?  How do I make it a DLL and use it in another project?
As far as I know, a C++ .NET Class Library Project ends up into a dll file. So no need to do anything
Yo use the library in another .NET project, right click on "References" in the client project in Solution Explorer and say "Add Reference...".  Then select the "Projects" tab and select the library project.  The types defined in the library will now be available to the client project.  If the projects are not in the same solution, you'll have to reference the dll directly - use Browse from the .NET tab of the References dialog.
That should read "To use..." instead of "Yo use..."
Of course, a typo....
Do not mind my comment, I thought the typo was mine.
Maybe I should just go home, too much work is not good :o)
when I instatiate the class (make the object for use) in the client project, I get:

error C3624: 'System::Object': the compiler cannot find this type; it is defined in the assembly 'mscorlib'

when I click on the error, it send me to the line that I instatiated the object on.

      ParametricWedge *pWedge = new ParametricWedge();

Is there something I am missing?
Do you have a
#using <mscorlib.dll>
line?
Whoa. I am dumb.  

I am still new to this whole .NET structure and "mananged" programming.  Thanks.

I have one more question then.  When I run the client program I get the following debug error in the middle of execution.

--------------------------------------------------------------------------
An unhandled exception of type 'System.NullReferenceException' occurred in parametricwedge.dll

Additional information: Object reference not set to an instance of an object
--------------------------------------------------------------------------

I assume this is because I forgot to create of instance of an object somewhere. When I set a breakpoint I can see that there are two objects which didnt get initialized inside my DLL.  I wonder why the compiler didnt catch this before, but its not important.  

How do I creat those objects...they are declared as follows in my class:

--------------------------------------------------------------------------
public __gc struct sCARLOS {
...
}

public __gc struct sEMU {
...
}
--------------------------------------------------------------------------

Then created initiallay as a pointer:
     sEMU    *EMU;
     sCARLOS *CARLOS;

I have tried using:

CARLOS = new sCARLOS;
EMU = new sEMU;

But the compiler in my DLL does not like that very much.  Any ideas?
What error do you get.  That works when I try it.  Is the type visible where youare going the 'new' (have you #included the header)?
Is it sCARLOS and sEMU that are the null references or the internal arrays in thise structures?
I got it working now.  

Its amazing what actually testing the newer version does, instead of just assuming the same error that was there 1.5 hours ago is still there.

Thanks for the help!
Hello,

I have the same problem in .

Main App (MFC C++ Project) and a C++ library in one solution, but on the line of a main App where I try to create an instance of a class defined in .dll library:

function_xyz ()
{
// CPPClass is a class defined in a namespace CPPLibrary in a class library project (.dll)

CPPClass instance1 = new CPPClass();
}

i get:  

error C2065: 'CPPClass' : undeclared identifier

I added references as described above, ...nothing changed.

Can anyone help ???





If you already added a refence to this DLL in your project, then make sure you included the namespace for the CPPClass as well

using namespace CPPLibrary;

should do the trick, I think.  If this is already done and still no go, then I think we may need a little more information.  

You might have good luck to post a question on the forum, which would be an active thread that the Experts would take a look at.  This thread is closed and thus no longer seen by very many people.  Hope you get what you need...
It did not help, but anyway...thanks....

I am going to put this question into forum as a new question.

Bye an d thanks again..