Solved

Linking issues in MSVC program using IONA's Orbacus 4.1.1

Posted on 2002-06-11
3
1,013 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
Comment Utility
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
Comment Utility
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
Comment Utility
Force accepted

** Mindphaser - Community Support Moderator **
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

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…
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 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 learn how to clear a vector as well as how to detect empty vectors in C++.

728 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