🔒 Locked
using Complex with visual studio
Advertisement
Original Post
When I try to include <Complex> in a C++ file, as in #include "stdafx.h" #include <complex> using namespace std; I get Ellipsometry fatal error LNK1120: 2 unresolved externals Ellipsometry error LNK2020: unresolved token (0A000006) _CxxThrowException Ellipsometry error LNK2020: unresolved token (0A000016) delete I can use other headers, such as <cmath> just fine. When I download code that uses <complex> it compiles fine. I can copy the project file to another, remove the code, and write minr in ti's place, and generally it will work. But if I cut all code from another project that uses <complex> and paste it into mine, It doesn't work. And yes, the header file is there. How do I fix this ?
That's not a compiler error it's a linker error. That isn't anything to do with <complex>
make an empty project with this and tell me what it produces.
|
make an empty project with this and tell me what it produces.
Maybe it is something to do with whether exceptions are enabled in your project. I don't know what environment you're using but there is often an option to enable/disable exceptions. If the code you are copying across uses exceptions then the project it's from will have them enabled. This is quite likely the problem.
Quote:
Original post by PDHB
I get the same problem when I try typing into a class library or a windows project source code.
You need to be a little clearer.
Did you check about the exceptions? It'll probably be in project->settings although I don't have VS 2003 myself.
Yes, Exceptions are enabled.
What I meant was that any time I try to include <complex> in a managed code file I get these link errors. The example of copying someone else's code from a project that worked into mine, where it does not work, was to show that it isn't what I am typing that is causing the problems.
What I meant was that any time I try to include <complex> in a managed code file I get these link errors. The example of copying someone else's code from a project that worked into mine, where it does not work, was to show that it isn't what I am typing that is causing the problems.
std::complex is all in the header file. you don't need to link with anything to make it work.
If you are getting link errors it is because you are using something but haven't told the linker about the libraries it needs to link against.
I searched for the error you are getting and found this at the top of the list of 3 results.
As I say, I don't have VS2003 but I do have [google]. Hope that helps.
Pete
If you are getting link errors it is because you are using something but haven't told the linker about the libraries it needs to link against.
I searched for the error you are getting and found this at the top of the list of 3 results.
Quote:
>>error LNK2020: unresolved token _CxxThrowException
>>error LNK2020: unresolved token delete
Assuming a managed C++ dll, add MSVCRT.LIB (Release) and MSVCRTD.LIB (Debug) to your Linker project settings, under Additional Dependencies. This will fix the unresolved errors
As I say, I don't have VS2003 but I do have [google]. Hope that helps.
Pete
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement