Solved

LNK2028 and LNK2019 errors with MQSeries 6 in unmanaged c++ code in VS C++ 2005

Posted on 2010-08-13
15
1,069 Views
Last Modified: 2012-05-10
I have 2 unmanaged C++ functions that are attempting to put and get from a websphere 6 mq local queue.    Everything in my program links ok except for the functions related to MQ.
Two examples of errors are:
error LNK2028: unresolved token (0A0003A8) "public: virtual __thiscall ImqMgr::~ImqMgr(void)" (??1ImqMgr@@$$FUAE@XZ) referenced in function "public: void __thiscall ImqMgr::`vbase destructor'(void)" (??_DImqMgr@@$$FQAEXXZ)      FEPAdapterMain.obj      
and
error LNK2019: unresolved external symbol "public: virtual __thiscall ImqErr::~ImqErr(void)" (??1ImqErr@@$$FUAE@XZ) referenced in function "public: void __thiscall ImqMgr::`vbase destructor'(void)" (??_DImqMgr@@$$FQAEXXZ)      FEPAdapterMain.obj      

I have spent two days going through every forum imaginable...and nothing seems to resolve the issue.
I have not posted to many forums..so please let me know what additional information you need to help me with this problem.  I would really appreciate the help.

0
Comment
Question by:fraeliz8
  • 8
  • 3
  • 2
15 Comments
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
Not familiar with websphere; but I'll take a guess. Do you have an interface with virtual destructors ImqMgr::~ImqMgr(), but in some derived class (possibly multiple levels down), maybe you did not implement a virtual destructor for that derived class?
0
 

Author Comment

by:fraeliz8
Comment Utility
Thanks so much for answering phoffric.... here is the latest based on your comment and some others I received from other internal technical folks:

Since i have what should be all unmanaged functions: in my Visual C++ project (meaning the following wraps around both .cpp modules:)

#ifdef _MANAGED
#pragma managed(push, off)
#endif

#ifdef _MANAGED
#pragma managed(pop)
#endif

1. I have changed    /clr  (Common Language Runtime support)   to No Common Language Runtime Support
2. I have changed Runtime Library from /MT to /MDd  
3.Added what I think are virtual destructors to header file (class) and .cpp file.
(this last one seemed to have no effect. Did this after the LNK2028 had already gone away)

THe LNK 2028 errors have gone away and remain with LNK2019 (31 errors)   smilar to the following pair:
* Error 23 error LNK2019: unresolved external symbol "public: __thiscall ImqMgr::ImqMgr(void)" (??0ImqMgr@@QAE@XZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall FEPMain::GetQueue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?GetQueue@FEPMain@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@0@Z)      FEPAdapterMain.obj      

* Error 26 error LNK2019: unresolved external symbol "public: virtual __thiscall ImqMgr::~ImqMgr(void)" (??1ImqMgr@@UAE@XZ) referenced in function "public: void __thiscall ImqMgr::`vbase destructor'(void)" (??_DImqMgr@@QAEXXZ)      FEPAdapterMain.obj      


**************************************************
and  the final error mentions 26 unresolved externals:
Error      32      fatal error LNK1120: 26 unresolved externals      C:\Facets\TRG_461\Applications\Meta\FEP\FEPAdapter\Debug\FEPAdapterWrapperCPP2.dll      
similar to:

This used to be  27 unresolved externals..and quite frankly I'm not sure what caused the decrease by 1 : )

0
 

Author Comment

by:fraeliz8
Comment Utility
One more thing.  When i comment out all code related to websphere MQ... the project builds wih  out error.  I just left in the shell of the functions and commented out all code except for one declare and a return statement.
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
Is this correct?
LNK2019: In your FEPAdapterMain.cpp file  is FEPMain::GetQueue() method, which has a ImqMgr object defined (which invokes the ImqMgr constructor). In FEPAdapterMain.cpp is an #include statement in which the ImqMgr constructor is declared.

If correct, then where is the ImqMgr constructor defined, in source code that you compile and link in?
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
>> LNK2019: unresolved external symbol  ImqMgr::~ImqMgr referenced in ... FEPAdapterMain.obj
>> Added ... virtual destructors to header file (class) and .cpp file
Is it true that class(es) in FEPAdapterMain is(are) derived from ImqMgr? If so, you added virtual destructor(s) in them, right? You can post your code (or snippets) if you wish.

============

Some generic advice:

In reviewing these errors online, I see that some recommendations is to start fresh. Sometimes this advice is necessary because VS gets hosed (when even clean does not work, and even after you manually clean out what clean fails to remove as I have seen this myself).

Even if VS is not hosed (as it has been for me on a few occasions), a fresh start can help.
Have you tried creating a new workspace and project with just the most basic main() program you can come up with (preferably, one right out of the manual - a MQ Hello World)? It should include only a minimal amount of code related to websphere MQ right out of the documentation. Then build upon this "working build" one step at a time adding the problematic function/method calls. This may help identify the single step that causes a good build to yield the errors you are seeing.

============

I see from your recent comment that the problem lies in dll - not my bailiwick. If you make no further progress, let me know, and I'll see if I can find some additional support for you.

============

Some additional references for: websphere MQ LNK2019 error (you may have seen these as you have already taken some of the advice).

http://www-01.ibm.com/support/docview.wss?uid=swg21109469

http://www.ibm.com/developerworks/forums/thread.jspa?threadID=108480
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/9dcad286-0afe-4ab0-8156-af9e0e8294e4
0
 
LVL 11

Expert Comment

by:cup
Comment Utility
Looks like the code for ImqMgr is not linked in.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 32

Expert Comment

by:phoffric
Comment Utility
From the link above:    "try adding mqm.lib to the link"
Did you verify that mqm.lib is in your link?
0
 

Accepted Solution

by:
fraeliz8 earned 0 total points
Comment Utility
I really do appreciate all the assistance......really do.   Not sure how I provide credit...i see you guys get points for things solved etc....and you did partially help me.

Well..... went to the IBM maintenance contract....and it seems you guys were on the right path... something was not linked in...turned out to be that i needed
Added two of the below to additional dependencies in the link.... and it built.  I guess just supplying the path containing these was not enough.

imqb23vn.lib.... this is base
(imqb13vn.lib is needed whether just running the client (like our meta frames with the environment Variable, or actually on the box with the mq server.

Then one of the following.
imqs23vn.lib....  use this one for server

imqc23vn.lib....  use this one for client
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
I think your last post which provided the complete solution should be the accepted solution since that information will provide a good source of information for the PAQ. Then assign points to other posts which also assist the question which, in your opinion, will also help the PAQ.
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
>> and you did partially help me
I see you gave us 0 points. You are able to provide points for partial help. Do you know how to do this?
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
Recommend splitting points since author said "you did partially help me"; and the supplied answers may be useful for the PAQ.
0
 
LVL 11

Expert Comment

by:cup
Comment Utility
I don't think I helped at all so if you are awarding any points, give them to phorffric.
0
 
LVL 32

Expert Comment

by:phoffric
Comment Utility
Recommend points for http:#33434958 and http:#33435632
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

772 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

12 Experts available now in Live!

Get 1:1 Help Now