Solved

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

Posted on 2010-08-13
15
1,087 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
ID: 33429172
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
ID: 33431700
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
ID: 33432572
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 32

Expert Comment

by:phoffric
ID: 33434474
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
ID: 33434958
>> 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
ID: 33435592
Looks like the code for ImqMgr is not linked in.
0
 
LVL 32

Expert Comment

by:phoffric
ID: 33435632
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
ID: 33437636
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
ID: 33437799
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
ID: 33441835
>> 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
ID: 33452439
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
ID: 33456839
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
ID: 33471838
Recommend points for http:#33434958 and http:#33435632
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

830 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