Solved

C++ CLI -- link errors ... which constructor can't it find?

Posted on 2009-05-18
8
520 Views
Last Modified: 2012-05-07
I got past the compile errors on my conversion from managed extensions for C++(.Net 1.1) to C++ CLI (.Net 2+).

Now i have several link errors like the one below.

.cctor is a constructor, right?  How do i know which constructor it can't find?

Thanks!
Error	27	error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ)	MyClass.obj	MyLibrary

Open in new window

0
Comment
Question by:Daniel Wilson
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 24412024
>> cctor is a constructor, right?
Yes

>> How do i know which constructor it can't find?
Looking at the linker error I'd guess it's looking for a default constructor.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 450 total points
ID: 24412028
From help about LNK2001:

When upgrading a managed library or web service project from Visual C++ 2003  to Visual C++ 2005, the /Zl compiler option will added to the Command  Line property page. This will cause LNK2001. Remove /Zl from the  Command Line property page to resolve. See /Zl (Omit Default Library  Name) and How to: Open Project Property  Pages for more information. Or, add msvcrt.lib and msvcmrt.lib to  the linker's Additional Dependencies property.

Is that your problem?
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24412282
/Zl is not my problem as that is on neither the compiler command line nor the linker command line.

And I have a default constructor:
MyClass::MyClass(){
  //set a class-level boolean
}

More ideas?
0
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 50 total points
ID: 24412320
Actually, cctor is probably a copy constructor (sorry, I read it wrong). Look for a definition of

MyClass::MyClass(MyClass &)

or

MyClass::MyClass(const MyClass &)

Are you trying to create a copy of a class that has noncopyable semantics (ie, copy constructor declared but not defined)?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24412424
No, there's no copy constructor for any of the classes about which it's complaining.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24412441
>> No, there's no copy constructor for any of the classes about which it's complaining.
As in no declaration nor implementation or just no implementation?
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24412475
No declaration nor implementation.

In these particular classes, a copy constructor would just make no sense.  So we never declare one.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24434529
Andy, you were right.  The /Zl was not in the huge block of command-line options, but was in the "Additional Options" section.

Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

930 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

9 Experts available now in Live!

Get 1:1 Help Now