Solved

Linking issues in MSVC program using IONA's Orbacus 4.1.1

Posted on 2002-06-11
3
1,021 Views
Last Modified: 2008-03-17
Hi,

I have the source code of IONA's Orbacus 4.1.1 product and a makefile for MSVC supplied by IONA to compile the product. In the instructions it is mentioned that I have to compile any program which uses Orbacus 4.1.1 using the same compiler options which I used to compile the Orbacus 4.1.1 source code. I compiled Orbacus 4.1.1 using the default options which were there in the makefile for MSVC supplied by IONA. Then I studied the makefile and used the same compiler /linker switches to compile my program (a simple hello world application). The are no errors in compiling but errors in linking which are detailed below:

Linking...
msvcirtd.lib(MSVCIRTD.dll) : error LNK2005: "public: class ostream & __thiscall ostream::operator<<(class ostream & (__cdecl*)(class ostream &))" (??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z) already defined in Server.obj
msvcirtd.lib(MSVCIRTD.dll) : error LNK2005: "class ostream & __cdecl endl(class ostream &)" (?endl@@YAAAVostream@@AAV1@@Z) already defined in Server.obj
LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRT.lib(MSVCRT.dll)
LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRT.lib(crtexe.obj)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRT.lib(MSVCRT.dll)
LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRT.lib(MSVCRT.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
libcimtd.lib(streamb.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z)
Debug/CS.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

CS.exe - 13 error(s), 2 warning(s)

If I exclude the libraries MSVCRT and LIBCMT using /NODEFAULTLIB option of MSVC 6.0 then I get lot more errors because of other symbols which are required from these two libraries.

I will tell you what compiler options I am using for compiling both Orbacus 4.1.1 and my program.

Orbacus is compiled using:

1. Default options in the makefile for MSVC where /MD flag is default, ie. compile as multithreaded dll with no debug options.
2. OLD_IOSTREAM is not defined at all.
3. DEBUG is not defined at all.

A typical command line for compiling Orbacus 4.1.1 is:
cl.exe /c /I. /I ..\include /DWIN32 /nologo /MD /W3 /Gx /Gy /GR /Fd ..\lib\jtc.pdb

A new MSVC project is chosen as:

1. 'Win32 Console Application', 'Empty Project'.
2. 'Multithreaded DLL' from 'use run-time library:' option, ie. /MD flag is set.
3. 'Enable Exception Handling' and 'Enable Run-Time Type Information (RTTI' from 'Project Settings -> C/C++ -> C++ Language' option.
4. Libraries wsock32.lib, advapi.lib, ob.lib, jtc.lib added to 'Project Settings -> Link -> Input -> Object/library modules' option.
5. In cpp files I/O library file included is 'iostream.h'.

I want to know if I need to change some compiler / linker options in the makefile to compile Orbacus 4.1.1 or I need to change some compiler / linker options of MSVC for the program which uses Orbacus 4.1.1.

Best regards,
Aditya
0
Comment
Question by:aditya_mehta
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 25 total points
ID: 7072471
It sounds like you are liking to both the DLL and staticly linked run time libraries (RTL).    Vc has two versions of the RTL, one is a DLL, which must be pressent when the program is run and the other is the static version that gets placed right into your program.   It sounds like your are using both.

I think that linking to MSVCRT.LIB is the problem.  Can you remove the option to link to it?
0
 
LVL 11

Expert Comment

by:griessh
ID: 7262266
Dear aditya_mehta

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "nietod"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7332931
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

685 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