Migration

K

Ken

Hi all,

I got a *.lib files and some header files from a thrid party which is
developed using ANSI C. I am now trying to create a managed C++ application
and import those libraries. I added the lib file in the linker option and
include those header files inside the program. Everything is ok when i
complied the project.

However, when I call one of the function inside the lib file I imported
and compile the project, a lot of multiple defined symbol error is found.
(e.g. ___argc already defined in libcmtd.lib(crt0dat.obj)). I don't know
what's wrong with it as I am new to both C++ and VC++.NET. Can anyone help
??

Kenneth
 
B

Bernd Muent

Ken said:
I got a *.lib files and some header files from a thrid party which is
developed using ANSI C. I am now trying to create a managed C++ application
and import those libraries. I added the lib file in the linker option and
include those header files inside the program. Everything is ok when i
complied the project.

However, when I call one of the function inside the lib file I imported
and compile the project, a lot of multiple defined symbol error is found.
(e.g. ___argc already defined in libcmtd.lib(crt0dat.obj)). I don't know
what's wrong with it as I am new to both C++ and VC++.NET. Can anyone help

Maybe you included the header files more then once?
"#pragma once" might help you.

B.
 
C

Carl Daniel [VC++ MVP]

Ken said:
Hi all,

I got a *.lib files and some header files from a thrid party which
is developed using ANSI C. I am now trying to create a managed C++
application and import those libraries. I added the lib file in the
linker option and include those header files inside the program.
Everything is ok when i complied the project.

However, when I call one of the function inside the lib file I
imported and compile the project, a lot of multiple defined symbol
error is found. (e.g. ___argc already defined in
libcmtd.lib(crt0dat.obj)). I don't know what's wrong with it as I am
new to both C++ and VC++.NET. Can anyone help ??

The problem is that the library and the code you're trying to link it in to
were compiled with different runtime library settings (e.g. the library was
compiled with /MT and you're compiling with /MD). Your choices are two:

1. Re-compile the library with /MD to match your managed code.

2. Add the linker option /NODEFAULTLIB:LIBCMTD.LIB to your linker settings
(you'll likely have to add /NODEFAULTLIB:LIBCMT.LIB to the release build
configuration as well).

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top