Solved

Unresolved External Symbols - HELP!

Posted on 2004-09-23
16
1,145 Views
Last Modified: 2008-02-01
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
-------------------------------------------------------------------------------
0
Comment
Question by:donfmorrison
  • 5
  • 5
  • 4
  • +1
16 Comments
 
LVL 19

Accepted Solution

by:
drichards earned 150 total points
ID: 12134511
These are C runtime functions that you have used in your managed class.  Change them to use .NET math functions or else you'll have to link against a C runtime library to resolve the references.  The .NET equivalents of these are all in System::Math.  If you need further help, post the lines and I'll show you the equivalents.
0
 
LVL 1

Author Comment

by:donfmorrison
ID: 12134695
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
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12134950
> 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
0
 
LVL 19

Expert Comment

by:drichards
ID: 12135025
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.
0
 
LVL 19

Expert Comment

by:drichards
ID: 12135034
That should read "To use..." instead of "Yo use..."
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12135068
Of course, a typo....
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12135079
Do not mind my comment, I thought the typo was mine.
Maybe I should just go home, too much work is not good :o)
0
 
LVL 1

Author Comment

by:donfmorrison
ID: 12135338
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?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 16

Expert Comment

by:nonubik
ID: 12135434
Do you have a
#using <mscorlib.dll>
line?
0
 
LVL 1

Author Comment

by:donfmorrison
ID: 12135541
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?
0
 
LVL 19

Expert Comment

by:drichards
ID: 12135748
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)?
0
 
LVL 19

Expert Comment

by:drichards
ID: 12135753
Is it sCARLOS and sEMU that are the null references or the internal arrays in thise structures?
0
 
LVL 1

Author Comment

by:donfmorrison
ID: 12136255
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!
0
 

Expert Comment

by:Stator
ID: 12292262
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 ???





0
 
LVL 1

Author Comment

by:donfmorrison
ID: 12292306
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...
0
 

Expert Comment

by:Stator
ID: 12292467
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..




0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
help with SQL 15 117
vc++ 6.0  Gui not loading 12 100
Help needed to format date/time 3 65
Need some help with listview limit text 20 85
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now