Solved

Linking issues in MSVC program using IONA's Orbacus 4.1.1

Posted on 2002-06-11
3
1,025 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

732 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