Re: Calling native C++ dll code from managed C++

From: Paul Brun (pb_newsgroup_at_pbrun.net)
Date: 03/05/04


Date: Fri, 5 Mar 2004 10:51:12 -0500

I have read your articles, but it seem to have a problem using the following
steps to build me Managed C++ Wrapper for a C library.

- Link with /NOENTRY. In Solution Explorer, right-click the project node and
click Properties. In the project's Property Pages dialog box, click Linker,
and then click Command Line. Add this switch to the Additional Options
field.
- Link msvcrt.lib. In the project's Property Pages dialog box, click Linker,
and then click Input. Add msvcrt.lib to the Additional Dependencies
property.
- Remove nochkclr.obj. On the Input page (same page as previous step),
remove nochkclr.obj from the Additional Dependencies property.
- Link in the CRT. On the Input page (same page as previous step), add
__DllMainCRTStartup@12 to the Force Symbol References property.

These steps are highlighted on the Microsoft website, however, in order for
my library to
compile and link properly, I have to skip step 2. If I don't, I get the
following errors:

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)
libcmt.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined
in msvcrt.lib(MSVCR71.dll)
libcmt.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in
msvcrt.lib(MSVCR71.dll)
libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup
D:\Mitel-Development\MiTAI.NET\MitaiNet\Debug\MitaiNet.dll : fatal error
LNK1120: 1 unresolved externals

However, if I were to leave my .NET Class Library settings like they were
when ti was created, I get the linker error that references the "_main"
symbol being unresolved.

Now, my application is not running correctly because of an exception within
the "strtok" function as outline in another post that nobody has been able
to help me with...

Thanks
Paul



Relevant Pages

  • Re: Home brew Z80 CP/M computer
    ... nice pile of assemblers and linkers. ... But it doesn't say what the SLR tools do with it. ... The thing that I absolutely _LOVED_ about the SLR tools was how well they dealt with external references. ... Reading between the lines, it was easy enough to figure out that Steve had defined a stack machine to do the address calculations, and embedded that into the linker. ...
    (comp.os.cpm)
  • Re: Im a stupid blond :( Please help me!!!
    ... > in a program to be left out of the external references table. ... Well for one the linker that comes with Microsoft Visual Studio 6 (not ... It's the loader's job to adjust ... > get the entire object file that contains that function linked in. ...
    (comp.lang.cpp)
  • Re: strange linking problem
    ... I usually use C, and since strings ... > files and looks for unsatisfied references to functions and variables. ... then I don't understand how the linker does not either ... that there should be a data area of a certain size and a certain name. ...
    (comp.lang.fortran)
  • Re: Strange linker warning?
    ... The warning means that the linker optimized away all references to functions ... The optimization kicks in only after all symbols are resolved. ... your link is pulling in something that references CEDDK. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Strange issues with linking
    ... Now I set a dependency d:\vtk50\Lib thinking that this should resolve the missing 16 unresolved externals ... It seems that the Linker now finds the unresolved externals ... Why does the Linker find the .Lib files and then generate the need for a Lib.obj file that it didn't need before? ... The 16 unresolved externals errors did not go away, its just that the linker was not able to get to the point of trying to resolve externals since you provided a bad dependency. ...
    (microsoft.public.dotnet.languages.vc)

Loading